@ancientpantheon/khronoton-core 0.9.0 → 0.11.0
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/CHANGELOG.md +29 -0
- package/README.md +8 -0
- package/dist/blockchain/stoachain.d.ts +1 -22
- package/dist/blockchain/stoachain.js +44 -3
- package/dist/{chunk-5LYT7ZLA.js → chunk-GNQ2IVXA.js} +60 -10
- package/dist/{chunk-5OB5NQ4S.js → chunk-LX6T2BDL.js} +1 -1
- package/dist/{context-Cv3H82B5.d.ts → context-89YS4xT3.d.ts} +2 -2
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/index.js +2 -2
- package/dist/provider/index.d.ts +4 -4
- package/dist/provider/index.js +2 -2
- package/dist/{seams-CPj31tJJ.d.ts → seams-DUtxDw_U.d.ts} +29 -1
- package/dist/server/executor.d.ts +28 -8
- package/dist/server/executor.js +106 -20
- package/dist/server/seams.d.ts +29 -1
- package/dist/server/store/cronoton.js +6 -1
- package/dist/server/store/index.d.ts +1 -1
- package/dist/server/store/index.js +1 -1
- package/dist/server/store/mappers.d.ts +13 -0
- package/dist/server/store/mappers.js +20 -1
- package/dist/server/types.d.ts +15 -1
- package/dist/{types-u_nUX1Bg.d.ts → types-DnFB1Yz-.d.ts} +15 -1
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +244 -54
- package/package.json +1 -1
package/dist/ui/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useServerResolvers, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-
|
|
2
|
-
import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-
|
|
1
|
+
import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useServerResolvers, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-LX6T2BDL.js';
|
|
2
|
+
import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-GNQ2IVXA.js';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import { lazy, forwardRef, createElement, useState, useEffect, useCallback, Suspense, useContext } from 'react';
|
|
4
|
+
import { lazy, forwardRef, createElement, useState, useEffect, useCallback, useMemo, Suspense, useContext } from 'react';
|
|
5
5
|
|
|
6
6
|
function KhronotonUiRoot({ children, className }) {
|
|
7
7
|
const cls = className ? `khronoton-ui ${className}` : "khronoton-ui";
|
|
@@ -1347,7 +1347,7 @@ function Loaded({
|
|
|
1347
1347
|
var MSG = {
|
|
1348
1348
|
name: "Name is required.",
|
|
1349
1349
|
ttl: "TTL must be between 60 and 86400 seconds.",
|
|
1350
|
-
|
|
1350
|
+
gasPriceBuffer: "Priority buffer cannot be negative.",
|
|
1351
1351
|
gasLimit: "Gas limit must be greater than zero.",
|
|
1352
1352
|
autoGas: "AUTO gas requires a successful Simulate to calibrate, or switch to manual.",
|
|
1353
1353
|
signers: "At least one signer is required.",
|
|
@@ -1362,12 +1362,16 @@ function makeEmptyBuilderState() {
|
|
|
1362
1362
|
pactCode: "",
|
|
1363
1363
|
config: {
|
|
1364
1364
|
chainId: "0",
|
|
1365
|
-
//
|
|
1366
|
-
//
|
|
1367
|
-
//
|
|
1368
|
-
|
|
1365
|
+
// 0 = pay exactly the live floor at fire time. The executor always
|
|
1366
|
+
// prices from the live network floor plus this buffer, so a cronoton
|
|
1367
|
+
// created at this default never underprices as the floor rises.
|
|
1368
|
+
gasPriceBufferAnu: 0,
|
|
1369
1369
|
gasLimit: 1500,
|
|
1370
|
-
|
|
1370
|
+
// AUTO is now the default per the auto-gas handoff: a fixed manual
|
|
1371
|
+
// limit was the prior default's failure mode (real fires over-reserve
|
|
1372
|
+
// gas wildly against a static number). Manual stays available as a
|
|
1373
|
+
// deliberate toggle for the operators who want it.
|
|
1374
|
+
autoGasLimit: true,
|
|
1371
1375
|
ttl: 600
|
|
1372
1376
|
},
|
|
1373
1377
|
payload: {
|
|
@@ -1387,8 +1391,9 @@ function makeEmptyBuilderState() {
|
|
|
1387
1391
|
runtimeArgKeysText: ""
|
|
1388
1392
|
};
|
|
1389
1393
|
}
|
|
1390
|
-
function maxTxFee(config) {
|
|
1391
|
-
|
|
1394
|
+
function maxTxFee(config, liveFloorAnu) {
|
|
1395
|
+
if (liveFloorAnu == null) return null;
|
|
1396
|
+
return (liveFloorAnu + config.gasPriceBufferAnu) * config.gasLimit;
|
|
1392
1397
|
}
|
|
1393
1398
|
function parseRuntimeArgKeysText(text) {
|
|
1394
1399
|
return text.split(/[,\n]/).map((k) => k.trim()).filter((k) => k.length > 0);
|
|
@@ -1466,7 +1471,9 @@ function toSigner(row) {
|
|
|
1466
1471
|
function builderToCommit(state, opts) {
|
|
1467
1472
|
const config = {
|
|
1468
1473
|
chainId: state.config.chainId,
|
|
1469
|
-
gasPrice:
|
|
1474
|
+
gasPrice: 0,
|
|
1475
|
+
// deprecated — kept as an honest 0 placeholder; never read for pricing
|
|
1476
|
+
gasPriceBufferAnu: state.config.gasPriceBufferAnu,
|
|
1470
1477
|
gasLimit: state.config.gasLimit,
|
|
1471
1478
|
autoGasLimit: state.config.autoGasLimit,
|
|
1472
1479
|
ttl: state.config.ttl
|
|
@@ -1490,7 +1497,6 @@ function builderToCommit(state, opts) {
|
|
|
1490
1497
|
if (runtimeArgKeys.length > 0) body.envelope.runtimeArgKeys = runtimeArgKeys;
|
|
1491
1498
|
return body;
|
|
1492
1499
|
}
|
|
1493
|
-
var GENESIS_MIN_GAS_ANU = 1e4;
|
|
1494
1500
|
function validateName(state) {
|
|
1495
1501
|
return state.name.trim().length === 0 ? [MSG.name] : [];
|
|
1496
1502
|
}
|
|
@@ -1498,8 +1504,9 @@ function validateConfig(state, opts = {}) {
|
|
|
1498
1504
|
const errors = [];
|
|
1499
1505
|
const c = state.config;
|
|
1500
1506
|
if (c.ttl < 60 || c.ttl > 86400) errors.push(MSG.ttl);
|
|
1501
|
-
|
|
1502
|
-
|
|
1507
|
+
if (!Number.isFinite(c.gasPriceBufferAnu) || c.gasPriceBufferAnu < 0) {
|
|
1508
|
+
errors.push(MSG.gasPriceBuffer);
|
|
1509
|
+
}
|
|
1503
1510
|
if (c.gasLimit <= 0) errors.push(MSG.gasLimit);
|
|
1504
1511
|
const autoGasWaived = Boolean(state.serverResolver) || isTriggerOnly2(state);
|
|
1505
1512
|
if (c.autoGasLimit && !opts.simulateCalibrated && !autoGasWaived) errors.push(MSG.autoGas);
|
|
@@ -1606,7 +1613,7 @@ function detailToBuilderState(row) {
|
|
|
1606
1613
|
pactCode: row.pact_code,
|
|
1607
1614
|
config: {
|
|
1608
1615
|
chainId: storedConfig.chainId,
|
|
1609
|
-
|
|
1616
|
+
gasPriceBufferAnu: storedConfig.gasPriceBufferAnu ?? 0,
|
|
1610
1617
|
gasLimit: storedConfig.gasLimit,
|
|
1611
1618
|
autoGasLimit: storedConfig.autoGasLimit,
|
|
1612
1619
|
ttl: storedConfig.ttl
|
|
@@ -1829,6 +1836,10 @@ function BuilderHeader({
|
|
|
1829
1836
|
function formatThousands(n) {
|
|
1830
1837
|
return n.toLocaleString("en-US");
|
|
1831
1838
|
}
|
|
1839
|
+
function postponedMessage(plannedCount) {
|
|
1840
|
+
const detail = typeof plannedCount === "number" ? ` \u2014 ${plannedCount} planned transaction${plannedCount === 1 ? "" : "s"}` : "";
|
|
1841
|
+
return `Simulation postponed${detail}.`;
|
|
1842
|
+
}
|
|
1832
1843
|
var INPUT_STYLE4 = {
|
|
1833
1844
|
display: "block",
|
|
1834
1845
|
width: "100%",
|
|
@@ -1899,13 +1910,19 @@ var GAS_LABEL_STYLE = {
|
|
|
1899
1910
|
function Hint({ children }) {
|
|
1900
1911
|
return /* @__PURE__ */ jsx("p", { style: HINT_STYLE, children });
|
|
1901
1912
|
}
|
|
1902
|
-
function ConfigTab({
|
|
1913
|
+
function ConfigTab({
|
|
1914
|
+
state,
|
|
1915
|
+
onChange,
|
|
1916
|
+
calibratedGasLimit,
|
|
1917
|
+
liveFloorAnu
|
|
1918
|
+
}) {
|
|
1903
1919
|
const config = state.config;
|
|
1904
1920
|
const patch = (next) => {
|
|
1905
1921
|
onChange({ ...state, config: { ...config, ...next } });
|
|
1906
1922
|
};
|
|
1907
1923
|
const auto = config.autoGasLimit;
|
|
1908
1924
|
const calibrated = typeof calibratedGasLimit === "number";
|
|
1925
|
+
const fee = maxTxFee(config, liveFloorAnu ?? null);
|
|
1909
1926
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1910
1927
|
/* @__PURE__ */ jsx(Title, { children: "Transaction Configuration" }),
|
|
1911
1928
|
/* @__PURE__ */ jsxs(Field, { label: "Chain ID", children: [
|
|
@@ -1920,18 +1937,22 @@ function ConfigTab({ state, onChange, calibratedGasLimit }) {
|
|
|
1920
1937
|
),
|
|
1921
1938
|
/* @__PURE__ */ jsx(Hint, { children: "Single chain per job (Stoa Network)." })
|
|
1922
1939
|
] }),
|
|
1923
|
-
/* @__PURE__ */ jsxs(Field, { label: "
|
|
1940
|
+
/* @__PURE__ */ jsxs(Field, { label: "Live Network Floor (ANU)", children: [
|
|
1941
|
+
/* @__PURE__ */ jsx("div", { style: DISPLAY_STYLE, children: liveFloorAnu != null ? `${formatThousands(liveFloorAnu)} ANU` : "Loading\u2026" }),
|
|
1942
|
+
/* @__PURE__ */ jsx(Hint, { children: "The chain's live minimum gas price right now. Refreshes automatically." })
|
|
1943
|
+
] }),
|
|
1944
|
+
/* @__PURE__ */ jsxs(Field, { label: "Priority Buffer (ANU above floor)", children: [
|
|
1924
1945
|
/* @__PURE__ */ jsx(
|
|
1925
1946
|
"input",
|
|
1926
1947
|
{
|
|
1927
|
-
"aria-label": "
|
|
1948
|
+
"aria-label": "Priority Buffer (ANU above floor)",
|
|
1928
1949
|
type: "number",
|
|
1929
1950
|
style: INPUT_STYLE4,
|
|
1930
|
-
value: config.
|
|
1931
|
-
onChange: (e) => patch({
|
|
1951
|
+
value: config.gasPriceBufferAnu,
|
|
1952
|
+
onChange: (e) => patch({ gasPriceBufferAnu: Number(e.target.value) })
|
|
1932
1953
|
}
|
|
1933
1954
|
),
|
|
1934
|
-
/* @__PURE__ */ jsx(Hint, { children: "
|
|
1955
|
+
/* @__PURE__ */ jsx(Hint, { children: "The transaction always pays the live floor at fire time, plus this. Leave at 0 unless you need priority over other pending transactions." })
|
|
1935
1956
|
] }),
|
|
1936
1957
|
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "14px" }, children: [
|
|
1937
1958
|
/* @__PURE__ */ jsxs("div", { style: GAS_HEAD_STYLE, children: [
|
|
@@ -1963,9 +1984,9 @@ function ConfigTab({ state, onChange, calibratedGasLimit }) {
|
|
|
1963
1984
|
auto ? /* @__PURE__ */ jsx(Hint, { children: calibrated ? `Calibrated: ${formatThousands(calibratedGasLimit)} gas` : "Run Simulate to calibrate the auto gas limit." }) : null
|
|
1964
1985
|
] }),
|
|
1965
1986
|
/* @__PURE__ */ jsx(Field, { label: "Max Tx Fee (ANU)", children: /* @__PURE__ */ jsxs("div", { style: DISPLAY_STYLE, children: [
|
|
1966
|
-
formatThousands(
|
|
1967
|
-
"
|
|
1968
|
-
/* @__PURE__ */ jsx("span", { style: MUTED_STYLE, children: "(
|
|
1987
|
+
fee != null ? `${formatThousands(fee)} ANU` : "\u2026",
|
|
1988
|
+
" ",
|
|
1989
|
+
/* @__PURE__ */ jsx("span", { style: MUTED_STYLE, children: "((floor + buffer) x gas limit)" })
|
|
1969
1990
|
] }) }),
|
|
1970
1991
|
/* @__PURE__ */ jsxs(Field, { label: "Time To Live (seconds)", children: [
|
|
1971
1992
|
/* @__PURE__ */ jsx(
|
|
@@ -3331,10 +3352,14 @@ var REASONS_STYLE = {
|
|
|
3331
3352
|
var TRIGGER_ONLY_SCHEDULE = "Trigger-only (external / manual)";
|
|
3332
3353
|
var EVENT_DRIVEN_SCHEDULE = "Event-driven (host-fired)";
|
|
3333
3354
|
var EVENT_DRIVEN_NOTICE = "Event-driven \u2014 the host application fires this when its trigger condition is met; there is no schedule.";
|
|
3334
|
-
function gasLine(state) {
|
|
3355
|
+
function gasLine(state, liveFloorAnu) {
|
|
3335
3356
|
const c = state.config;
|
|
3336
3357
|
const suffix = c.autoGasLimit ? " (AUTO)" : "";
|
|
3337
|
-
|
|
3358
|
+
const buffer = c.gasPriceBufferAnu;
|
|
3359
|
+
if (liveFloorAnu == null) return `${formatThousands(c.gasLimit)} @ \u2026 ANU${suffix}`;
|
|
3360
|
+
const total = liveFloorAnu + buffer;
|
|
3361
|
+
const priceLabel = buffer > 0 ? `${formatThousands(total)} ANU (floor + ${formatThousands(buffer)})` : buffer < 0 ? `${formatThousands(total)} ANU (floor - ${formatThousands(Math.abs(buffer))})` : `${formatThousands(total)} ANU (floor)`;
|
|
3362
|
+
return `${formatThousands(c.gasLimit)} @ ${priceLabel}${suffix}`;
|
|
3338
3363
|
}
|
|
3339
3364
|
function gasPayerLabel(gasPayer) {
|
|
3340
3365
|
if (gasPayer.type === "gas-station") return "Gas Station";
|
|
@@ -3370,15 +3395,14 @@ function ExecuteTab({
|
|
|
3370
3395
|
onCommit,
|
|
3371
3396
|
committing,
|
|
3372
3397
|
eventDrivenResolver,
|
|
3373
|
-
sim
|
|
3398
|
+
sim,
|
|
3399
|
+
liveFloorAnu,
|
|
3400
|
+
isEdit,
|
|
3401
|
+
commit,
|
|
3402
|
+
gate
|
|
3374
3403
|
}) {
|
|
3375
3404
|
const [banner, setBanner] = useState(null);
|
|
3376
|
-
const commit = builderToCommit(state);
|
|
3377
3405
|
const payloadKeyCount = Object.keys(commit.envelope.payload ?? {}).length;
|
|
3378
|
-
const simulateCalibrated = Boolean(
|
|
3379
|
-
sim.result?.ok && typeof sim.result.calibratedGasLimit === "number"
|
|
3380
|
-
);
|
|
3381
|
-
const gate = canCommit(state, { simulateCalibrated });
|
|
3382
3406
|
const triggerOnly = isTriggerOnly2(state);
|
|
3383
3407
|
const schedulerOff = triggerOnly || state.externalFireable || Boolean(eventDrivenResolver);
|
|
3384
3408
|
const onSimulate = async () => {
|
|
@@ -3388,8 +3412,7 @@ function ExecuteTab({
|
|
|
3388
3412
|
return;
|
|
3389
3413
|
}
|
|
3390
3414
|
if (view.postponed) {
|
|
3391
|
-
|
|
3392
|
-
setBanner(renderBanner("var(--khr-accent)", `Simulation postponed${detail}.`));
|
|
3415
|
+
setBanner(renderBanner("var(--khr-accent)", postponedMessage(view.plannedCount)));
|
|
3393
3416
|
return;
|
|
3394
3417
|
}
|
|
3395
3418
|
if (view.ok) {
|
|
@@ -3422,7 +3445,7 @@ function ExecuteTab({
|
|
|
3422
3445
|
/* @__PURE__ */ jsxs(Panel, { style: { marginBottom: "16px" }, children: [
|
|
3423
3446
|
/* @__PURE__ */ jsx("div", { style: { ...ROW_LABEL_STYLE, marginBottom: "4px" }, children: "Transaction Summary" }),
|
|
3424
3447
|
/* @__PURE__ */ jsx(SummaryRow, { label: "Chain", value: state.config.chainId, testId: "summary-chain" }),
|
|
3425
|
-
/* @__PURE__ */ jsx(SummaryRow, { label: "Gas", value: gasLine(state), testId: "summary-gas" }),
|
|
3448
|
+
/* @__PURE__ */ jsx(SummaryRow, { label: "Gas", value: gasLine(state, liveFloorAnu), testId: "summary-gas" }),
|
|
3426
3449
|
/* @__PURE__ */ jsx(SummaryRow, { label: "TTL", value: `${state.config.ttl}s`, testId: "summary-ttl" }),
|
|
3427
3450
|
/* @__PURE__ */ jsx(SummaryRow, { label: "Payload keys", value: String(payloadKeyCount), testId: "summary-payload" }),
|
|
3428
3451
|
/* @__PURE__ */ jsx(SummaryRow, { label: "Gas payer", value: gasPayerLabel(state.gasPayer), testId: "summary-gaspayer" }),
|
|
@@ -3451,7 +3474,7 @@ function ExecuteTab({
|
|
|
3451
3474
|
style: commitEnabled ? COMMIT_ENABLED_STYLE : COMMIT_DISABLED_STYLE,
|
|
3452
3475
|
disabled: !commitEnabled,
|
|
3453
3476
|
onClick: onCommitClick,
|
|
3454
|
-
children: "Commit Codex Cronoton"
|
|
3477
|
+
children: isEdit ? committing ? "Saving\u2026" : "Save changes" : "Commit Codex Cronoton"
|
|
3455
3478
|
}
|
|
3456
3479
|
),
|
|
3457
3480
|
!gate.ok ? /* @__PURE__ */ jsx("ul", { style: REASONS_STYLE, children: gate.reasons.map((reason) => /* @__PURE__ */ jsx("li", { children: reason }, reason)) }) : null
|
|
@@ -3468,6 +3491,98 @@ function renderBanner(color, message) {
|
|
|
3468
3491
|
}
|
|
3469
3492
|
);
|
|
3470
3493
|
}
|
|
3494
|
+
var BAR_STYLE = {
|
|
3495
|
+
display: "flex",
|
|
3496
|
+
alignItems: "center",
|
|
3497
|
+
gap: "12px",
|
|
3498
|
+
padding: "10px 12px",
|
|
3499
|
+
marginBottom: "12px",
|
|
3500
|
+
border: "1px solid var(--khr-border)",
|
|
3501
|
+
borderRadius: "var(--khr-radius)",
|
|
3502
|
+
background: "var(--khr-panel)"
|
|
3503
|
+
};
|
|
3504
|
+
var SIMULATE_BUTTON_STYLE2 = {
|
|
3505
|
+
border: "1px solid var(--khr-border)",
|
|
3506
|
+
background: "var(--khr-panel)",
|
|
3507
|
+
color: "var(--khr-text)",
|
|
3508
|
+
padding: "7px 14px",
|
|
3509
|
+
borderRadius: "6px",
|
|
3510
|
+
cursor: "pointer",
|
|
3511
|
+
font: "inherit",
|
|
3512
|
+
fontSize: "12px"
|
|
3513
|
+
};
|
|
3514
|
+
var SAVE_ENABLED_STYLE = {
|
|
3515
|
+
padding: "7px 14px",
|
|
3516
|
+
border: "1px solid var(--khr-accent)",
|
|
3517
|
+
background: "var(--khr-accent-tint)",
|
|
3518
|
+
color: "var(--khr-accent)",
|
|
3519
|
+
borderRadius: "6px",
|
|
3520
|
+
cursor: "pointer",
|
|
3521
|
+
font: "inherit",
|
|
3522
|
+
fontSize: "12px",
|
|
3523
|
+
fontWeight: 600
|
|
3524
|
+
};
|
|
3525
|
+
var SAVE_DISABLED_STYLE = {
|
|
3526
|
+
...SAVE_ENABLED_STYLE,
|
|
3527
|
+
borderColor: "var(--khr-border)",
|
|
3528
|
+
background: "var(--khr-panel)",
|
|
3529
|
+
color: "var(--khr-text-dim)",
|
|
3530
|
+
cursor: "not-allowed",
|
|
3531
|
+
opacity: 0.7
|
|
3532
|
+
};
|
|
3533
|
+
var STATUS_STYLE = {
|
|
3534
|
+
margin: 0,
|
|
3535
|
+
fontSize: "12px",
|
|
3536
|
+
color: "var(--khr-text-dim)"
|
|
3537
|
+
};
|
|
3538
|
+
function saveBarStatus(sim, gate) {
|
|
3539
|
+
if (sim.pending) return "Running dry-run\u2026";
|
|
3540
|
+
const result = sim.result;
|
|
3541
|
+
if (result?.postponed) return postponedMessage(result.plannedCount);
|
|
3542
|
+
if (result && !result.ok) {
|
|
3543
|
+
return `Simulation failed \u2014 ${result.error ?? "unknown error"}`;
|
|
3544
|
+
}
|
|
3545
|
+
if (result?.ok && typeof result.calibratedGasLimit === "number") {
|
|
3546
|
+
return `Calibrated gas ${formatThousands(result.calibratedGasLimit)} \u2014 ready to save.`;
|
|
3547
|
+
}
|
|
3548
|
+
if (!gate.ok && gate.reasons.length > 0) return gate.reasons[0];
|
|
3549
|
+
return "Changes apply at the next fire.";
|
|
3550
|
+
}
|
|
3551
|
+
function SaveBar({ commit, gate, sim, onSave, committing, access }) {
|
|
3552
|
+
const mutable = canMutate(access);
|
|
3553
|
+
const onSimulate = () => {
|
|
3554
|
+
if (!mutable || sim.pending) return;
|
|
3555
|
+
void sim.run(commit.envelope);
|
|
3556
|
+
};
|
|
3557
|
+
const saveEnabled = gate.ok && !committing && mutable;
|
|
3558
|
+
const onSaveClick = () => {
|
|
3559
|
+
if (gate.ok && !committing && mutable) onSave();
|
|
3560
|
+
};
|
|
3561
|
+
const status = mutable ? saveBarStatus(sim, gate) : ADMIN_ONLY_TITLE;
|
|
3562
|
+
return /* @__PURE__ */ jsxs("div", { style: BAR_STYLE, children: [
|
|
3563
|
+
/* @__PURE__ */ jsx(
|
|
3564
|
+
"button",
|
|
3565
|
+
{
|
|
3566
|
+
type: "button",
|
|
3567
|
+
style: SIMULATE_BUTTON_STYLE2,
|
|
3568
|
+
disabled: sim.pending || !mutable,
|
|
3569
|
+
onClick: onSimulate,
|
|
3570
|
+
children: sim.pending ? "Simulating\u2026" : "Simulate"
|
|
3571
|
+
}
|
|
3572
|
+
),
|
|
3573
|
+
/* @__PURE__ */ jsx(
|
|
3574
|
+
"button",
|
|
3575
|
+
{
|
|
3576
|
+
type: "button",
|
|
3577
|
+
style: saveEnabled ? SAVE_ENABLED_STYLE : SAVE_DISABLED_STYLE,
|
|
3578
|
+
disabled: !saveEnabled,
|
|
3579
|
+
onClick: onSaveClick,
|
|
3580
|
+
children: committing ? "Saving\u2026" : "Save changes"
|
|
3581
|
+
}
|
|
3582
|
+
),
|
|
3583
|
+
/* @__PURE__ */ jsx("p", { style: STATUS_STYLE, children: status })
|
|
3584
|
+
] });
|
|
3585
|
+
}
|
|
3471
3586
|
|
|
3472
3587
|
// src/ui/tx-size.ts
|
|
3473
3588
|
var STOA_TX_BYTE_CEILING = 2 * 1024 * 1024;
|
|
@@ -3482,7 +3597,7 @@ async function estimateTxSize(state) {
|
|
|
3482
3597
|
let bytes;
|
|
3483
3598
|
try {
|
|
3484
3599
|
const { Pact } = await import('@stoachain/kadena-stoic-legacy/client');
|
|
3485
|
-
const { anuToStoaNumber } = await import('@stoachain/stoa-core/gas');
|
|
3600
|
+
const { anuToStoaNumber, minGasPriceAnu } = await import('@stoachain/stoa-core/gas');
|
|
3486
3601
|
const { KADENA_NETWORK } = await import('@stoachain/stoa-core/constants');
|
|
3487
3602
|
const builder = Pact.builder.execution(pactCode || "").setMeta({
|
|
3488
3603
|
senderAccount: state.gasPayer.type === "codex" ? state.gasPayer.address ?? "" : "c:gas-station",
|
|
@@ -3490,9 +3605,15 @@ async function estimateTxSize(state) {
|
|
|
3490
3605
|
gasLimit: config.gasLimit,
|
|
3491
3606
|
// `anuToStoaNumber`, not `anuToStoa`: this meter exists to predict the
|
|
3492
3607
|
// SIZE of the real signed transaction, so it must serialize gasPrice
|
|
3493
|
-
// exactly the way the executor does
|
|
3494
|
-
//
|
|
3495
|
-
|
|
3608
|
+
// exactly the way the executor does — the live network floor plus
|
|
3609
|
+
// `gasPriceBufferAnu`, summed IN ANU before the ONE conversion below
|
|
3610
|
+
// (same precision fix as `blockchain/stoachain.ts`'s `gasMeta`: two
|
|
3611
|
+
// independently-converted STOA floats summed can produce a different
|
|
3612
|
+
// serialized value than converting the summed ANU once). The
|
|
3613
|
+
// deprecated `config.gasPrice` field is never read here.
|
|
3614
|
+
gasPrice: anuToStoaNumber(
|
|
3615
|
+
minGasPriceAnu(Math.floor(Date.now() / 1e3)) + (config.gasPriceBufferAnu ?? 0)
|
|
3616
|
+
),
|
|
3496
3617
|
ttl: config.ttl
|
|
3497
3618
|
}).setNetworkId(KADENA_NETWORK);
|
|
3498
3619
|
for (const [k, v] of Object.entries(payload ?? {})) {
|
|
@@ -3562,7 +3683,7 @@ function TxMeters({ state, sim }) {
|
|
|
3562
3683
|
state.pactCode,
|
|
3563
3684
|
state.config.chainId,
|
|
3564
3685
|
state.config.gasLimit,
|
|
3565
|
-
state.config.
|
|
3686
|
+
state.config.gasPriceBufferAnu,
|
|
3566
3687
|
state.config.ttl,
|
|
3567
3688
|
state.payload,
|
|
3568
3689
|
state.signers.length,
|
|
@@ -3612,6 +3733,48 @@ function TxMeters({ state, sim }) {
|
|
|
3612
3733
|
] })
|
|
3613
3734
|
] });
|
|
3614
3735
|
}
|
|
3736
|
+
var POLL_INTERVAL_MS = 3e4;
|
|
3737
|
+
function useLiveGasFloor() {
|
|
3738
|
+
const [floorAnu, setFloorAnu] = useState(null);
|
|
3739
|
+
useEffect(() => {
|
|
3740
|
+
if (typeof window === "undefined") return;
|
|
3741
|
+
let active = true;
|
|
3742
|
+
const refresh = async () => {
|
|
3743
|
+
try {
|
|
3744
|
+
const { minGasPriceAnu } = await import('@stoachain/stoa-core/gas');
|
|
3745
|
+
const value = minGasPriceAnu(Math.floor(Date.now() / 1e3));
|
|
3746
|
+
if (active) setFloorAnu(value);
|
|
3747
|
+
} catch {
|
|
3748
|
+
}
|
|
3749
|
+
};
|
|
3750
|
+
void refresh();
|
|
3751
|
+
const timer = setInterval(() => void refresh(), POLL_INTERVAL_MS);
|
|
3752
|
+
const onVisibilityChange = () => {
|
|
3753
|
+
if (document.visibilityState === "visible") void refresh();
|
|
3754
|
+
};
|
|
3755
|
+
const onFocus = () => void refresh();
|
|
3756
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
3757
|
+
window.addEventListener("focus", onFocus);
|
|
3758
|
+
return () => {
|
|
3759
|
+
active = false;
|
|
3760
|
+
clearInterval(timer);
|
|
3761
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
3762
|
+
window.removeEventListener("focus", onFocus);
|
|
3763
|
+
};
|
|
3764
|
+
}, []);
|
|
3765
|
+
return floorAnu;
|
|
3766
|
+
}
|
|
3767
|
+
function useCommitGate(state, sim) {
|
|
3768
|
+
const commit = useMemo(() => builderToCommit(state), [state]);
|
|
3769
|
+
const simulateCalibrated = Boolean(
|
|
3770
|
+
sim.result?.ok && typeof sim.result.calibratedGasLimit === "number"
|
|
3771
|
+
);
|
|
3772
|
+
const gate = useMemo(
|
|
3773
|
+
() => canCommit(state, { simulateCalibrated }),
|
|
3774
|
+
[state, simulateCalibrated]
|
|
3775
|
+
);
|
|
3776
|
+
return { commit, gate, simulateCalibrated };
|
|
3777
|
+
}
|
|
3615
3778
|
var DEFAULT_BUILDER_ROBOTS = "noindex,nofollow";
|
|
3616
3779
|
var TABS = [
|
|
3617
3780
|
{ key: "config", label: "Config" },
|
|
@@ -3656,7 +3819,7 @@ var EDIT_BANNER = {
|
|
|
3656
3819
|
};
|
|
3657
3820
|
function Builder({
|
|
3658
3821
|
editId,
|
|
3659
|
-
access
|
|
3822
|
+
access,
|
|
3660
3823
|
onDone,
|
|
3661
3824
|
robots = DEFAULT_BUILDER_ROBOTS
|
|
3662
3825
|
}) {
|
|
@@ -3726,18 +3889,33 @@ function Builder({
|
|
|
3726
3889
|
}
|
|
3727
3890
|
}, [state, isEdit, editId, actions, onDone, eventDrivenResolver]);
|
|
3728
3891
|
const calibratedGasLimit = state.config.autoGasLimit ? state.config.gasLimit : null;
|
|
3892
|
+
const liveFloorAnu = useLiveGasFloor();
|
|
3893
|
+
const { commit, gate } = useCommitGate(state, sim);
|
|
3729
3894
|
const handlePactCodeChange = useCallback((pactCode) => {
|
|
3730
3895
|
setState((s) => ({ ...s, pactCode }));
|
|
3731
3896
|
}, []);
|
|
3732
3897
|
return /* @__PURE__ */ jsxs("div", { className: "khronoton-ui", children: [
|
|
3733
3898
|
/* @__PURE__ */ jsx("meta", { name: "robots", content: robots }),
|
|
3734
|
-
isEdit && /* @__PURE__ */ jsxs(
|
|
3735
|
-
/* @__PURE__ */ jsx(
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3899
|
+
isEdit && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3900
|
+
editReady && /* @__PURE__ */ jsx(
|
|
3901
|
+
SaveBar,
|
|
3902
|
+
{
|
|
3903
|
+
commit,
|
|
3904
|
+
gate,
|
|
3905
|
+
sim,
|
|
3906
|
+
onSave: handleCommit,
|
|
3907
|
+
committing,
|
|
3908
|
+
access
|
|
3909
|
+
}
|
|
3910
|
+
),
|
|
3911
|
+
/* @__PURE__ */ jsxs("div", { style: EDIT_BANNER, children: [
|
|
3912
|
+
/* @__PURE__ */ jsx("p", { style: { margin: 0 }, children: "Edits apply at the NEXT fire. Payload opens in raw-JSON mode. Re-run Simulate before saving." }),
|
|
3913
|
+
editRow && /* @__PURE__ */ jsxs("p", { style: { margin: "0.35rem 0 0" }, children: [
|
|
3914
|
+
"Current schedule: ",
|
|
3915
|
+
editRow.schedule_mode,
|
|
3916
|
+
" \xB7 Status: ",
|
|
3917
|
+
editRow.status
|
|
3918
|
+
] })
|
|
3741
3919
|
] })
|
|
3742
3920
|
] }),
|
|
3743
3921
|
editReady ? /* @__PURE__ */ jsxs("div", { style: PANE_WRAP, children: [
|
|
@@ -3765,7 +3943,15 @@ function Builder({
|
|
|
3765
3943
|
},
|
|
3766
3944
|
t.key
|
|
3767
3945
|
)) }),
|
|
3768
|
-
activeTab === "config" && /* @__PURE__ */ jsx(
|
|
3946
|
+
activeTab === "config" && /* @__PURE__ */ jsx(
|
|
3947
|
+
ConfigTab,
|
|
3948
|
+
{
|
|
3949
|
+
state,
|
|
3950
|
+
onChange: setState,
|
|
3951
|
+
calibratedGasLimit,
|
|
3952
|
+
liveFloorAnu
|
|
3953
|
+
}
|
|
3954
|
+
),
|
|
3769
3955
|
activeTab === "payload" && /* @__PURE__ */ jsx(PayloadTab, { state, onChange: (payload) => setState((s) => ({ ...s, payload })) }),
|
|
3770
3956
|
activeTab === "gas-payer" && /* @__PURE__ */ jsx(GasPayerTab, { state, onChange: setState, signers }),
|
|
3771
3957
|
activeTab === "signatures" && /* @__PURE__ */ jsx(SignaturesTab, { state, onChange: setState, signers }),
|
|
@@ -3777,7 +3963,11 @@ function Builder({
|
|
|
3777
3963
|
onCommit: handleCommit,
|
|
3778
3964
|
committing,
|
|
3779
3965
|
eventDrivenResolver,
|
|
3780
|
-
sim
|
|
3966
|
+
sim,
|
|
3967
|
+
liveFloorAnu,
|
|
3968
|
+
isEdit,
|
|
3969
|
+
commit,
|
|
3970
|
+
gate
|
|
3781
3971
|
}
|
|
3782
3972
|
)
|
|
3783
3973
|
] })
|
|
@@ -3788,7 +3978,7 @@ var DEFAULT_PUBLIC_ROBOTS = DEFAULT_DETAIL_ROBOTS;
|
|
|
3788
3978
|
var PUBLIC_ACCESS = { tier: "logged-out" };
|
|
3789
3979
|
var PUBLIC_BAR_TEXT = "Public view \u2014 read-only transparency into this codex cronoton's schedule and fire history.";
|
|
3790
3980
|
var PUBLIC_FOOTER_TEXT = "Public view \u2014 read only. Sign in as an Ancient admin to manage.";
|
|
3791
|
-
var
|
|
3981
|
+
var BAR_STYLE2 = {
|
|
3792
3982
|
marginBottom: "16px",
|
|
3793
3983
|
padding: "10px 14px",
|
|
3794
3984
|
borderRadius: "8px",
|
|
@@ -3804,7 +3994,7 @@ var FOOTER_STYLE = {
|
|
|
3804
3994
|
};
|
|
3805
3995
|
function Public({ id, robots = DEFAULT_PUBLIC_ROBOTS }) {
|
|
3806
3996
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3807
|
-
/* @__PURE__ */ jsx("div", { style:
|
|
3997
|
+
/* @__PURE__ */ jsx("div", { style: BAR_STYLE2, children: PUBLIC_BAR_TEXT }),
|
|
3808
3998
|
/* @__PURE__ */ jsx(Detail, { id, access: PUBLIC_ACCESS, robots }),
|
|
3809
3999
|
/* @__PURE__ */ jsx("p", { style: FOOTER_STYLE, children: PUBLIC_FOOTER_TEXT })
|
|
3810
4000
|
] });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancientpantheon/khronoton-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Headless framework-agnostic scheduler engine: pure schedule math plus an injectable tick engine. No database, no job queue, no framework — hosts inject storage and firing via hooks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|