wasmlock 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.
@@ -0,0 +1,120 @@
1
+ import { EXIT, type Status } from "./exit.ts";
2
+ import type { Lockfile } from "./lockfile.ts";
3
+ import { type Network } from "./network.ts";
4
+ import { type PendingState } from "./pending.ts";
5
+ import { type Rule } from "./rules.ts";
6
+ import { type RawLedgerEntry, type RpcTransport } from "./rpc.ts";
7
+ export type { Status } from "./exit.ts";
8
+ /** How an instance reaches its code, without the hash. */
9
+ export type ReachState = {
10
+ readonly kind: "wasm";
11
+ } | {
12
+ readonly kind: "stellar-asset";
13
+ } | {
14
+ readonly kind: "external";
15
+ readonly owner: string;
16
+ readonly tag: string;
17
+ };
18
+ export interface Change {
19
+ readonly field: "reach.kind" | "reach.owner" | "reach.tag" | "wasmHash";
20
+ readonly old: string;
21
+ readonly new: string;
22
+ }
23
+ /** Where an entry was last written and until when it lives. */
24
+ export interface LedgerStamp {
25
+ readonly lastModifiedLedgerSeq: number;
26
+ readonly liveUntilLedgerSeq: number | null;
27
+ }
28
+ export interface ContractResult {
29
+ readonly id: string;
30
+ readonly label: string | null;
31
+ readonly status: Status;
32
+ readonly pinned: {
33
+ readonly reach: ReachState;
34
+ readonly wasmHash: string;
35
+ };
36
+ /** What the ledger says now. Null when the instance could not be read or understood. */
37
+ readonly live: {
38
+ readonly reach: ReachState;
39
+ readonly wasmHash: string | null;
40
+ } | null;
41
+ /** Old and new values, for drift. */
42
+ readonly changes: readonly Change[];
43
+ /** Why the contract is incomplete. Empty otherwise. */
44
+ readonly reasons: readonly string[];
45
+ /**
46
+ * What the contract's pending-upgrade rules found. Present only for a contract whose lockfile
47
+ * entry names rules (and whose live code hash is known).
48
+ */
49
+ readonly pending?: PendingState;
50
+ /** The entries that were read, null for one that was not read or not found. */
51
+ readonly entries: {
52
+ readonly instance: LedgerStamp | null;
53
+ readonly code: LedgerStamp | null;
54
+ readonly ownerEntry: LedgerStamp | null;
55
+ };
56
+ }
57
+ export interface CheckReport {
58
+ readonly version: 1;
59
+ readonly network: Network;
60
+ /** The latest ledger any answer was taken at. Null when nothing was answered. */
61
+ readonly ledger: number | null;
62
+ readonly summary: {
63
+ readonly total: number;
64
+ readonly clean: number;
65
+ readonly drift: number;
66
+ readonly pending: number;
67
+ readonly incomplete: number;
68
+ };
69
+ readonly exitCode: 0 | 1 | 2 | 3;
70
+ readonly contracts: readonly ContractResult[];
71
+ }
72
+ /** The endpoint serves another network than the lockfile names. A usage error, not a finding. */
73
+ export declare class NetworkMismatchError extends Error {
74
+ constructor(expected: Network, passphrase: string);
75
+ }
76
+ type Lookup = {
77
+ readonly ok: true;
78
+ readonly entry: RawLedgerEntry;
79
+ readonly stamp: LedgerStamp;
80
+ } | {
81
+ readonly ok: false;
82
+ readonly reason: string;
83
+ };
84
+ /**
85
+ * A cache of ledger reads. `get` of a key that was never read records it as wanted, so the
86
+ * caller can run its logic, fetch everything wanted in as few calls as possible, and run it again.
87
+ */
88
+ export declare class EntryReader {
89
+ private readonly transport;
90
+ private readonly slots;
91
+ private readonly wanted;
92
+ constructor(transport: RpcTransport);
93
+ want(key: string): void;
94
+ get(key: string, what: string): Lookup;
95
+ /** Reads everything wanted. Returns false when nothing was wanted. */
96
+ flush(): Promise<boolean>;
97
+ get latestLedger(): number | null;
98
+ }
99
+ /** What a read of the ledger gave: each contract's result, and the reader that still holds the entries. */
100
+ export interface Evaluation {
101
+ readonly results: readonly ContractResult[];
102
+ /** The latest ledger any answer was taken at. Null when nothing was answered. */
103
+ readonly ledger: number | null;
104
+ readonly reader: EntryReader;
105
+ }
106
+ /**
107
+ * Reads the ledger for every contract of a lockfile and compares each with its pin. Throws
108
+ * `ConfigError`, before any request, for a pending rule name that is neither a preset nor in
109
+ * `userRules`, and `NetworkMismatchError` when the endpoint serves another network; every other
110
+ * failure to read is reported per contract as incomplete.
111
+ */
112
+ export declare function evaluateLockfile(lockfile: Lockfile, transport: RpcTransport, userRules?: readonly Rule[]): Promise<Evaluation>;
113
+ /**
114
+ * Checks every pin against the ledger. Read-only: the transport has no write method. Throws
115
+ * `NetworkMismatchError` when the endpoint serves another network; every other failure to read is
116
+ * reported per contract as incomplete.
117
+ */
118
+ export declare function checkLockfile(lockfile: Lockfile, transport: RpcTransport, userRules?: readonly Rule[]): Promise<CheckReport>;
119
+ export { formatDuration, formatReport } from "./check-format.ts";
120
+ export { EXIT };
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};