@givelotus/compiler 0.0.0-stage → 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/README.md +331 -2
- package/artifact-v2.schema.json +58 -0
- package/artifact.schema.json +19 -0
- package/dist/ast.d.ts +292 -0
- package/dist/ast.js +150 -0
- package/dist/bindings.d.ts +6 -0
- package/dist/bindings.js +134 -0
- package/dist/call-runtime.d.ts +84 -0
- package/dist/call-runtime.js +249 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +22 -0
- package/dist/compiler.d.ts +79 -0
- package/dist/compiler.js +125 -0
- package/dist/diagnostics.d.ts +163 -0
- package/dist/diagnostics.js +498 -0
- package/dist/ecash.d.ts +41 -0
- package/dist/ecash.js +190 -0
- package/dist/fees.d.ts +164 -0
- package/dist/fees.js +208 -0
- package/dist/fixture-cli.d.ts +2 -0
- package/dist/fixture-cli.js +41 -0
- package/dist/fixtures.d.ts +68 -0
- package/dist/fixtures.js +46 -0
- package/dist/forth-ir.d.ts +73 -0
- package/dist/forth-ir.js +147 -0
- package/dist/generic-cli.d.ts +2 -0
- package/dist/generic-cli.js +140 -0
- package/dist/generic.d.ts +48 -0
- package/dist/generic.js +2566 -0
- package/dist/lints.d.ts +8 -0
- package/dist/lints.js +204 -0
- package/dist/names.d.ts +1 -0
- package/dist/names.js +7 -0
- package/dist/opcodes.d.ts +154 -0
- package/dist/opcodes.js +162 -0
- package/dist/optimizer.d.ts +58 -0
- package/dist/optimizer.js +786 -0
- package/dist/package-fetch-cli.d.ts +2 -0
- package/dist/package-fetch-cli.js +17 -0
- package/dist/package-lock-cli.d.ts +2 -0
- package/dist/package-lock-cli.js +28 -0
- package/dist/package-sources.d.ts +82 -0
- package/dist/package-sources.js +785 -0
- package/dist/package-update-cli.d.ts +2 -0
- package/dist/package-update-cli.js +20 -0
- package/dist/packages.d.ts +231 -0
- package/dist/packages.js +1324 -0
- package/dist/parser.d.ts +32 -0
- package/dist/parser.js +575 -0
- package/dist/policy.d.ts +83 -0
- package/dist/policy.js +207 -0
- package/dist/runtime.d.ts +58 -0
- package/dist/runtime.js +126 -0
- package/dist/scheduler.d.ts +38 -0
- package/dist/scheduler.js +76 -0
- package/dist/semantic-ir.d.ts +76 -0
- package/dist/semantic-ir.js +231 -0
- package/dist/std.d.ts +27 -0
- package/dist/std.js +282 -0
- package/dist/target-compiler.d.ts +9 -0
- package/dist/target-compiler.js +139 -0
- package/dist/targets.d.ts +53 -0
- package/dist/targets.js +67 -0
- package/dist/token-cli.d.ts +2 -0
- package/dist/token-cli.js +82 -0
- package/dist/token-metadata.d.ts +43 -0
- package/dist/token-metadata.js +166 -0
- package/dist/toml-subset.d.ts +19 -0
- package/dist/toml-subset.js +81 -0
- package/dist/transaction-runtime.d.ts +182 -0
- package/dist/transaction-runtime.js +646 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +3 -0
- package/dist/vm-cost.d.ts +11 -0
- package/dist/vm-cost.js +541 -0
- package/package.json +74 -4
- package/policy-artifact.schema.json +20 -0
- package/std/custody/arbiter-escrow.lotus +20 -0
- package/std/custody/htlc.lotus +15 -0
- package/std/custody/multisig-2of3.lotus +13 -0
- package/std/custody/single-owner-wallet.lotus +9 -0
- package/std/custody/vault-with-recovery.lotus +14 -0
- package/std/defi/amm-pool-v2.lotus +97 -0
- package/std/defi/indexed-limit-order.lotus +37 -0
- package/std/nft/nft-collection.lotus +51 -0
- package/std/nft/royalty-transfer-rules.lotus +38 -0
- package/std/nft/unique-nft.lotus +30 -0
- package/std/tokens/capped-supply-token.lotus +76 -0
- package/std/tokens/fixed-supply-token.lotus +29 -0
- package/std/tokens/lrc20.lotus +26 -0
- package/std/tokens/standard-transfer-rules.lotus +15 -0
- package/std/tokens/stateful-token-merge.lotus +132 -0
- package/std/tokens/upgradable-token-rules.lotus +70 -0
- package/std/tokens/voucher-mint-token.lotus +31 -0
- package/std-pkg/lotus.toml +9 -0
- package/std-pkg/src/lrc20.lotus +38 -0
- package/std-pkg/src/stateful_token.lotus +131 -0
- package/std-pkg/src/upgradable.lotus +68 -0
|
@@ -0,0 +1,646 @@
|
|
|
1
|
+
/** Offline P01 multi-input planner. Execution and chain context are outside this module. */
|
|
2
|
+
import { bytes, concat, cs, hex, tagged, uint, unhex } from "./compiler.js";
|
|
3
|
+
import { MAX_MONEY, assertMoneyRange } from "./runtime.js";
|
|
4
|
+
import { assertContractArtifact, encodeCallValue, } from "./call-runtime.js";
|
|
5
|
+
import { feeRequirement, staticInvocationCu, } from "./fees.js";
|
|
6
|
+
const PROFILE = "P01-P02-P03-candidate-2026-10-14", U128 = (1n << 128n) - 1n;
|
|
7
|
+
const MODE_BYTE = { FULL: 0, OWN_INPUT_ALL_OUTPUTS: 1, OWN_INPUT_ONE_OUTPUT: 2 };
|
|
8
|
+
const stages = {
|
|
9
|
+
framing: "passed",
|
|
10
|
+
proof: "passed",
|
|
11
|
+
accounting: "passed",
|
|
12
|
+
signature: "unavailable",
|
|
13
|
+
invocation: "unavailable",
|
|
14
|
+
contextual: "unavailable",
|
|
15
|
+
block: "unavailable",
|
|
16
|
+
};
|
|
17
|
+
function u32(n) {
|
|
18
|
+
if (!Number.isInteger(n) || n < 0 || n > 0xffffffff)
|
|
19
|
+
throw Error("u32 range");
|
|
20
|
+
return uint(BigInt(n), 4);
|
|
21
|
+
}
|
|
22
|
+
function add(a, b) {
|
|
23
|
+
const x = a + b;
|
|
24
|
+
if (x > U128)
|
|
25
|
+
throw Error("u128 aggregate overflow");
|
|
26
|
+
return x;
|
|
27
|
+
}
|
|
28
|
+
function snapshot(x) {
|
|
29
|
+
return JSON.stringify(x, (_, v) => typeof v === "bigint" ? v.toString() : v instanceof Uint8Array ? hex(v) : v);
|
|
30
|
+
}
|
|
31
|
+
function comparePath(a, b) {
|
|
32
|
+
for (let i = 0; i < Math.min(a.length, b.length); i++)
|
|
33
|
+
if (a[i] !== b[i])
|
|
34
|
+
return a[i] - b[i];
|
|
35
|
+
return a.length - b.length;
|
|
36
|
+
}
|
|
37
|
+
export function encodeAssetOutput(o) {
|
|
38
|
+
if (![0, 1, 2, 3, 4, 5].includes(o.flags) ||
|
|
39
|
+
!Array.isArray(o.branches) ||
|
|
40
|
+
!Array.isArray(o.paths))
|
|
41
|
+
throw Error("output flags or policy");
|
|
42
|
+
const token = !!(o.flags & 1), burn = !!(o.flags & 2), hasState = !!(o.flags & 4);
|
|
43
|
+
if (token) {
|
|
44
|
+
if (!o.tokenId || o.tokenId === "00".repeat(32))
|
|
45
|
+
throw Error("token ID required");
|
|
46
|
+
unhex(o.tokenId, 32);
|
|
47
|
+
}
|
|
48
|
+
else if (o.tokenId !== undefined)
|
|
49
|
+
throw Error("native output has token ID");
|
|
50
|
+
if (hasState) {
|
|
51
|
+
if (!o.stateRoot || o.stateRoot === "00".repeat(32))
|
|
52
|
+
throw Error("state root required");
|
|
53
|
+
unhex(o.stateRoot, 32);
|
|
54
|
+
}
|
|
55
|
+
else if (o.stateRoot !== undefined)
|
|
56
|
+
throw Error("stateless output has state root");
|
|
57
|
+
if (o.branches.length < 1 ||
|
|
58
|
+
o.branches.length > 16 ||
|
|
59
|
+
new Set(o.branches).size !== o.branches.length)
|
|
60
|
+
throw Error("output branch count or duplicate");
|
|
61
|
+
o.branches.forEach((x) => unhex(x, 32));
|
|
62
|
+
if (burn ? o.paths.length !== 0 : o.paths.length < 1 || o.paths.length > 16)
|
|
63
|
+
throw Error("output path count");
|
|
64
|
+
let prev;
|
|
65
|
+
for (const p of o.paths) {
|
|
66
|
+
if (!Array.isArray(p) ||
|
|
67
|
+
p.length < 1 ||
|
|
68
|
+
p.length > 16 ||
|
|
69
|
+
p.some((v, i) => !Number.isInteger(v) ||
|
|
70
|
+
v < 0 ||
|
|
71
|
+
v >= o.branches.length ||
|
|
72
|
+
(i > 0 && v <= p[i - 1])))
|
|
73
|
+
throw Error("invalid output path");
|
|
74
|
+
if (prev && comparePath(prev, p) >= 0)
|
|
75
|
+
throw Error("output path order");
|
|
76
|
+
prev = p;
|
|
77
|
+
}
|
|
78
|
+
return concat(Uint8Array.of(o.flags), uint(o.value, 8), ...(token ? [unhex(o.tokenId, 32)] : []), ...(hasState ? [unhex(o.stateRoot, 32)] : []), cs(o.branches.length), ...o.branches.map((x) => unhex(x, 32)), cs(o.paths.length), ...o.paths.map((p) => concat(cs(p.length), ...p.map(cs))));
|
|
79
|
+
}
|
|
80
|
+
function indexedRoot(leaves) {
|
|
81
|
+
if (!leaves.length)
|
|
82
|
+
return tagged("merkleidx", Uint8Array.of(2));
|
|
83
|
+
let nodes = leaves, level = 0;
|
|
84
|
+
while (nodes.length > 1) {
|
|
85
|
+
if (nodes.length & 1)
|
|
86
|
+
nodes = [...nodes, new Uint8Array(32)];
|
|
87
|
+
const next = [];
|
|
88
|
+
for (let i = 0; i < nodes.length; i += 2)
|
|
89
|
+
next.push(tagged("merkleidx", concat(Uint8Array.of(1), uint(BigInt(level), 2), nodes[i], nodes[i + 1])));
|
|
90
|
+
nodes = next;
|
|
91
|
+
level++;
|
|
92
|
+
}
|
|
93
|
+
return nodes[0];
|
|
94
|
+
}
|
|
95
|
+
function witnesses(input) {
|
|
96
|
+
return input.kind === "mint"
|
|
97
|
+
? [
|
|
98
|
+
{
|
|
99
|
+
artifact: input.artifact,
|
|
100
|
+
methodName: input.methodName,
|
|
101
|
+
args: input.args,
|
|
102
|
+
},
|
|
103
|
+
]
|
|
104
|
+
: input.witnesses;
|
|
105
|
+
}
|
|
106
|
+
function selected(w, root, kind) {
|
|
107
|
+
assertContractArtifact(w.artifact);
|
|
108
|
+
const a = w.artifact;
|
|
109
|
+
const m = a.methods.find((x) => x.name === w.methodName);
|
|
110
|
+
if (!m)
|
|
111
|
+
throw Error("unknown method");
|
|
112
|
+
if (kind === "mint"
|
|
113
|
+
? a.kind !== "token" || m.invocation !== "mint"
|
|
114
|
+
: a.kind === "token" || m.invocation === "mint")
|
|
115
|
+
throw Error("wrong artifact or method invocation kind");
|
|
116
|
+
if (m.root !== root || a.policy.root !== root)
|
|
117
|
+
throw Error("witness branch root mismatch");
|
|
118
|
+
if (m.args.length > 32)
|
|
119
|
+
throw Error("candidate call argument cap");
|
|
120
|
+
if (Object.keys(w.args).sort().join(",") !==
|
|
121
|
+
m.args
|
|
122
|
+
.map((x) => x.name)
|
|
123
|
+
.sort()
|
|
124
|
+
.join(","))
|
|
125
|
+
throw Error("argument names mismatch");
|
|
126
|
+
for (const arg of m.args) {
|
|
127
|
+
const value = w.args[arg.name];
|
|
128
|
+
if (arg.type === "Signature") {
|
|
129
|
+
if (value !== null && !(typeof value === "string" && value in MODE_BYTE) && value !== "ABSTAIN")
|
|
130
|
+
throw Error(`signature slot ${arg.name} must be null, "FULL", "OWN_INPUT_ALL_OUTPUTS", "OWN_INPUT_ONE_OUTPUT" or "ABSTAIN"`);
|
|
131
|
+
if (kind === "mint" && (value === "OWN_INPUT_ALL_OUTPUTS" || value === "OWN_INPUT_ONE_OUTPUT"))
|
|
132
|
+
throw Error(`signature slot ${arg.name}: modes 01 and 02 are defined only for spend invocations`);
|
|
133
|
+
}
|
|
134
|
+
else if (typeof value === "string")
|
|
135
|
+
throw Error(`argument ${arg.name} is a ${arg.type}, not a signing mode`);
|
|
136
|
+
else
|
|
137
|
+
encodeCallValue(arg.type, value ?? null);
|
|
138
|
+
}
|
|
139
|
+
return m;
|
|
140
|
+
}
|
|
141
|
+
function signingMode(w, name) {
|
|
142
|
+
const value = w.args[name];
|
|
143
|
+
return typeof value === "string" ? value : "FULL";
|
|
144
|
+
}
|
|
145
|
+
function coreWitness(w) {
|
|
146
|
+
const m = w.artifact.methods.find((x) => x.name === w.methodName);
|
|
147
|
+
return concat(bytes(unhex(m.scriptHex)), cs(m.proof.length), ...m.proof.map((x) => unhex(x, 32)));
|
|
148
|
+
}
|
|
149
|
+
function valuesFor(input, index, sigs, projected = false) {
|
|
150
|
+
return witnesses(input).map((w, j) => {
|
|
151
|
+
const m = w.artifact.methods.find((x) => x.name === w.methodName);
|
|
152
|
+
return m.args.map((arg) => {
|
|
153
|
+
if (arg.type !== "Signature")
|
|
154
|
+
return encodeCallValue(arg.type, (w.args[arg.name] ?? null));
|
|
155
|
+
const mode = signingMode(w, arg.name);
|
|
156
|
+
if (mode === "ABSTAIN")
|
|
157
|
+
return new Uint8Array(64);
|
|
158
|
+
const suffix = mode === "FULL" ? new Uint8Array() : Uint8Array.of(MODE_BYTE[mode]);
|
|
159
|
+
if (projected)
|
|
160
|
+
return new Uint8Array(64 + suffix.length);
|
|
161
|
+
if (!sigs)
|
|
162
|
+
return new Uint8Array();
|
|
163
|
+
const signature = sigs[`${index}:${j}:${arg.name}`];
|
|
164
|
+
if (!(signature instanceof Uint8Array) || signature.length !== 64)
|
|
165
|
+
throw Error(`signature ${index}:${j}:${arg.name} must be the 64-byte BIP340 signature`);
|
|
166
|
+
return concat(signature, suffix);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function inputBytes(input, values, full) {
|
|
171
|
+
const ws = witnesses(input);
|
|
172
|
+
const encode = (w, j) => full
|
|
173
|
+
? concat(coreWitness(w), cs(values[j].length), ...values[j].map(bytes))
|
|
174
|
+
: coreWitness(w);
|
|
175
|
+
if (input.kind === "mint")
|
|
176
|
+
return concat(unhex(input.artifact.policy.root, 32), u32(0), u32(0xffffffff), Uint8Array.of(3), encode(ws[0], 0));
|
|
177
|
+
return concat(unhex(input.prevTxid, 32), u32(input.prevIndex), u32(input.sequence), Uint8Array.of(1), cs(input.pathIndex), cs(ws.length), ...ws.map(encode));
|
|
178
|
+
}
|
|
179
|
+
function hashParts(intent, values) {
|
|
180
|
+
const header = concat(u32(7), uint(intent.lock ?? 0n, 8), uint(BigInt(intent.inputs.length), 2), uint(BigInt(intent.outputs.length), 2));
|
|
181
|
+
const core = intent.inputs.map((x, i) => inputBytes(x, values[i], false));
|
|
182
|
+
const full = intent.inputs.map((x, i) => inputBytes(x, values[i], true));
|
|
183
|
+
const outputs = intent.outputs.map(encodeAssetOutput), outRoot = indexedRoot(outputs.map((x) => tagged("output", bytes(x))));
|
|
184
|
+
const chain = unhex(intent.chainId, 32);
|
|
185
|
+
const id = tagged("txid", concat(chain, header, indexedRoot(core.map((x) => tagged("inputcore", x))), outRoot));
|
|
186
|
+
const txhash = tagged("txhash", concat(chain, header, indexedRoot(full.map((x) => tagged("inputfull", x))), outRoot));
|
|
187
|
+
const coinsRoot = indexedRoot(intent.inputs.map((x) => tagged("coinentry", x.kind === "mint" ? Uint8Array.of(0) : bytes(encodeAssetOutput(x.coin)))));
|
|
188
|
+
return {
|
|
189
|
+
wire: concat(header, ...full, ...outputs),
|
|
190
|
+
core,
|
|
191
|
+
full,
|
|
192
|
+
outputs,
|
|
193
|
+
outputsRoot: outRoot,
|
|
194
|
+
txid: hex(id),
|
|
195
|
+
txhash: hex(txhash),
|
|
196
|
+
coinsRoot,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function costShape(intent, parts, values) {
|
|
200
|
+
const inputCount = intent.inputs.length, outputCount = intent.outputs.length;
|
|
201
|
+
// Serialized sizes the field reads push, from the transaction itself (P05).
|
|
202
|
+
const pathSizes = (outputs) => {
|
|
203
|
+
const widths = [];
|
|
204
|
+
for (const o of outputs)
|
|
205
|
+
o.paths.forEach((path, slot) => { widths[slot] = Math.max(widths[slot] ?? 0, 1 + path.length); });
|
|
206
|
+
return widths;
|
|
207
|
+
};
|
|
208
|
+
const coins = intent.inputs.flatMap((x) => (x.kind === "spend" ? [x.coin] : []));
|
|
209
|
+
const fields = {
|
|
210
|
+
0xdb: pathSizes(coins),
|
|
211
|
+
0xdc: intent.inputs.map((x) => (x.kind === "spend" ? encodeAssetOutput(x.coin).length : 0)),
|
|
212
|
+
0xe6: pathSizes(intent.outputs),
|
|
213
|
+
0xe7: parts.outputs.map((o) => o.length),
|
|
214
|
+
};
|
|
215
|
+
return {
|
|
216
|
+
wireBytes: parts.wire.length,
|
|
217
|
+
inputs: intent.inputs.map((input, i) => {
|
|
218
|
+
const ws = witnesses(input).map((w, j) => {
|
|
219
|
+
const m = w.artifact.methods.find((x) => x.name === w.methodName);
|
|
220
|
+
const script = unhex(m.scriptHex);
|
|
221
|
+
// Arguments are pushed in order; a mint's 16-byte delta goes on top.
|
|
222
|
+
const argumentBytes = values[i][j].map((v) => v.length);
|
|
223
|
+
if (input.kind === "mint")
|
|
224
|
+
argumentBytes.push(16);
|
|
225
|
+
return {
|
|
226
|
+
scriptBytes: script.length,
|
|
227
|
+
siblings: m.proof.length,
|
|
228
|
+
vmCu: intent.fee.invocationCu?.[`${i}:${j}`] ??
|
|
229
|
+
staticInvocationCu(script, argumentBytes, inputCount, outputCount, fields),
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
return input.kind === "mint"
|
|
233
|
+
? {
|
|
234
|
+
kind: "mint",
|
|
235
|
+
coreBytes: parts.core[i].length,
|
|
236
|
+
fullBytes: parts.full[i].length,
|
|
237
|
+
witnesses: [ws[0]],
|
|
238
|
+
}
|
|
239
|
+
: {
|
|
240
|
+
kind: "spend",
|
|
241
|
+
coreBytes: parts.core[i].length,
|
|
242
|
+
fullBytes: parts.full[i].length,
|
|
243
|
+
coinOutputBytes: encodeAssetOutput(input.coin).length,
|
|
244
|
+
witnesses: ws,
|
|
245
|
+
};
|
|
246
|
+
}),
|
|
247
|
+
outputs: parts.outputs.map((bytes, j) => ({
|
|
248
|
+
bytes: bytes.length,
|
|
249
|
+
burn: !!(intent.outputs[j].flags & 2),
|
|
250
|
+
})),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function accounting(intent) {
|
|
254
|
+
const ins = new Map(), outs = new Map(), explicit = new Map();
|
|
255
|
+
let nativeIn = 0n, nativeOut = 0n, tokenOutputs = 0;
|
|
256
|
+
const record = (m, id, v) => m.set(id, add(m.get(id) ?? 0n, v));
|
|
257
|
+
for (const input of intent.inputs)
|
|
258
|
+
if (input.kind === "spend") {
|
|
259
|
+
const c = input.coin;
|
|
260
|
+
if (c.flags & 2)
|
|
261
|
+
throw Error("burn output cannot be spent");
|
|
262
|
+
if (c.flags & 1)
|
|
263
|
+
record(ins, c.tokenId, c.value);
|
|
264
|
+
else
|
|
265
|
+
nativeIn = add(nativeIn, c.value);
|
|
266
|
+
}
|
|
267
|
+
for (const o of intent.outputs) {
|
|
268
|
+
if (o.flags & 1) {
|
|
269
|
+
record(outs, o.tokenId, o.value);
|
|
270
|
+
tokenOutputs++;
|
|
271
|
+
if (o.flags & 2)
|
|
272
|
+
record(explicit, o.tokenId, o.value);
|
|
273
|
+
}
|
|
274
|
+
else
|
|
275
|
+
nativeOut = add(nativeOut, o.value);
|
|
276
|
+
}
|
|
277
|
+
if (nativeOut > nativeIn)
|
|
278
|
+
throw Error("negative native fee");
|
|
279
|
+
const deltas = {}, burns = {};
|
|
280
|
+
for (const id of new Set([...ins.keys(), ...outs.keys()])) {
|
|
281
|
+
const a = ins.get(id) ?? 0n, b = outs.get(id) ?? 0n;
|
|
282
|
+
if (b > a) {
|
|
283
|
+
const delta = b - a;
|
|
284
|
+
// C16a: a mint amount is an amount; 2^62 also fits the VM's int128.
|
|
285
|
+
if (delta > MAX_MONEY)
|
|
286
|
+
throw Error(`mint amount ${delta} for token ${id} is outside MoneyRange 0..2^62 (C16a)`);
|
|
287
|
+
deltas[id] = delta;
|
|
288
|
+
}
|
|
289
|
+
const burn = (a > b ? a - b : 0n) + (explicit.get(id) ?? 0n);
|
|
290
|
+
if (burn)
|
|
291
|
+
burns[id] = burn;
|
|
292
|
+
}
|
|
293
|
+
const fee = nativeIn - nativeOut;
|
|
294
|
+
if (fee > MAX_MONEY)
|
|
295
|
+
throw Error(`native fee ${fee} is outside MoneyRange 0..2^62 (C16a)`);
|
|
296
|
+
return { fee, deltas, burns, tokenOutputs };
|
|
297
|
+
}
|
|
298
|
+
export function prepareTransactionCall(intent) {
|
|
299
|
+
if (intent.change === undefined)
|
|
300
|
+
return { ...prepareExact(intent), changeIndex: null };
|
|
301
|
+
const { change, ...rest } = intent;
|
|
302
|
+
const output = change?.output;
|
|
303
|
+
if (!output || output.flags !== 0 || output.tokenId !== undefined)
|
|
304
|
+
throw Error("change output must be native and spendable (flags 0)");
|
|
305
|
+
const at = change.index ?? rest.outputs.length;
|
|
306
|
+
if (!Number.isInteger(at) || at < 0 || at > rest.outputs.length)
|
|
307
|
+
throw Error(`change index ${at} is outside 0..${rest.outputs.length}`);
|
|
308
|
+
let remainder = 0n;
|
|
309
|
+
for (const input of rest.inputs)
|
|
310
|
+
if (input.kind === "spend" && !(input.coin.flags & 1))
|
|
311
|
+
remainder += input.coin.value;
|
|
312
|
+
for (const o of rest.outputs)
|
|
313
|
+
if (!(o.flags & 1))
|
|
314
|
+
remainder -= o.value;
|
|
315
|
+
const placed = (value) => ({
|
|
316
|
+
...rest,
|
|
317
|
+
outputs: [...rest.outputs.slice(0, at), { ...output, value }, ...rest.outputs.slice(at)],
|
|
318
|
+
});
|
|
319
|
+
const dust = rest.fee?.parameters?.dustLimitAtoms ?? 0n;
|
|
320
|
+
if (remainder >= 0n) {
|
|
321
|
+
// The change value does not change the shape (u64 on the wire), so a probe with
|
|
322
|
+
// value 0 prices the final transaction exactly.
|
|
323
|
+
const need = prepareExact(placed(0n), at).requiredFeeAtoms;
|
|
324
|
+
if (remainder - need >= dust)
|
|
325
|
+
return { ...prepareExact(placed(remainder - need)), changeIndex: at };
|
|
326
|
+
}
|
|
327
|
+
const need = remainder >= 0n ? prepareExact(rest, -1).requiredFeeAtoms : undefined;
|
|
328
|
+
if (need === undefined || remainder < need)
|
|
329
|
+
throw Error(`native inputs leave ${remainder} atoms after the outputs, but the fee needs ${need ?? "more"} atoms`);
|
|
330
|
+
return { ...prepareExact(rest), changeIndex: null };
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* The fee the intent's final shape requires under its fee policy, without checking that
|
|
334
|
+
* the intent pays it. With `intent.change`, the change output is priced in place.
|
|
335
|
+
*/
|
|
336
|
+
export function estimateTransactionCuAndFee(intent) {
|
|
337
|
+
if (intent.change === undefined)
|
|
338
|
+
return prepareExact(intent, -1).feeRequirement;
|
|
339
|
+
const { change, ...rest } = intent;
|
|
340
|
+
const at = change.index ?? rest.outputs.length;
|
|
341
|
+
if (!Number.isInteger(at) || at < 0 || at > rest.outputs.length)
|
|
342
|
+
throw Error(`change index ${at} is outside 0..${rest.outputs.length}`);
|
|
343
|
+
const outputs = [...rest.outputs.slice(0, at), { ...change.output, value: 0n }, ...rest.outputs.slice(at)];
|
|
344
|
+
return prepareExact({ ...rest, outputs }, at).feeRequirement;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Set the value of an existing native output (by default the last native spendable one)
|
|
348
|
+
* so that the transaction pays exactly its required fee. Unlike `intent.change`, which
|
|
349
|
+
* drops change below the dust limit, this rejects it.
|
|
350
|
+
*/
|
|
351
|
+
export function simulateFeeAndAdjustChange(intent, options = {}) {
|
|
352
|
+
if (!intent || !Array.isArray(intent.inputs) || !Array.isArray(intent.outputs))
|
|
353
|
+
throw Error("simulateFeeAndAdjustChange takes a planner TransactionIntent");
|
|
354
|
+
if (intent.change !== undefined)
|
|
355
|
+
throw Error("intent already names a change output");
|
|
356
|
+
const native = (o) => o.flags === 0 && o.tokenId === undefined;
|
|
357
|
+
let at = options.changeOutputIndex ?? -1;
|
|
358
|
+
if (options.changeOutputIndex === undefined) {
|
|
359
|
+
for (let j = intent.outputs.length - 1; j >= 0 && at < 0; j--)
|
|
360
|
+
if (native(intent.outputs[j]))
|
|
361
|
+
at = j;
|
|
362
|
+
if (at < 0)
|
|
363
|
+
throw Error("no native spendable change output found");
|
|
364
|
+
}
|
|
365
|
+
else if (!Number.isInteger(at) || at < 0 || at >= intent.outputs.length)
|
|
366
|
+
throw Error(`changeOutputIndex ${at} is out of range for ${intent.outputs.length} outputs`);
|
|
367
|
+
if (!native(intent.outputs[at]))
|
|
368
|
+
throw Error("designated change output must be a native spendable output");
|
|
369
|
+
const others = intent.outputs.filter((_, j) => j !== at);
|
|
370
|
+
const placed = { ...intent, outputs: others, change: { output: intent.outputs[at], index: at } };
|
|
371
|
+
const estimate = estimateTransactionCuAndFee(placed);
|
|
372
|
+
let totalNativeInputs = 0n, nonChangeNativeOutputs = 0n;
|
|
373
|
+
for (const input of intent.inputs)
|
|
374
|
+
if (input.kind === "spend" && !(input.coin.flags & 1))
|
|
375
|
+
totalNativeInputs += input.coin.value;
|
|
376
|
+
for (const o of others)
|
|
377
|
+
if (!(o.flags & 1))
|
|
378
|
+
nonChangeNativeOutputs += o.value;
|
|
379
|
+
const changeValue = totalNativeInputs - nonChangeNativeOutputs - estimate.requiredFeeAtoms;
|
|
380
|
+
const dust = intent.fee.parameters.dustLimitAtoms;
|
|
381
|
+
if (changeValue >= 0n && changeValue < dust)
|
|
382
|
+
throw Error(`change of ${changeValue} atoms is below the dust limit of ${dust} atoms`);
|
|
383
|
+
const plan = prepareTransactionCall(placed);
|
|
384
|
+
return {
|
|
385
|
+
estimate: plan.feeRequirement,
|
|
386
|
+
changeOutputIndex: at,
|
|
387
|
+
totalNativeInputs,
|
|
388
|
+
nonChangeNativeOutputs,
|
|
389
|
+
requiredFeeAtoms: plan.requiredFeeAtoms,
|
|
390
|
+
feeAtoms: plan.feeAtoms,
|
|
391
|
+
changeValue,
|
|
392
|
+
adjustedOutputs: plan.intent.outputs,
|
|
393
|
+
adjustedIntent: plan.intent,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Plan a transaction whose outputs are all given. `probe` (an output index, or -1) skips
|
|
398
|
+
* the fee checks and that output's dust check, to price a shape before its change is known.
|
|
399
|
+
*/
|
|
400
|
+
function prepareExact(intent, probe) {
|
|
401
|
+
if (intent.profile !== PROFILE)
|
|
402
|
+
throw Error("unsupported profile");
|
|
403
|
+
unhex(intent.chainId, 32);
|
|
404
|
+
const lock = intent.lock ?? 0n;
|
|
405
|
+
uint(lock, 8);
|
|
406
|
+
if ((lock & 255n) > 2n || ((lock & 255n) === 0n && lock !== 0n))
|
|
407
|
+
throw Error("invalid P01 lock");
|
|
408
|
+
if (!intent.fee || typeof intent.fee !== "object")
|
|
409
|
+
throw Error("fee policy required: { parameters, rule?, maxFeeAtoms?, invocationCu? } (see SPEC_FEE_PARAMETERS)");
|
|
410
|
+
const dust = intent.fee.parameters?.dustLimitAtoms;
|
|
411
|
+
if (!intent.inputs.length ||
|
|
412
|
+
intent.inputs.length > 256 ||
|
|
413
|
+
intent.outputs.length > 256)
|
|
414
|
+
throw Error("input/output count exceeds the C06 cap of 256");
|
|
415
|
+
intent.outputs.forEach(encodeAssetOutput);
|
|
416
|
+
// C14c: a spendable native output holds at least the dust limit.
|
|
417
|
+
if (typeof dust !== "bigint" || dust < 0n)
|
|
418
|
+
throw Error("fee parameter dustLimitAtoms must be a nonnegative bigint");
|
|
419
|
+
intent.outputs.forEach((o, j) => {
|
|
420
|
+
if ((o.flags & 3) === 0 && o.value < dust && j !== probe)
|
|
421
|
+
throw Error(`native output ${j} holds ${o.value} atoms, below the dust limit of ${dust} (C14c)`);
|
|
422
|
+
});
|
|
423
|
+
// C16a: every output and spent-coin amount, native or token, is in MoneyRange.
|
|
424
|
+
intent.outputs.forEach((o, j) => assertMoneyRange(o.value, `output ${j} value`));
|
|
425
|
+
intent.inputs.forEach((input, i) => {
|
|
426
|
+
if (input.kind === "spend")
|
|
427
|
+
assertMoneyRange(input.coin.value, `input ${i} coin value`);
|
|
428
|
+
});
|
|
429
|
+
const seen = new Set(), mintIds = [];
|
|
430
|
+
let spends = 0;
|
|
431
|
+
for (const input of intent.inputs) {
|
|
432
|
+
if (input.kind === "mint") {
|
|
433
|
+
const id = input.artifact.policy.root;
|
|
434
|
+
unhex(id, 32);
|
|
435
|
+
if (id === "00".repeat(32))
|
|
436
|
+
throw Error("zero mint token ID");
|
|
437
|
+
selected({
|
|
438
|
+
artifact: input.artifact,
|
|
439
|
+
methodName: input.methodName,
|
|
440
|
+
args: input.args,
|
|
441
|
+
}, id, "mint");
|
|
442
|
+
const key = `${id}:0`;
|
|
443
|
+
if (seen.has(key))
|
|
444
|
+
throw Error("duplicate input outpoint");
|
|
445
|
+
seen.add(key);
|
|
446
|
+
mintIds.push(id);
|
|
447
|
+
}
|
|
448
|
+
else if (input.kind === "spend") {
|
|
449
|
+
spends++;
|
|
450
|
+
unhex(input.prevTxid, 32);
|
|
451
|
+
u32(input.prevIndex);
|
|
452
|
+
u32(input.sequence);
|
|
453
|
+
if (input.sequence !== 0xffffffff && (input.sequence & ~0x40ffff) !== 0)
|
|
454
|
+
throw Error("invalid P01 sequence");
|
|
455
|
+
const key = `${input.prevTxid}:${input.prevIndex}`;
|
|
456
|
+
if (seen.has(key))
|
|
457
|
+
throw Error("duplicate input outpoint");
|
|
458
|
+
seen.add(key);
|
|
459
|
+
encodeAssetOutput(input.coin);
|
|
460
|
+
if (input.coin.flags & 2)
|
|
461
|
+
throw Error("burn output cannot be spent");
|
|
462
|
+
if (!Number.isInteger(input.pathIndex) ||
|
|
463
|
+
input.pathIndex < 0 ||
|
|
464
|
+
input.pathIndex >= input.coin.paths.length)
|
|
465
|
+
throw Error("invalid path index");
|
|
466
|
+
const path = input.coin.paths[input.pathIndex];
|
|
467
|
+
if (input.witnesses.length !== path.length)
|
|
468
|
+
throw Error("required witness count");
|
|
469
|
+
input.witnesses.forEach((w, j) => selected(w, input.coin.branches[path[j]], "spend"));
|
|
470
|
+
}
|
|
471
|
+
else
|
|
472
|
+
throw Error("unsupported input kind");
|
|
473
|
+
}
|
|
474
|
+
if (!spends)
|
|
475
|
+
throw Error("ordinary transaction needs consuming input");
|
|
476
|
+
const totals = accounting(intent);
|
|
477
|
+
if (snapshot([...mintIds].sort()) !==
|
|
478
|
+
snapshot(Object.keys(totals.deltas).sort()))
|
|
479
|
+
throw Error("mint inputs do not match positive token deltas");
|
|
480
|
+
const empty = intent.inputs.map((x, i) => valuesFor(x, i)), projected = intent.inputs.map((x, i) => valuesFor(x, i, undefined, true));
|
|
481
|
+
const initial = hashParts(intent, empty), predicted = hashParts(intent, projected);
|
|
482
|
+
const fee = feeRequirement(costShape(intent, predicted, projected), totals.tokenOutputs, intent.fee);
|
|
483
|
+
if (probe === undefined && totals.fee < fee.requiredFeeAtoms)
|
|
484
|
+
throw Error(`native fee ${totals.fee} is below the required ${fee.requiredFeeAtoms} atoms ` +
|
|
485
|
+
`(${fee.rule} rule: byte fee ${fee.byteFeeAtoms}, token-output burn ${fee.tokenOutputBurnAtoms}, ` +
|
|
486
|
+
`cu share ${fee.cuShareAtoms} for ${fee.transactionCostCu} cu)`);
|
|
487
|
+
if (probe === undefined && totals.fee > fee.maxFeeAtoms)
|
|
488
|
+
throw Error(`native fee ${totals.fee} exceeds the ceiling of ${fee.maxFeeAtoms} atoms; ` +
|
|
489
|
+
"check the change output, or set fee.maxFeeAtoms to pay more");
|
|
490
|
+
const requests = [];
|
|
491
|
+
intent.inputs.forEach((input, i) => witnesses(input).forEach((w, j) => {
|
|
492
|
+
const m = w.artifact.methods.find((x) => x.name === w.methodName);
|
|
493
|
+
const branchIndex = input.kind === "spend"
|
|
494
|
+
? input.coin.paths[input.pathIndex][j]
|
|
495
|
+
: undefined;
|
|
496
|
+
const selector = input.kind === "mint"
|
|
497
|
+
? concat(Uint8Array.of(3), unhex(input.artifact.policy.root, 32), uint(totals.deltas[input.artifact.policy.root], 16), unhex(m.leaf, 32))
|
|
498
|
+
: concat(Uint8Array.of(1), u32(i), u32(branchIndex), unhex(m.leaf, 32));
|
|
499
|
+
const message = (mode) => {
|
|
500
|
+
if (mode === 0)
|
|
501
|
+
return hex(tagged("sighash", concat(unhex(intent.chainId, 32), Uint8Array.of(0), unhex(initial.txid, 32), initial.coinsRoot, selector)));
|
|
502
|
+
if (input.kind !== "spend")
|
|
503
|
+
throw Error("modes 01 and 02 are defined only for spend invocations");
|
|
504
|
+
if (mode === 2 && i >= initial.outputs.length)
|
|
505
|
+
throw Error(`input ${i} signs mode 02 but the transaction has no output ${i}`);
|
|
506
|
+
// OwnInputHash(i) = H_owninput(InputCore(i) || Bytes(CoinOutput(coin_i))).
|
|
507
|
+
const own = tagged("owninput", concat(initial.core[i], bytes(encodeAssetOutput(input.coin))));
|
|
508
|
+
const outputs = mode === 1 ? initial.outputsRoot : tagged("output", bytes(initial.outputs[i]));
|
|
509
|
+
return hex(tagged("sighash", concat(unhex(intent.chainId, 32), Uint8Array.of(mode), u32(7), uint(intent.lock ?? 0n, 8), own, outputs, selector)));
|
|
510
|
+
};
|
|
511
|
+
for (const arg of m.args) {
|
|
512
|
+
if (arg.type !== "Signature")
|
|
513
|
+
continue;
|
|
514
|
+
const chosen = signingMode(w, arg.name);
|
|
515
|
+
if (chosen === "ABSTAIN")
|
|
516
|
+
continue;
|
|
517
|
+
const mode = MODE_BYTE[chosen];
|
|
518
|
+
requests.push({
|
|
519
|
+
key: `${i}:${j}:${arg.name}`,
|
|
520
|
+
argument: arg.name,
|
|
521
|
+
mode,
|
|
522
|
+
signingMode: chosen,
|
|
523
|
+
digest: message(mode),
|
|
524
|
+
inputIndex: i,
|
|
525
|
+
witnessIndex: j,
|
|
526
|
+
...(input.kind === "mint"
|
|
527
|
+
? {
|
|
528
|
+
tokenId: input.artifact.policy.root,
|
|
529
|
+
positiveDelta: totals.deltas[input.artifact.policy.root],
|
|
530
|
+
}
|
|
531
|
+
: { branchIndex: branchIndex }),
|
|
532
|
+
leaf: m.leaf,
|
|
533
|
+
feeAtoms: totals.fee,
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
}));
|
|
537
|
+
return {
|
|
538
|
+
intent,
|
|
539
|
+
seal: snapshot(intent),
|
|
540
|
+
unsignedWire: initial.wire,
|
|
541
|
+
projectedFullBytes: predicted.wire.length,
|
|
542
|
+
txid: initial.txid,
|
|
543
|
+
feeAtoms: totals.fee,
|
|
544
|
+
minimumFeeAtoms: fee.minimumFeeAtoms,
|
|
545
|
+
requiredFeeAtoms: fee.requiredFeeAtoms,
|
|
546
|
+
maxFeeAtoms: fee.maxFeeAtoms,
|
|
547
|
+
feeRequirement: fee,
|
|
548
|
+
tokenDeltas: totals.deltas,
|
|
549
|
+
tokenBurns: totals.burns,
|
|
550
|
+
requests,
|
|
551
|
+
stages,
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
export function finalizeTransactionCall(plan, signatures) {
|
|
555
|
+
if (snapshot(plan.intent) !== plan.seal)
|
|
556
|
+
throw Error("stale transaction plan");
|
|
557
|
+
const fresh = prepareTransactionCall(plan.intent);
|
|
558
|
+
if (fresh.txid !== plan.txid ||
|
|
559
|
+
hex(fresh.unsignedWire) !== hex(plan.unsignedWire) ||
|
|
560
|
+
fresh.projectedFullBytes !== plan.projectedFullBytes ||
|
|
561
|
+
fresh.feeAtoms !== plan.feeAtoms ||
|
|
562
|
+
fresh.minimumFeeAtoms !== plan.minimumFeeAtoms ||
|
|
563
|
+
fresh.requiredFeeAtoms !== plan.requiredFeeAtoms ||
|
|
564
|
+
fresh.maxFeeAtoms !== plan.maxFeeAtoms ||
|
|
565
|
+
snapshot(fresh.tokenDeltas) !== snapshot(plan.tokenDeltas) ||
|
|
566
|
+
snapshot(fresh.tokenBurns) !== snapshot(plan.tokenBurns) ||
|
|
567
|
+
snapshot(fresh.requests) !== snapshot(plan.requests))
|
|
568
|
+
throw Error("stale transaction plan");
|
|
569
|
+
if (snapshot(Object.keys(signatures).sort()) !==
|
|
570
|
+
snapshot(fresh.requests.map((x) => x.key).sort()))
|
|
571
|
+
throw Error("signature slots mismatch");
|
|
572
|
+
const final = hashParts(plan.intent, plan.intent.inputs.map((x, i) => valuesFor(x, i, signatures)));
|
|
573
|
+
if (final.wire.length !== plan.projectedFullBytes)
|
|
574
|
+
throw Error("projected wire length mismatch");
|
|
575
|
+
return { wire: final.wire, txid: final.txid, txhash: final.txhash, stages };
|
|
576
|
+
}
|
|
577
|
+
export { APPROVED_COST_SCHEDULE, DEFAULT_MAX_FEE_MULTIPLE, MAX_MONEY, SPEC_FEE_PARAMETERS, byteFee, cuShareAtoms, feeRequirement, indexedByteFee, staticInvocationCu, linearCost, transactionCost, } from "./fees.js";
|
|
578
|
+
function placed(inputs, input, index) {
|
|
579
|
+
const at = index ?? 0;
|
|
580
|
+
if (!Number.isInteger(at) || at < 0 || at > inputs.length)
|
|
581
|
+
throw Error(`inputIndex ${at} is outside 0..${inputs.length}`);
|
|
582
|
+
return [...inputs.slice(0, at), input, ...inputs.slice(at)];
|
|
583
|
+
}
|
|
584
|
+
export function contractSpendIntent(artifact, methodName, context, args) {
|
|
585
|
+
if (!context || typeof context !== "object")
|
|
586
|
+
throw Error("spend context required");
|
|
587
|
+
const pathIndex = context.pathIndex ?? 0;
|
|
588
|
+
const path = context.coin?.paths?.[pathIndex];
|
|
589
|
+
if (!Array.isArray(path))
|
|
590
|
+
throw Error(`coin has no path ${pathIndex}`);
|
|
591
|
+
const companions = [...(context.companions ?? [])];
|
|
592
|
+
let own = false;
|
|
593
|
+
const witnesses = path.map((branch) => {
|
|
594
|
+
if (!own && context.coin.branches[branch] === artifact.policy.root) {
|
|
595
|
+
own = true;
|
|
596
|
+
return { artifact, methodName, args };
|
|
597
|
+
}
|
|
598
|
+
const next = companions.shift();
|
|
599
|
+
if (!next)
|
|
600
|
+
throw Error(`coin path ${pathIndex} needs a witness for branch ${branch}; pass it in companions`);
|
|
601
|
+
return next;
|
|
602
|
+
});
|
|
603
|
+
if (!own)
|
|
604
|
+
throw Error(`coin path ${pathIndex} does not require contract ${artifact.contract}`);
|
|
605
|
+
if (companions.length)
|
|
606
|
+
throw Error(`${companions.length} unused companion witness(es)`);
|
|
607
|
+
const input = {
|
|
608
|
+
kind: "spend",
|
|
609
|
+
prevTxid: context.prevTxid,
|
|
610
|
+
prevIndex: context.prevIndex,
|
|
611
|
+
sequence: context.sequence ?? 0xffffffff,
|
|
612
|
+
coin: context.coin,
|
|
613
|
+
pathIndex,
|
|
614
|
+
witnesses,
|
|
615
|
+
};
|
|
616
|
+
return {
|
|
617
|
+
profile: artifact.target,
|
|
618
|
+
chainId: context.chainId,
|
|
619
|
+
...(context.lock === undefined ? {} : { lock: context.lock }),
|
|
620
|
+
fee: context.fee,
|
|
621
|
+
inputs: placed(context.otherInputs ?? [], input, context.inputIndex),
|
|
622
|
+
outputs: [...context.outputs],
|
|
623
|
+
...(context.change === undefined ? {} : { change: context.change }),
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
export function contractMintIntent(artifact, methodName, context, args) {
|
|
627
|
+
if (!context || typeof context !== "object")
|
|
628
|
+
throw Error("mint context required");
|
|
629
|
+
const inputs = context.inputs ?? [];
|
|
630
|
+
const input = { kind: "mint", artifact, methodName, args };
|
|
631
|
+
return {
|
|
632
|
+
profile: artifact.target,
|
|
633
|
+
chainId: context.chainId,
|
|
634
|
+
...(context.lock === undefined ? {} : { lock: context.lock }),
|
|
635
|
+
fee: context.fee,
|
|
636
|
+
inputs: placed(inputs, input, context.inputIndex ?? inputs.length),
|
|
637
|
+
outputs: [...context.outputs],
|
|
638
|
+
...(context.change === undefined ? {} : { change: context.change }),
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
/** True when the plan invokes `methodName` of `artifact` in some input. */
|
|
642
|
+
export function planInvokes(plan, artifact, methodName) {
|
|
643
|
+
return plan.intent.inputs.some((input) => input.kind === "mint"
|
|
644
|
+
? input.artifact.policy.root === artifact.policy.root && input.methodName === methodName
|
|
645
|
+
: input.witnesses.some((w) => w.artifact.policy.root === artifact.policy.root && w.methodName === methodName));
|
|
646
|
+
}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P05 static VM charge of one invocation: the reference's size pass
|
|
3
|
+
* (tools/lotus-v2-reference, vm_cost.static_size_cost) under the approved opcode
|
|
4
|
+
* schedule, plus 1 cu per script byte. The pass tracks an upper bound on every
|
|
5
|
+
* stack item's size and charges each instruction from its operand and result
|
|
6
|
+
* bounds; loops multiply their body by the static bound, and a conditional charges
|
|
7
|
+
* its dearer arm. Anything the pass cannot follow charges at MAX_ELEMENT_BYTES.
|
|
8
|
+
*/
|
|
9
|
+
/** Serialized sizes the field reads push (UTXOPATH, UTXOOUTPUT, OUTPUTPATH, OUTPUTRECORD). */
|
|
10
|
+
export type FieldSizes = Partial<Record<0xdb | 0xdc | 0xe6 | 0xe7, number[]>>;
|
|
11
|
+
export declare function staticInvocationCu(script: Uint8Array, initialSizes: number[], inputCount: number, outputCount: number, fields?: FieldSizes): bigint;
|