@givelotus/compiler 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.
Files changed (87) hide show
  1. package/README.md +331 -2
  2. package/artifact-v2.schema.json +58 -0
  3. package/artifact.schema.json +19 -0
  4. package/dist/ast.d.ts +292 -0
  5. package/dist/ast.js +150 -0
  6. package/dist/bindings.d.ts +6 -0
  7. package/dist/bindings.js +134 -0
  8. package/dist/call-runtime.d.ts +84 -0
  9. package/dist/call-runtime.js +249 -0
  10. package/dist/cli.d.ts +2 -0
  11. package/dist/cli.js +22 -0
  12. package/dist/compiler.d.ts +79 -0
  13. package/dist/compiler.js +125 -0
  14. package/dist/diagnostics.d.ts +163 -0
  15. package/dist/diagnostics.js +498 -0
  16. package/dist/ecash.d.ts +41 -0
  17. package/dist/ecash.js +190 -0
  18. package/dist/fees.d.ts +164 -0
  19. package/dist/fees.js +208 -0
  20. package/dist/fixture-cli.d.ts +2 -0
  21. package/dist/fixture-cli.js +41 -0
  22. package/dist/fixtures.d.ts +68 -0
  23. package/dist/fixtures.js +46 -0
  24. package/dist/forth-ir.d.ts +73 -0
  25. package/dist/forth-ir.js +147 -0
  26. package/dist/generic-cli.d.ts +2 -0
  27. package/dist/generic-cli.js +140 -0
  28. package/dist/generic.d.ts +48 -0
  29. package/dist/generic.js +2566 -0
  30. package/dist/lints.d.ts +8 -0
  31. package/dist/lints.js +204 -0
  32. package/dist/names.d.ts +1 -0
  33. package/dist/names.js +7 -0
  34. package/dist/opcodes.d.ts +154 -0
  35. package/dist/opcodes.js +162 -0
  36. package/dist/optimizer.d.ts +58 -0
  37. package/dist/optimizer.js +786 -0
  38. package/dist/package-fetch-cli.d.ts +2 -0
  39. package/dist/package-fetch-cli.js +17 -0
  40. package/dist/package-lock-cli.d.ts +2 -0
  41. package/dist/package-lock-cli.js +28 -0
  42. package/dist/package-sources.d.ts +82 -0
  43. package/dist/package-sources.js +785 -0
  44. package/dist/package-update-cli.d.ts +2 -0
  45. package/dist/package-update-cli.js +20 -0
  46. package/dist/packages.d.ts +231 -0
  47. package/dist/packages.js +1307 -0
  48. package/dist/parser.d.ts +32 -0
  49. package/dist/parser.js +575 -0
  50. package/dist/policy.d.ts +83 -0
  51. package/dist/policy.js +207 -0
  52. package/dist/runtime.d.ts +58 -0
  53. package/dist/runtime.js +126 -0
  54. package/dist/scheduler.d.ts +38 -0
  55. package/dist/scheduler.js +76 -0
  56. package/dist/semantic-ir.d.ts +76 -0
  57. package/dist/semantic-ir.js +231 -0
  58. package/dist/std.d.ts +27 -0
  59. package/dist/std.js +225 -0
  60. package/dist/target-compiler.d.ts +9 -0
  61. package/dist/target-compiler.js +139 -0
  62. package/dist/targets.d.ts +53 -0
  63. package/dist/targets.js +67 -0
  64. package/dist/toml-subset.d.ts +19 -0
  65. package/dist/toml-subset.js +81 -0
  66. package/dist/transaction-runtime.d.ts +182 -0
  67. package/dist/transaction-runtime.js +646 -0
  68. package/dist/version.d.ts +3 -0
  69. package/dist/version.js +3 -0
  70. package/dist/vm-cost.d.ts +11 -0
  71. package/dist/vm-cost.js +541 -0
  72. package/package.json +71 -4
  73. package/policy-artifact.schema.json +20 -0
  74. package/std/custody/arbiter-escrow.lotus +20 -0
  75. package/std/custody/htlc.lotus +15 -0
  76. package/std/custody/multisig-2of3.lotus +13 -0
  77. package/std/custody/single-owner-wallet.lotus +9 -0
  78. package/std/custody/vault-with-recovery.lotus +14 -0
  79. package/std/defi/amm-pool-v2.lotus +97 -0
  80. package/std/defi/indexed-limit-order.lotus +37 -0
  81. package/std/nft/nft-collection.lotus +51 -0
  82. package/std/nft/royalty-transfer-rules.lotus +38 -0
  83. package/std/nft/unique-nft.lotus +30 -0
  84. package/std/tokens/capped-supply-token.lotus +76 -0
  85. package/std/tokens/fixed-supply-token.lotus +29 -0
  86. package/std/tokens/standard-transfer-rules.lotus +15 -0
  87. package/std/tokens/voucher-mint-token.lotus +31 -0
