@useopentab/cli 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +147 -2
- package/dist/bin.js +361 -0
- package/dist/chunks/chunk-4R3NAR3C.js +28 -0
- package/dist/chunks/chunk-D3C7KAMJ.js +2221 -0
- package/dist/chunks/chunk-EKJH2AJS.js +371 -0
- package/dist/chunks/chunk-GOEFQ62Z.js +53 -0
- package/dist/chunks/chunk-HTU7QRDF.js +223 -0
- package/dist/chunks/chunk-HZHOKJIM.js +360 -0
- package/dist/chunks/chunk-IRXOU25X.js +1856 -0
- package/dist/chunks/chunk-MOZ4BFSB.js +13 -0
- package/dist/chunks/chunk-Q776JIO3.js +1821 -0
- package/dist/chunks/chunk-QTI2WM44.js +68 -0
- package/dist/chunks/chunk-S5IAH7CT.js +84 -0
- package/dist/chunks/config-OPZLVTYX.js +73 -0
- package/dist/chunks/gate-53O3YCXE.js +74 -0
- package/dist/chunks/indexer-OLIWEEFT.js +491 -0
- package/dist/chunks/init-JSZX6AF5.js +176 -0
- package/dist/chunks/line-2QBTLAUN.js +95 -0
- package/dist/chunks/liveNode-SLQN4XRB.js +299 -0
- package/dist/chunks/liveOnboard-Z4GRTSHR.js +400 -0
- package/dist/chunks/liveSettle-V5W7D2U5.js +1398 -0
- package/dist/chunks/notary-PQDSEOVV.js +122 -0
- package/dist/chunks/onboardError-RLJPEEFU.js +10 -0
- package/dist/chunks/src-RIOYQO2J.js +556 -0
- package/dist/chunks/tab-QPO2545T.js +59 -0
- package/dist/chunks/verify-Z7BGKZOB.js +719 -0
- package/package.json +66 -3
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ccd,
|
|
3
|
+
tabOf
|
|
4
|
+
} from "./chunk-QTI2WM44.js";
|
|
5
|
+
import {
|
|
6
|
+
ReportBuilder
|
|
7
|
+
} from "./chunk-GOEFQ62Z.js";
|
|
8
|
+
import {
|
|
9
|
+
CliError
|
|
10
|
+
} from "./chunk-MOZ4BFSB.js";
|
|
11
|
+
import {
|
|
12
|
+
TESTNET_GENESIS_HEX,
|
|
13
|
+
accountAddressToBase58,
|
|
14
|
+
cycleEnd,
|
|
15
|
+
fromHex
|
|
16
|
+
} from "./chunk-D3C7KAMJ.js";
|
|
17
|
+
|
|
18
|
+
// packages/cli/src/commands/tab.ts
|
|
19
|
+
async function tabStatus(env, tabId) {
|
|
20
|
+
const chain = await env.verifyChain();
|
|
21
|
+
const ctx = { chain, bureau: env.config.bureau, anchorAccount: env.config.anchorAccount, drpAnchorAccounts: env.config.drpAnchorAccounts, genesis: fromHex(TESTNET_GENESIS_HEX, 32) };
|
|
22
|
+
const rb = new ReportBuilder(`tab ${tabId}`);
|
|
23
|
+
const tab = await tabOf(ctx, tabId);
|
|
24
|
+
if (!rb.check("tab exists", tab !== null) || tab === null) return rb.build();
|
|
25
|
+
const now = BigInt(env.io.now());
|
|
26
|
+
const cycle = now < tab.openedAt ? 0 : Number((now - tab.openedAt) / tab.cycleMs);
|
|
27
|
+
rb.fact("status", tab.status);
|
|
28
|
+
rb.fact("line", tab.lineId);
|
|
29
|
+
rb.fact("seller token", tab.sellerToken);
|
|
30
|
+
rb.fact("seller wallet (snapshot)", accountAddressToBase58(tab.sellerWallet));
|
|
31
|
+
rb.fact("limit", ccd(tab.limit));
|
|
32
|
+
rb.fact("settled total", ccd(tab.settledTotal));
|
|
33
|
+
rb.fact("cycle now", `${cycle} (ends ${new Date(Number(cycleEnd(tab.openedAt, cycle, tab.cycleMs))).toISOString()})`);
|
|
34
|
+
rb.fact("last settled cycle", tab.lastSettledCycle);
|
|
35
|
+
rb.fact("last settlement", tab.lastSettledAt === null ? null : `${new Date(Number(tab.lastSettledAt)).toISOString()}${tab.lastOnTime ? ", on time" : ", late"}${tab.lastAcked ? ", acked" : ""}`);
|
|
36
|
+
rb.fact("lanes used", `${tab.lanes.filter((l) => l.seq > 0n).length} of ${tab.maxLanes}`);
|
|
37
|
+
if (tab.reportedTotal > 0n) rb.fact("reported in default", ccd(tab.reportedTotal));
|
|
38
|
+
return rb.build();
|
|
39
|
+
}
|
|
40
|
+
async function tabSettle(env, req) {
|
|
41
|
+
if (env.config.facilitatorUrl === null) throw new CliError("usage", "set FACILITATOR_URL (the facilitator sponsors settleTab)");
|
|
42
|
+
const rb = new ReportBuilder(`settle tab ${req.tabId}`);
|
|
43
|
+
const s = await env.settler().settle(req);
|
|
44
|
+
if (s === null) {
|
|
45
|
+
rb.check("nothing due", true, "no receipted amount beyond the settled total");
|
|
46
|
+
return rb.build();
|
|
47
|
+
}
|
|
48
|
+
rb.check("settled", true, s.txHash);
|
|
49
|
+
rb.fact("cycle", s.cycle);
|
|
50
|
+
rb.fact("total", ccd(s.total));
|
|
51
|
+
rb.fact("paid to the seller wallet", ccd(s.amount));
|
|
52
|
+
rb.fact("seller acked", s.acked);
|
|
53
|
+
rb.fact("verify", `opentab verify settlement ${s.txHash}`);
|
|
54
|
+
return rb.build();
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
tabSettle,
|
|
58
|
+
tabStatus
|
|
59
|
+
};
|