@lucid-evolution/tx-graph 0.0.1
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 +21 -0
- package/README.md +108 -0
- package/dist/index.cjs +4292 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +477 -0
- package/dist/index.d.ts +477 -0
- package/dist/index.js +4229 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Anastasia Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# @lucid-evolution/tx-graph
|
|
2
|
+
|
|
3
|
+
Transaction graph tracing and rendering utilities for Lucid Evolution.
|
|
4
|
+
|
|
5
|
+
The package records offchain transaction-building scenarios as an auditable UTxO graph. It can render the same trace as JSON, DOT, Mermaid, SVG, or a self-contained HTML explorer.
|
|
6
|
+
|
|
7
|
+
## What It Shows
|
|
8
|
+
|
|
9
|
+
- Which UTxOs were spent, referenced, used as collateral, or produced.
|
|
10
|
+
- Which reference-script and datum-bearing UTxOs participated in a transaction.
|
|
11
|
+
- Where minted and burned assets attach to the transaction flow.
|
|
12
|
+
- Which signer, withdrawal, and certificate relationships were required.
|
|
13
|
+
- Which redeemer maps to each spend, mint, withdrawal, or certificate edge.
|
|
14
|
+
- Which warnings affect the trustworthiness of the graph.
|
|
15
|
+
|
|
16
|
+
The graph is intentionally ledger-first. It does not guess project-specific actions such as `Swap`, `Lock`, or `UnitVal` from opaque redeemer CBOR. Add those labels with explicit redeemer describers.
|
|
17
|
+
|
|
18
|
+
## Basic Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { createTxGraph, labelRedeemer } from "@lucid-evolution/tx-graph";
|
|
22
|
+
|
|
23
|
+
const graph = createTxGraph({
|
|
24
|
+
assets: { lovelace: "ADA" },
|
|
25
|
+
addresses: { [walletAddress]: "wallet" },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await graph.record(tx, { label: "swap and settle", status: "submitted" });
|
|
29
|
+
|
|
30
|
+
const svg = graph.toSvg({
|
|
31
|
+
redeemers: [labelRedeemer({ tag: "spend", index: 0 }, "Swap")],
|
|
32
|
+
});
|
|
33
|
+
const html = graph.toHtml({
|
|
34
|
+
view: "scriptInteraction",
|
|
35
|
+
mode: "audit",
|
|
36
|
+
redeemers: [labelRedeemer({ tag: "spend", index: 0 }, "Swap")],
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Renderers
|
|
41
|
+
|
|
42
|
+
- `graph.toJSON()` returns the canonical trace.
|
|
43
|
+
- `graph.toSemantic()` returns the renderer-neutral visual graph contract.
|
|
44
|
+
- `graph.toDot()` returns GraphViz DOT with structured HTML-like labels.
|
|
45
|
+
- `graph.toMermaid()` returns Mermaid flowchart text.
|
|
46
|
+
- `graph.toSvg()` returns a deterministic static SVG artifact.
|
|
47
|
+
- `graph.toHtml()` returns a self-contained explorer with SVG, search, edge filters, details, and copyable metadata.
|
|
48
|
+
|
|
49
|
+
`traceToDot`, `traceToMermaid`, `traceToSvg`, and `traceToHtml` are also exported for rendering saved traces.
|
|
50
|
+
|
|
51
|
+
## Actions And Redeemers
|
|
52
|
+
|
|
53
|
+
Use explicit describers to make redeemer intent visible:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import {
|
|
57
|
+
describeRedeemerByConstructor,
|
|
58
|
+
describeRedeemerWith,
|
|
59
|
+
labelRedeemer,
|
|
60
|
+
} from "@lucid-evolution/tx-graph";
|
|
61
|
+
|
|
62
|
+
const redeemers = [
|
|
63
|
+
labelRedeemer({ tag: "spend", index: 0 }, "Swap", "swap"),
|
|
64
|
+
describeRedeemerByConstructor(
|
|
65
|
+
{ tag: "mint", index: 0, constructor: 0 },
|
|
66
|
+
"MintReward",
|
|
67
|
+
),
|
|
68
|
+
describeRedeemerWith(({ redeemer, target }) =>
|
|
69
|
+
redeemer.tag === "publish" && target.type === "certificate"
|
|
70
|
+
? { label: "PublishStake", source: "schema", confidence: "high" }
|
|
71
|
+
: undefined,
|
|
72
|
+
),
|
|
73
|
+
];
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Every action records whether it came from `user`, `schema`, `constructor`, or `generic` fallback metadata.
|
|
77
|
+
|
|
78
|
+
## Modes, Views, And Privacy
|
|
79
|
+
|
|
80
|
+
Modes control detail level:
|
|
81
|
+
|
|
82
|
+
- `overview`: compact labels, action names, low raw-data exposure.
|
|
83
|
+
- `audit`: redeemer indices, ex units, constructor fields, more rows.
|
|
84
|
+
- `debug`: fuller raw values where privacy settings allow them.
|
|
85
|
+
|
|
86
|
+
Views control emphasis:
|
|
87
|
+
|
|
88
|
+
- `flow`: normal transaction flow.
|
|
89
|
+
- `scriptInteraction`: emphasizes script UTxOs, reference reads, collateral, redeemers, and script-touching asset movement.
|
|
90
|
+
|
|
91
|
+
Privacy can hide or shorten hashes, addresses, datums, redeemers, and CBOR. HTML metadata is privacy-safe by default. Set `includeRawMetadata: true` only for local/private artifacts where raw refs should be copyable from the details drawer.
|
|
92
|
+
|
|
93
|
+
## Example
|
|
94
|
+
|
|
95
|
+
Generate SVG and HTML artifacts from the deterministic example trace:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
TMPDIR=/tmp pnpm --dir packages/tx-graph exec tsx examples/render-scenario.ts ../../temp/tx-graph-example
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This writes:
|
|
102
|
+
|
|
103
|
+
- `temp/tx-graph-example/scenario.svg`
|
|
104
|
+
- `temp/tx-graph-example/scenario.html`
|
|
105
|
+
- `temp/tx-graph-example/scenario.dot`
|
|
106
|
+
- `temp/tx-graph-example/scenario.mmd`
|
|
107
|
+
|
|
108
|
+
The example intentionally uses a synthetic trace. In an emulator or provider flow, build the trace with `createTxGraph`, `graph.record(...)`, and optionally `graph.wrapProvider(...)`, then call the same render methods.
|