@@ -0,0 +1,53 @@
1
+ /** Compiler target capabilities are implemented slices, not network support claims. */
2
+ export type TargetId = 'lotus-v2' | 'ecash';
3
+ export type SemanticCapability = 'bytes' | 'bool' | 'sha256' | 'hash256' | 'byte-equality' | 'require' | 'if' | 'lotus-int128' | 'transaction-signature' | 'transaction-reflection' | 'lotus-loop' | 'lotus-token';
4
+ export type SourceSpan = {
5
+ start: number;
6
+ end: number;
7
+ file?: string;
8
+ };
9
+ export type TargetDiagnostic = {
10
+ code: string;
11
+ message: string;
12
+ span?: SourceSpan;
13
+ capability?: string;
14
+ };
15
+ export type CapabilityRequirement = {
16
+ capability: SemanticCapability;
17
+ span?: SourceSpan;
18
+ };
19
+ export type TargetDescriptor = {
20
+ readonly id: TargetId;
21
+ readonly revision: string;
22
+ readonly profile: string;
23
+ readonly capabilities: readonly SemanticCapability[];
24
+ readonly limits: Readonly<{
25
+ maxScriptBytes: number;
26
+ maxElementBytes: number;
27
+ maxStackItems: number | null;
28
+ maxOps: number;
29
+ }>;
30
+ readonly capabilityScope: 'compiler-implemented';
31
+ /** null stack limit requires the caller's explicit invocation profile. */
32
+ readonly limitsScope: 'compiler' | 'vm-consensus';
33
+ readonly semantics: Readonly<{
34
+ booleanEncoding: 'canonical-int128-le' | 'minimal-scriptnum';
35
+ booleanConsumers: 'canonical-zero-or-one' | 'script-truthiness-with-minimalif';
36
+ integerModel: 'signed-int128' | 'not-supported-by-compiler';
37
+ signatureModel: 'lotus-p01' | 'not-supported-by-compiler';
38
+ entrypoint: 'merkle-branch-per-method' | 'single-method-script';
39
+ commitmentModel: 'lotus-branches-and-paths' | 'external-script-wrapper-required';
40
+ }>;
41
+ /** Exact pin's STANDARD_SCRIPT_VERIFY_FLAGS plus MINIMALIF; research profile, not network defaults. */
42
+ readonly evaluationFlags: readonly string[];
43
+ readonly maxMethods: number;
44
+ readonly evaluationFlagPolicy: 'caller-invocation-profile' | 'standard-plus-minimalif-research';
45
+ readonly sourceTree?: string;
46
+ };
47
+ export declare const ECASH_REVISION = "1fb7db17c176cdea8a2c60d887891589382ee4e3";
48
+ /** Exact identifiers only: aliases and inherited defaults are caller policy. */
49
+ export declare function resolveTarget(id: string): TargetDescriptor;
50
+ /** Reject semantic obligations before bytecode emission; preserve occurrence spans. */
51
+ export declare function checkCapabilities(target: TargetDescriptor, requirements: readonly CapabilityRequirement[]): TargetDiagnostic[];
52
+ /** eCash method dispatch must be designed explicitly, never inherited from Lotus. */
53
+ export declare function checkEntrypoint(target: TargetDescriptor, methodCount: number, span?: SourceSpan): TargetDiagnostic[];
@@ -0,0 +1,67 @@
1
+ export const ECASH_REVISION = '1fb7db17c176cdea8a2c60d887891589382ee4e3';
2
+ const portable = ['bytes', 'bool', 'sha256', 'hash256', 'byte-equality', 'require', 'if'];
3
+ const lotusOnly = ['lotus-int128', 'transaction-signature', 'transaction-reflection', 'lotus-loop', 'lotus-token'];
4
+ const lotus = Object.freeze({
5
+ id: 'lotus-v2', revision: 'P01-P02-P03-candidate-2026-10-14', profile: 'P01-P02-P03-candidate-2026-10-14',
6
+ capabilities: Object.freeze([...portable, ...lotusOnly]), capabilityScope: 'compiler-implemented', limitsScope: 'compiler',
7
+ limits: Object.freeze({ maxScriptBytes: 8192, maxElementBytes: 8192, maxStackItems: null, maxOps: 4096 }),
8
+ semantics: Object.freeze({ booleanEncoding: 'canonical-int128-le', booleanConsumers: 'canonical-zero-or-one',
9
+ integerModel: 'signed-int128', signatureModel: 'lotus-p01', entrypoint: 'merkle-branch-per-method',
10
+ commitmentModel: 'lotus-branches-and-paths' }),
11
+ evaluationFlags: Object.freeze([]), maxMethods: 16, evaluationFlagPolicy: 'caller-invocation-profile',
12
+ });
13
+ const ecash = Object.freeze({
14
+ id: 'ecash', revision: ECASH_REVISION, profile: 'ecash-script-minimal-cleanstack-1fb7db17',
15
+ capabilities: Object.freeze([...portable]), capabilityScope: 'compiler-implemented', limitsScope: 'vm-consensus',
16
+ limits: Object.freeze({ maxScriptBytes: 10000, maxElementBytes: 520, maxStackItems: 1000, maxOps: 201 }),
17
+ semantics: Object.freeze({ booleanEncoding: 'minimal-scriptnum', booleanConsumers: 'script-truthiness-with-minimalif',
18
+ integerModel: 'not-supported-by-compiler', signatureModel: 'not-supported-by-compiler',
19
+ entrypoint: 'single-method-script', commitmentModel: 'external-script-wrapper-required' }),
20
+ maxMethods: 1, evaluationFlagPolicy: 'standard-plus-minimalif-research',
21
+ sourceTree: 'b2e4a0a9f57c593129028352d5dbb0c4ff294cdb',
22
+ evaluationFlags: Object.freeze(['P2SH', 'STRICTENC', 'SIGHASH_FORKID', 'LOW_S', 'NULLFAIL', 'MINIMALDATA',
23
+ 'SCHNORR_MULTISIG', 'ENFORCE_SIGCHECKS', 'DERSIG', 'SIGPUSHONLY', 'DISCOURAGE_UPGRADABLE_NOPS',
24
+ 'CLEANSTACK', 'CHECKLOCKTIMEVERIFY', 'CHECKSEQUENCEVERIFY', 'DISALLOW_SEGWIT_RECOVERY', 'INPUT_SIGCHECKS', 'MINIMALIF']),
25
+ });
26
+ /** Exact identifiers only: aliases and inherited defaults are caller policy. */
27
+ export function resolveTarget(id) {
28
+ if (id === 'lotus-v2')
29
+ return lotus;
30
+ if (id === 'ecash')
31
+ return ecash;
32
+ throw new Error(`Unknown compiler target ${JSON.stringify(id)}; expected lotus-v2 or ecash`);
33
+ }
34
+ const ecashReasons = Object.freeze({
35
+ 'lotus-int128': 'Lotus Int requires exact sixteen-byte signed int128 arithmetic; the eCash compiler slice has no equivalent integer lowering.',
36
+ 'transaction-signature': 'Lotus transaction-signature semantics require the P01 authenticated message and key/signature ABI; eCash uses a different transaction/signature ABI and its signing lowering is not implemented.',
37
+ 'transaction-reflection': 'Lotus transaction reflection requires authenticated input/output and branch/path semantics; equivalent eCash compiler lowering is not implemented.',
38
+ 'lotus-loop': 'Lotus input/output enumeration requires transaction-context iteration; the eCash compiler slice implements no equivalent loop lowering.',
39
+ 'lotus-token': 'Lotus token mint/spend semantics and continuation commitments are not implemented by the eCash compiler slice.',
40
+ });
41
+ /** Reject semantic obligations before bytecode emission; preserve occurrence spans. */
42
+ export function checkCapabilities(target, requirements) {
43
+ return requirements.flatMap(requirement => {
44
+ if (target.capabilities.includes(requirement.capability))
45
+ return [];
46
+ const reason = target.id === 'ecash' && Object.hasOwn(ecashReasons, requirement.capability)
47
+ ? ecashReasons[requirement.capability]
48
+ : `Capability ${JSON.stringify(requirement.capability)} is not implemented by target ${target.id}.`;
49
+ return [{ code: 'E1201', message: `${target.id} (${target.revision}): ${reason}`,
50
+ ...(requirement.span ? { span: { ...requirement.span } } : {}), capability: requirement.capability }];
51
+ });
52
+ }
53
+ /** eCash method dispatch must be designed explicitly, never inherited from Lotus. */
54
+ export function checkEntrypoint(target, methodCount, span) {
55
+ if (!Number.isSafeInteger(methodCount) || methodCount < 1)
56
+ return [{ code: 'E1202',
57
+ message: 'A target entrypoint requires a positive safe integer method count.', ...(span ? { span: { ...span } } : {}) }];
58
+ if (target.semantics.entrypoint === 'single-method-script' && methodCount !== 1)
59
+ return [{ code: 'E1202',
60
+ message: `${target.id} emits one method script; ${methodCount} methods require an explicit selector/dispatch ABI, which is not implemented. Lotus branch proofs cannot select eCash entrypoints.`,
61
+ ...(span ? { span: { ...span } } : {}) }];
62
+ if (methodCount > target.maxMethods)
63
+ return [{ code: 'E1202',
64
+ message: `${target.id} compiler supports at most ${target.maxMethods} methods; received ${methodCount}.`,
65
+ ...(span ? { span: { ...span } } : {}) }];
66
+ return [];
67
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Strict parser for the tiny TOML subset used by `lotus.toml` (CABI-07).
3
+ *
4
+ * Accepted (every accepted file is also valid TOML 1.0):
5
+ * - UTF-8 text without BOM, LF or CRLF line endings, no tab characters or control bytes;
6
+ * - blank lines and full-line or trailing `#` comments;
7
+ * - `[table]` headers with a bare key (no dotted, array or inline tables);
8
+ * - `key = "string"` and `key = ["a", "b"]` (single line, optional trailing comma);
9
+ * - bare keys `[A-Za-z0-9_-]+` or quoted basic-string keys (no escapes);
10
+ * - basic strings without escapes, quotes or control characters.
11
+ *
12
+ * Everything else (integers, booleans, escapes, multi-line values, dotted keys,
13
+ * duplicate keys/tables, keys before the first table) is rejected rather than
14
+ * approximated, so two parsers cannot disagree about an accepted manifest.
15
+ * Quoted keys are basic strings, which TOML already allows.
16
+ */
17
+ export type TomlValue = string | string[];
18
+ export type TomlDocument = Map<string, Map<string, TomlValue>>;
19
+ export declare function parseTomlSubset(text: string, file: string): TomlDocument;
@@ -0,0 +1,81 @@
1
+ const KEY = /^[A-Za-z0-9_-]+$/;
2
+ const STRING = /^"([^"\\\x00-\x1f\x7f]*)"/;
3
+ export function parseTomlSubset(text, file) {
4
+ if (text.startsWith('\uFEFF'))
5
+ throw new Error(`${file}: byte-order mark is not allowed`);
6
+ const doc = new Map();
7
+ let table;
8
+ const lines = text.split('\n');
9
+ lines.forEach((raw, index) => {
10
+ const lineNo = index + 1;
11
+ const fail = (message) => { throw new Error(`${file}:${lineNo}: ${message}`); };
12
+ const line = raw.endsWith('\r') ? raw.slice(0, -1) : raw;
13
+ if (/[\x00-\x08\x0a-\x1f\x7f\t]/.test(line))
14
+ fail('control or tab character');
15
+ let rest = line.trim();
16
+ if (rest === '' || rest.startsWith('#'))
17
+ return;
18
+ const header = /^\[([A-Za-z0-9_-]+)\]\s*(#.*)?$/.exec(rest);
19
+ if (header) {
20
+ const name = header[1];
21
+ if (doc.has(name))
22
+ fail(`duplicate table [${name}]`);
23
+ table = new Map();
24
+ doc.set(name, table);
25
+ return;
26
+ }
27
+ const eq = rest.indexOf('=');
28
+ if (eq < 0)
29
+ fail('expected key = value');
30
+ const rawKey = rest.slice(0, eq).trim();
31
+ let key;
32
+ if (rawKey.startsWith('"')) {
33
+ const quoted = STRING.exec(rawKey);
34
+ key = quoted?.[0].length === rawKey.length ? quoted[1] ?? '' : '';
35
+ if (!key)
36
+ fail('unsupported key (quoted keys are basic strings without escapes)');
37
+ }
38
+ else {
39
+ if (!KEY.test(rawKey))
40
+ fail(`unsupported key ${JSON.stringify(rawKey)} (bare keys only)`);
41
+ key = rawKey;
42
+ }
43
+ if (!table)
44
+ fail('key outside of a table');
45
+ if (table.has(key))
46
+ fail(`duplicate key ${key}`);
47
+ rest = rest.slice(eq + 1).trim();
48
+ let value;
49
+ if (rest.startsWith('"')) {
50
+ const m = STRING.exec(rest);
51
+ if (!m)
52
+ fail('unsupported string (escapes, quotes and control characters are not allowed)');
53
+ value = m[1];
54
+ rest = rest.slice(m[0].length);
55
+ }
56
+ else if (rest.startsWith('[')) {
57
+ rest = rest.slice(1).trim();
58
+ const items = [];
59
+ while (!rest.startsWith(']')) {
60
+ const m = STRING.exec(rest);
61
+ if (!m)
62
+ fail('array items must be basic strings on one line');
63
+ items.push(m[1]);
64
+ rest = rest.slice(m[0].length).trim();
65
+ if (rest.startsWith(','))
66
+ rest = rest.slice(1).trim();
67
+ else if (!rest.startsWith(']'))
68
+ fail('expected , or ] in array');
69
+ }
70
+ value = items;
71
+ rest = rest.slice(1);
72
+ }
73
+ else
74
+ return fail('unsupported value (only strings and string arrays)');
75
+ rest = rest.trim();
76
+ if (rest !== '' && !rest.startsWith('#'))
77
+ fail('unexpected text after value');
78
+ table.set(key, value);
79
+ });
80
+ return doc;
81
+ }
@@ -0,0 +1,182 @@
1
+ import { type CallValue, type ContractArtifact } from "./call-runtime.js";
2
+ import { type FeePolicy, type FeeRequirement } from "./fees.js";
3
+ declare const PROFILE = "P01-P02-P03-candidate-2026-10-14";
4
+ export type AssetOutput = {
5
+ flags: 0 | 1 | 2 | 3 | 4 | 5;
6
+ value: bigint;
7
+ tokenId?: string;
8
+ stateRoot?: string;
9
+ branches: string[];
10
+ paths: number[][];
11
+ };
12
+ /**
13
+ * How a Signature slot is filled (P01). `null` or "FULL" asks for a mode 00 signature
14
+ * over the whole transaction. "OWN_INPUT_ALL_OUTPUTS" (mode 01) and
15
+ * "OWN_INPUT_ONE_OUTPUT" (mode 02, paired with the output at the input's index) cover
16
+ * only this input and the outputs; they are defined for spends only. "ABSTAIN" asks for
17
+ * no signature and puts 64 zero bytes in the slot, which CHECKSIG reports as false:
18
+ * an empty operand would be a script error.
19
+ */
20
+ export type SigningMode = "FULL" | "OWN_INPUT_ALL_OUTPUTS" | "OWN_INPUT_ONE_OUTPUT" | "ABSTAIN";
21
+ /** A witness argument: a typed value, or for a Signature slot a SigningMode or null. */
22
+ export type WitnessValue = CallValue | SigningMode;
23
+ export type SelectedWitness = {
24
+ artifact: ContractArtifact;
25
+ methodName: string;
26
+ args: Record<string, WitnessValue>;
27
+ };
28
+ export type SpendInput = {
29
+ kind: "spend";
30
+ prevTxid: string;
31
+ prevIndex: number;
32
+ sequence: number;
33
+ coin: AssetOutput;
34
+ pathIndex: number;
35
+ witnesses: SelectedWitness[];
36
+ };
37
+ export type MintInput = {
38
+ kind: "mint";
39
+ artifact: ContractArtifact;
40
+ methodName: string;
41
+ args: Record<string, WitnessValue>;
42
+ };
43
+ export type PlannedInput = SpendInput | MintInput;
44
+ export type TransactionIntent = {
45
+ profile: typeof PROFILE;
46
+ chainId: string;
47
+ lock?: bigint;
48
+ /** Fee parameters and policy; see fees.ts. */
49
+ fee: FeePolicy;
50
+ inputs: PlannedInput[];
51
+ outputs: AssetOutput[];
52
+ /**
53
+ * A native change output. The planner computes the fee from the final transaction
54
+ * shape and gives the change the rest; change below the dust limit is dropped and
55
+ * paid as fee. Without it the fee is whatever the outputs leave.
56
+ */
57
+ change?: TransactionChange;
58
+ };
59
+ export type TransactionChange = {
60
+ /** The change output's policy; flags 0. Its value is computed. */
61
+ output: Omit<AssetOutput, "value"> & {
62
+ value?: bigint;
63
+ };
64
+ /** Position among the outputs; defaults to the end. */
65
+ index?: number;
66
+ };
67
+ export type SignatureRequest = {
68
+ key: string;
69
+ argument: string;
70
+ /** The P01 mode byte; a wallet must show partial modes as such. */
71
+ mode: 0 | 1 | 2;
72
+ signingMode: Exclude<SigningMode, "ABSTAIN">;
73
+ /** The 32-byte message to sign with BIP340; the signer returns 64 bytes. */
74
+ digest: string;
75
+ inputIndex: number;
76
+ witnessIndex: number;
77
+ branchIndex?: number;
78
+ tokenId?: string;
79
+ positiveDelta?: bigint;
80
+ leaf: string;
81
+ feeAtoms: bigint;
82
+ };
83
+ declare const stages: {
84
+ readonly framing: "passed";
85
+ readonly proof: "passed";
86
+ readonly accounting: "passed";
87
+ readonly signature: "unavailable";
88
+ readonly invocation: "unavailable";
89
+ readonly contextual: "unavailable";
90
+ readonly block: "unavailable";
91
+ };
92
+ export type TransactionPlan = {
93
+ intent: TransactionIntent;
94
+ seal: string;
95
+ unsignedWire: Uint8Array;
96
+ projectedFullBytes: number;
97
+ txid: string;
98
+ feeAtoms: bigint;
99
+ /** The consensus floor (C14a, C14b). */
100
+ minimumFeeAtoms: bigint;
101
+ /** The floor the fee policy requires: the consensus floor or the cu share. */
102
+ requiredFeeAtoms: bigint;
103
+ maxFeeAtoms: bigint;
104
+ feeRequirement: FeeRequirement;
105
+ tokenDeltas: Record<string, bigint>;
106
+ tokenBurns: Record<string, bigint>;
107
+ requests: SignatureRequest[];
108
+ stages: typeof stages;
109
+ /** Where the planner put the change output in `intent.outputs`, or null. */
110
+ changeIndex: number | null;
111
+ };
112
+ export type TransactionFinal = {
113
+ wire: Uint8Array;
114
+ txid: string;
115
+ txhash: string;
116
+ stages: typeof stages;
117
+ };
118
+ export declare function encodeAssetOutput(o: AssetOutput): Uint8Array;
119
+ export declare function prepareTransactionCall(intent: TransactionIntent): TransactionPlan;
120
+ /**
121
+ * The fee the intent's final shape requires under its fee policy, without checking that
122
+ * the intent pays it. With `intent.change`, the change output is priced in place.
123
+ */
124
+ export declare function estimateTransactionCuAndFee(intent: TransactionIntent): FeeRequirement;
125
+ export type FeeSimulationResult = {
126
+ estimate: FeeRequirement;
127
+ changeOutputIndex: number;
128
+ totalNativeInputs: bigint;
129
+ nonChangeNativeOutputs: bigint;
130
+ requiredFeeAtoms: bigint;
131
+ feeAtoms: bigint;
132
+ changeValue: bigint;
133
+ adjustedOutputs: AssetOutput[];
134
+ adjustedIntent: TransactionIntent;
135
+ };
136
+ /**
137
+ * Set the value of an existing native output (by default the last native spendable one)
138
+ * so that the transaction pays exactly its required fee. Unlike `intent.change`, which
139
+ * drops change below the dust limit, this rejects it.
140
+ */
141
+ export declare function simulateFeeAndAdjustChange(intent: TransactionIntent, options?: {
142
+ changeOutputIndex?: number;
143
+ }): FeeSimulationResult;
144
+ export declare function finalizeTransactionCall(plan: TransactionPlan, signatures: Record<string, Uint8Array>): TransactionFinal;
145
+ export { APPROVED_COST_SCHEDULE, DEFAULT_MAX_FEE_MULTIPLE, MAX_MONEY, SPEC_FEE_PARAMETERS, byteFee, cuShareAtoms, feeRequirement, indexedByteFee, staticInvocationCu, type FieldSizes, linearCost, transactionCost, type CostSchedule, type FeeRule, type FeeParameters, type FeePolicy, type FeeRequirement, } from "./fees.js";
146
+ export type ContractSpendContext = Readonly<{
147
+ chainId: string;
148
+ prevTxid: string;
149
+ prevIndex: number;
150
+ /** Defaults to 0xffffffff (no relative lock). */
151
+ sequence?: number;
152
+ coin: AssetOutput;
153
+ /** The coin path to satisfy; defaults to 0. */
154
+ pathIndex?: number;
155
+ /** Witnesses for the path's other branches, in path order. */
156
+ companions?: readonly SelectedWitness[];
157
+ /** Other inputs, such as fee-paying wallet coins. */
158
+ otherInputs?: readonly PlannedInput[];
159
+ /** Position of the contract input among the inputs; defaults to 0. */
160
+ inputIndex?: number;
161
+ outputs: readonly AssetOutput[];
162
+ /** A change output; the planner then computes the fee and the change value. */
163
+ change?: TransactionChange;
164
+ lock?: bigint;
165
+ fee: FeePolicy;
166
+ }>;
167
+ export type ContractMintContext = Readonly<{
168
+ chainId: string;
169
+ /** The transaction's other inputs; at least one must consume a coin. */
170
+ inputs: readonly PlannedInput[];
171
+ /** Position of the mint input; defaults to the end. */
172
+ inputIndex?: number;
173
+ outputs: readonly AssetOutput[];
174
+ change?: TransactionChange;
175
+ lock?: bigint;
176
+ fee: FeePolicy;
177
+ }>;
178
+ type Artifact = SelectedWitness["artifact"];
179
+ export declare function contractSpendIntent(artifact: Artifact, methodName: string, context: ContractSpendContext, args: Record<string, WitnessValue>): TransactionIntent;
180
+ export declare function contractMintIntent(artifact: Artifact, methodName: string, context: ContractMintContext, args: Record<string, WitnessValue>): TransactionIntent;
181
+ /** True when the plan invokes `methodName` of `artifact` in some input. */
182
+ export declare function planInvokes(plan: TransactionPlan, artifact: Artifact, methodName: string): boolean;