wasmlock 0.1.0 → 0.2.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/dist/check.d.ts CHANGED
@@ -25,10 +25,22 @@ export interface LedgerStamp {
25
25
  readonly lastModifiedLedgerSeq: number;
26
26
  readonly liveUntilLedgerSeq: number | null;
27
27
  }
28
+ /**
29
+ * The RPC returns an entry that was evicted to the archive with its data and a live-until ledger of
30
+ * 0. Zero means "archived", never a ledger number: no entry expires at ledger 0.
31
+ */
32
+ export declare const ARCHIVED_LIVE_UNTIL = 0;
33
+ export declare const isArchived: (stamp: LedgerStamp | null) => boolean;
28
34
  export interface ContractResult {
29
35
  readonly id: string;
30
36
  readonly label: string | null;
31
37
  readonly status: Status;
38
+ /**
39
+ * True when an entry this result rests on (the instance, the code, an owner's tag) was archived
40
+ * when it was read. It does not change the status: an archived contract cannot run or be
41
+ * upgraded until its entries are restored, so its code hash cannot change silently.
42
+ */
43
+ readonly archived: boolean;
32
44
  readonly pinned: {
33
45
  readonly reach: ReachState;
34
46
  readonly wasmHash: string;
package/dist/cli.js CHANGED
@@ -36877,6 +36877,7 @@ async function readLedgerEntries(transport, keys) {
36877
36877
  }
36878
36878
 
36879
36879
  // src/check-format.ts
36880
+ var ARCHIVED_NOTE = "an entry was archived when read; archived code cannot run or change until its entries are restored";
36880
36881
  var STATUS_ORDER = ["drift", "pending", "incomplete", "clean"];
36881
36882
  function describeReach(reach) {
36882
36883
  return reach.kind === "external" ? `external ${forTerminal(reach.owner)} tag ${forTerminal(reach.tag)}` : reach.kind;
@@ -36941,6 +36942,8 @@ function formatReport(report) {
36941
36942
  lines.push(` ${change.field}: ${forTerminal(change.old)} -> ${forTerminal(change.new)}`);
36942
36943
  for (const reason of contract.reasons)
36943
36944
  lines.push(` ${textForTerminal(reason)}`);
36945
+ if (contract.archived)
36946
+ lines.push(` archived: ${ARCHIVED_NOTE}`);
36944
36947
  for (const line of pendingLines(contract))
36945
36948
  lines.push(line);
36946
36949
  if (status === "drift" && contract.live !== null && contract.live.wasmHash === null) {
@@ -36957,6 +36960,9 @@ function formatReport(report) {
36957
36960
  }
36958
36961
 
36959
36962
  // src/check.ts
36963
+ var ARCHIVED_LIVE_UNTIL = 0;
36964
+ var isArchived = (stamp) => stamp !== null && stamp.liveUntilLedgerSeq === ARCHIVED_LIVE_UNTIL;
36965
+
36960
36966
  class NetworkMismatchError extends Error {
36961
36967
  constructor(expected, passphrase) {
36962
36968
  super(`the RPC endpoint serves "${passphrase}" but the lockfile is for ${expected}`);
@@ -36990,7 +36996,7 @@ class EntryReader {
36990
36996
  if (entry.liveUntilLedgerSeq === undefined) {
36991
36997
  return { ok: false, reason: `${what} has no TTL, which a contract entry always has` };
36992
36998
  }
36993
- if (entry.liveUntilLedgerSeq < readAt) {
36999
+ if (entry.liveUntilLedgerSeq !== ARCHIVED_LIVE_UNTIL && entry.liveUntilLedgerSeq < readAt) {
36994
37000
  return {
36995
37001
  ok: false,
36996
37002
  reason: `${what} expired at ledger ${String(entry.liveUntilLedgerSeq)} (read at ledger ${String(readAt)}) and is archived`
@@ -37039,7 +37045,9 @@ function pinnedReach(contract) {
37039
37045
  function liveReach(executable) {
37040
37046
  return executable.kind === "external" ? { kind: "external", owner: executable.owner, tag: executable.tag } : { kind: executable.kind };
37041
37047
  }
37048
+ var anyArchived = (entries) => isArchived(entries.instance) || isArchived(entries.code) || isArchived(entries.ownerEntry);
37042
37049
  function incomplete(contract, reasons, partial = {}) {
37050
+ const entries = partial.entries ?? { instance: null, code: null, ownerEntry: null };
37043
37051
  return {
37044
37052
  id: contract.id,
37045
37053
  label: contract.label ?? null,
@@ -37048,8 +37056,9 @@ function incomplete(contract, reasons, partial = {}) {
37048
37056
  live: null,
37049
37057
  changes: [],
37050
37058
  reasons,
37051
- entries: { instance: null, code: null, ownerEntry: null },
37052
- ...partial
37059
+ ...partial,
37060
+ archived: anyArchived(entries),
37061
+ entries
37053
37062
  };
37054
37063
  }
37055
37064
  function decodeOrReason(decode) {
@@ -37148,6 +37157,7 @@ function evaluate(contract, reader, context) {
37148
37157
  id: contract.id,
37149
37158
  label: contract.label ?? null,
37150
37159
  status,
37160
+ archived: anyArchived({ instance: instanceStamp, code, ownerEntry }),
37151
37161
  pinned: { reach: pinned, wasmHash: contract.wasmHash },
37152
37162
  live: { reach: live, wasmHash: liveHash },
37153
37163
  changes,
@@ -38043,7 +38053,7 @@ function readContract(c, path, value) {
38043
38053
  const obj = c.record(path, value);
38044
38054
  if (!obj)
38045
38055
  return;
38046
- c.keys(path, obj, ["id", "reach", "wasmHash", "codeLedgerHint", "instanceLedgerHint", "pinnedAt", "interface"], ["label", "meta", "imports", "uses", "pending"]);
38056
+ c.keys(path, obj, ["id", "reach", "wasmHash", "codeLedgerHint", "instanceLedgerHint", "pinnedAt", "interface"], ["label", "meta", "imports", "uses", "pending", "archivedWhenPinned"]);
38047
38057
  const id = c.contractId(`${path}.id`, obj["id"]);
38048
38058
  const label = Object.hasOwn(obj, "label") ? c.nonEmptyString(`${path}.label`, obj["label"]) : undefined;
38049
38059
  const reach = readReach(c, `${path}.reach`, obj["reach"]);
@@ -38056,6 +38066,13 @@ function readContract(c, path, value) {
38056
38066
  const imports = Object.hasOwn(obj, "imports") ? readImports2(c, `${path}.imports`, obj["imports"]) : undefined;
38057
38067
  const uses = Object.hasOwn(obj, "uses") ? readNames(c, `${path}.uses`, obj["uses"], FUNCTION_NAME, "function name") : undefined;
38058
38068
  const pending = Object.hasOwn(obj, "pending") ? readNames(c, `${path}.pending`, obj["pending"], /^[a-z][a-z0-9-]{0,63}$/, "rule name") : undefined;
38069
+ let archivedWhenPinned;
38070
+ if (Object.hasOwn(obj, "archivedWhenPinned")) {
38071
+ if (obj["archivedWhenPinned"] === true)
38072
+ archivedWhenPinned = true;
38073
+ else
38074
+ c.add(`${path}.archivedWhenPinned`, "must be true when present; leave it out for a contract that was live");
38075
+ }
38059
38076
  if (reach?.kind === "external" && wasmHash !== undefined && reach.ownerEntry.hash !== wasmHash) {
38060
38077
  c.add(`${path}.wasmHash`, "must equal reach.ownerEntry.hash: the tag entry holds the pinned hash");
38061
38078
  }
@@ -38074,7 +38091,8 @@ function readContract(c, path, value) {
38074
38091
  ...meta !== undefined && { meta },
38075
38092
  ...imports !== undefined && { imports },
38076
38093
  ...uses !== undefined && { uses },
38077
- ...pending !== undefined && { pending }
38094
+ ...pending !== undefined && { pending },
38095
+ ...archivedWhenPinned !== undefined && { archivedWhenPinned }
38078
38096
  };
38079
38097
  }
38080
38098
  function validateLockfile(value) {
@@ -38806,6 +38824,7 @@ function readLiveCode(result, ledger, reader) {
38806
38824
  codeLedgerHint: code.stamp.lastModifiedLedgerSeq,
38807
38825
  instanceLedgerHint: entries.instance.lastModifiedLedgerSeq,
38808
38826
  pinnedAt: ledger,
38827
+ archived: result.archived || isArchived(code.stamp),
38809
38828
  wasm
38810
38829
  }
38811
38830
  };
@@ -38822,6 +38841,7 @@ function entryFromLive(kept, live, snapshot) {
38822
38841
  interface: snapshot ? { digest: live.wasm.digest, snapshot: live.wasm.snapshot } : { digest: live.wasm.digest },
38823
38842
  meta: live.wasm.meta,
38824
38843
  imports: live.wasm.imports,
38844
+ ...live.archived && { archivedWhenPinned: true },
38825
38845
  ...kept.uses !== undefined && { uses: kept.uses },
38826
38846
  ...kept.pending !== undefined && { pending: kept.pending }
38827
38847
  };
@@ -39770,7 +39790,7 @@ async function planUpdate(lockfile, ids, transport, dryRun, userRules = []) {
39770
39790
  // package.json
39771
39791
  var package_default = {
39772
39792
  name: "wasmlock",
39773
- version: "0.1.0",
39793
+ version: "0.2.0",
39774
39794
  description: "Dependency updater for on-chain Soroban contracts: pins third-party contract code, detects upgrades, documents and proposes a re-pin.",
39775
39795
  license: "MIT",
39776
39796
  type: "module",
package/dist/entry.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ContractResult, EntryReader } from "./check.ts";
1
+ import { type ContractResult, type EntryReader } from "./check.ts";
2
2
  import type { ContractEntry, Reach } from "./lockfile.ts";
3
3
  import { type WasmInterface } from "./spec.ts";
4
4
  /** Everything a pin records about the code a contract runs, every value read from the ledger. */
@@ -8,6 +8,8 @@ export interface LiveCode {
8
8
  readonly codeLedgerHint: number;
9
9
  readonly instanceLedgerHint: number;
10
10
  readonly pinnedAt: number;
11
+ /** An entry the pin rests on was archived when it was read. */
12
+ readonly archived: boolean;
11
13
  readonly wasm: WasmInterface;
12
14
  }
13
15
  export type LiveRead = {
package/dist/index.js CHANGED
@@ -900,7 +900,7 @@ function readContract(c, path, value) {
900
900
  const obj = c.record(path, value);
901
901
  if (!obj)
902
902
  return;
903
- c.keys(path, obj, ["id", "reach", "wasmHash", "codeLedgerHint", "instanceLedgerHint", "pinnedAt", "interface"], ["label", "meta", "imports", "uses", "pending"]);
903
+ c.keys(path, obj, ["id", "reach", "wasmHash", "codeLedgerHint", "instanceLedgerHint", "pinnedAt", "interface"], ["label", "meta", "imports", "uses", "pending", "archivedWhenPinned"]);
904
904
  const id = c.contractId(`${path}.id`, obj["id"]);
905
905
  const label = Object.hasOwn(obj, "label") ? c.nonEmptyString(`${path}.label`, obj["label"]) : undefined;
906
906
  const reach = readReach(c, `${path}.reach`, obj["reach"]);
@@ -913,6 +913,13 @@ function readContract(c, path, value) {
913
913
  const imports = Object.hasOwn(obj, "imports") ? readImports(c, `${path}.imports`, obj["imports"]) : undefined;
914
914
  const uses = Object.hasOwn(obj, "uses") ? readNames(c, `${path}.uses`, obj["uses"], FUNCTION_NAME, "function name") : undefined;
915
915
  const pending = Object.hasOwn(obj, "pending") ? readNames(c, `${path}.pending`, obj["pending"], /^[a-z][a-z0-9-]{0,63}$/, "rule name") : undefined;
916
+ let archivedWhenPinned;
917
+ if (Object.hasOwn(obj, "archivedWhenPinned")) {
918
+ if (obj["archivedWhenPinned"] === true)
919
+ archivedWhenPinned = true;
920
+ else
921
+ c.add(`${path}.archivedWhenPinned`, "must be true when present; leave it out for a contract that was live");
922
+ }
916
923
  if (reach?.kind === "external" && wasmHash !== undefined && reach.ownerEntry.hash !== wasmHash) {
917
924
  c.add(`${path}.wasmHash`, "must equal reach.ownerEntry.hash: the tag entry holds the pinned hash");
918
925
  }
@@ -931,7 +938,8 @@ function readContract(c, path, value) {
931
938
  ...meta !== undefined && { meta },
932
939
  ...imports !== undefined && { imports },
933
940
  ...uses !== undefined && { uses },
934
- ...pending !== undefined && { pending }
941
+ ...pending !== undefined && { pending },
942
+ ...archivedWhenPinned !== undefined && { archivedWhenPinned }
935
943
  };
936
944
  }
937
945
  function validateLockfile(value) {
@@ -37634,6 +37642,7 @@ async function readLedgerEntries(transport, keys) {
37634
37642
  }
37635
37643
 
37636
37644
  // src/check-format.ts
37645
+ var ARCHIVED_NOTE = "an entry was archived when read; archived code cannot run or change until its entries are restored";
37637
37646
  var STATUS_ORDER = ["drift", "pending", "incomplete", "clean"];
37638
37647
  function describeReach(reach) {
37639
37648
  return reach.kind === "external" ? `external ${forTerminal(reach.owner)} tag ${forTerminal(reach.tag)}` : reach.kind;
@@ -37698,6 +37707,8 @@ function formatReport(report) {
37698
37707
  lines.push(` ${change.field}: ${forTerminal(change.old)} -> ${forTerminal(change.new)}`);
37699
37708
  for (const reason of contract.reasons)
37700
37709
  lines.push(` ${textForTerminal(reason)}`);
37710
+ if (contract.archived)
37711
+ lines.push(` archived: ${ARCHIVED_NOTE}`);
37701
37712
  for (const line of pendingLines(contract))
37702
37713
  lines.push(line);
37703
37714
  if (status === "drift" && contract.live !== null && contract.live.wasmHash === null) {
@@ -37714,6 +37725,9 @@ function formatReport(report) {
37714
37725
  }
37715
37726
 
37716
37727
  // src/check.ts
37728
+ var ARCHIVED_LIVE_UNTIL = 0;
37729
+ var isArchived = (stamp) => stamp !== null && stamp.liveUntilLedgerSeq === ARCHIVED_LIVE_UNTIL;
37730
+
37717
37731
  class NetworkMismatchError extends Error {
37718
37732
  constructor(expected, passphrase) {
37719
37733
  super(`the RPC endpoint serves "${passphrase}" but the lockfile is for ${expected}`);
@@ -37747,7 +37761,7 @@ class EntryReader {
37747
37761
  if (entry.liveUntilLedgerSeq === undefined) {
37748
37762
  return { ok: false, reason: `${what} has no TTL, which a contract entry always has` };
37749
37763
  }
37750
- if (entry.liveUntilLedgerSeq < readAt) {
37764
+ if (entry.liveUntilLedgerSeq !== ARCHIVED_LIVE_UNTIL && entry.liveUntilLedgerSeq < readAt) {
37751
37765
  return {
37752
37766
  ok: false,
37753
37767
  reason: `${what} expired at ledger ${String(entry.liveUntilLedgerSeq)} (read at ledger ${String(readAt)}) and is archived`
@@ -37796,7 +37810,9 @@ function pinnedReach(contract) {
37796
37810
  function liveReach(executable) {
37797
37811
  return executable.kind === "external" ? { kind: "external", owner: executable.owner, tag: executable.tag } : { kind: executable.kind };
37798
37812
  }
37813
+ var anyArchived = (entries) => isArchived(entries.instance) || isArchived(entries.code) || isArchived(entries.ownerEntry);
37799
37814
  function incomplete(contract, reasons, partial = {}) {
37815
+ const entries = partial.entries ?? { instance: null, code: null, ownerEntry: null };
37800
37816
  return {
37801
37817
  id: contract.id,
37802
37818
  label: contract.label ?? null,
@@ -37805,8 +37821,9 @@ function incomplete(contract, reasons, partial = {}) {
37805
37821
  live: null,
37806
37822
  changes: [],
37807
37823
  reasons,
37808
- entries: { instance: null, code: null, ownerEntry: null },
37809
- ...partial
37824
+ ...partial,
37825
+ archived: anyArchived(entries),
37826
+ entries
37810
37827
  };
37811
37828
  }
37812
37829
  function decodeOrReason(decode) {
@@ -37905,6 +37922,7 @@ function evaluate(contract, reader, context) {
37905
37922
  id: contract.id,
37906
37923
  label: contract.label ?? null,
37907
37924
  status,
37925
+ archived: anyArchived({ instance: instanceStamp, code, ownerEntry }),
37908
37926
  pinned: { reach: pinned, wasmHash: contract.wasmHash },
37909
37927
  live: { reach: live, wasmHash: liveHash },
37910
37928
  changes,
@@ -39056,6 +39074,7 @@ function readLiveCode(result, ledger, reader) {
39056
39074
  codeLedgerHint: code.stamp.lastModifiedLedgerSeq,
39057
39075
  instanceLedgerHint: entries.instance.lastModifiedLedgerSeq,
39058
39076
  pinnedAt: ledger,
39077
+ archived: result.archived || isArchived(code.stamp),
39059
39078
  wasm
39060
39079
  }
39061
39080
  };
@@ -39072,6 +39091,7 @@ function entryFromLive(kept, live, snapshot) {
39072
39091
  interface: snapshot ? { digest: live.wasm.digest, snapshot: live.wasm.snapshot } : { digest: live.wasm.digest },
39073
39092
  meta: live.wasm.meta,
39074
39093
  imports: live.wasm.imports,
39094
+ ...live.archived && { archivedWhenPinned: true },
39075
39095
  ...kept.uses !== undefined && { uses: kept.uses },
39076
39096
  ...kept.pending !== undefined && { pending: kept.pending }
39077
39097
  };
@@ -69,6 +69,11 @@ export interface ContractEntry {
69
69
  readonly meta?: readonly MetaEntry[];
70
70
  /** The module's host imports when pinned, sorted by module then name. */
71
71
  readonly imports?: readonly ImportEntry[];
72
+ /**
73
+ * Present, and `true`, when an entry the pin rests on was archived when it was pinned. Absent
74
+ * means it was live; `false` is never written. Informational: `check` compares hashes only.
75
+ */
76
+ readonly archivedWhenPinned?: true;
72
77
  /** The functions the integrator calls. Absent means undeclared, not "none". */
73
78
  readonly uses?: readonly string[];
74
79
  /** Names of pending-upgrade rules to apply to this contract. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wasmlock",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Dependency updater for on-chain Soroban contracts: pins third-party contract code, detects upgrades, documents and proposes a re-pin.",
5
5
  "license": "MIT",
6
6
  "type": "module",