@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,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;
|