@hazbase/simplicity 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.
Files changed (43) hide show
  1. package/LICENSE +182 -0
  2. package/README.md +778 -0
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +628 -0
  5. package/dist/client/ContractFactory.d.ts +13 -0
  6. package/dist/client/ContractFactory.js +50 -0
  7. package/dist/client/DeployedContract.d.ts +12 -0
  8. package/dist/client/DeployedContract.js +43 -0
  9. package/dist/client/SimplicityClient.d.ts +21 -0
  10. package/dist/client/SimplicityClient.js +65 -0
  11. package/dist/core/artifact.d.ts +6 -0
  12. package/dist/core/artifact.js +100 -0
  13. package/dist/core/compiler.d.ts +3 -0
  14. package/dist/core/compiler.js +117 -0
  15. package/dist/core/errors.d.ts +33 -0
  16. package/dist/core/errors.js +70 -0
  17. package/dist/core/executor.d.ts +5 -0
  18. package/dist/core/executor.js +664 -0
  19. package/dist/core/presets.d.ts +16 -0
  20. package/dist/core/presets.js +251 -0
  21. package/dist/core/rpc.d.ts +7 -0
  22. package/dist/core/rpc.js +37 -0
  23. package/dist/core/summary.d.ts +6 -0
  24. package/dist/core/summary.js +27 -0
  25. package/dist/core/templating.d.ts +2 -0
  26. package/dist/core/templating.js +17 -0
  27. package/dist/core/toolchain.d.ts +14 -0
  28. package/dist/core/toolchain.js +82 -0
  29. package/dist/core/types.d.ts +258 -0
  30. package/dist/core/types.js +2 -0
  31. package/dist/gasless/RelayerClient.d.ts +13 -0
  32. package/dist/gasless/RelayerClient.js +76 -0
  33. package/dist/gasless/types.d.ts +144 -0
  34. package/dist/gasless/types.js +2 -0
  35. package/dist/index.d.ts +8 -0
  36. package/dist/index.js +35 -0
  37. package/dist/presets/htlc.simf.tmpl +35 -0
  38. package/dist/presets/manifest.d.ts +1 -0
  39. package/dist/presets/manifest.js +5 -0
  40. package/dist/presets/p2pk.simf.tmpl +4 -0
  41. package/dist/presets/p2pkLockHeight.simf.tmpl +5 -0
  42. package/dist/presets/transferWithTimeout.simf.tmpl +26 -0
  43. package/package.json +45 -0
@@ -0,0 +1,258 @@
1
+ export type NetworkName = "liquidtestnet" | "liquidv1" | "regtest";
2
+ export type UtxoPolicy = "smallest_over" | "largest" | "newest";
3
+ export interface RpcConfig {
4
+ url: string;
5
+ username: string;
6
+ password: string;
7
+ wallet?: string;
8
+ }
9
+ export interface ToolchainConfig {
10
+ simcPath: string;
11
+ halSimplicityPath: string;
12
+ elementsCliPath?: string;
13
+ }
14
+ export interface SimplicityClientConfig {
15
+ network: NetworkName;
16
+ rpc: RpcConfig;
17
+ toolchain: ToolchainConfig;
18
+ defaults?: {
19
+ feeSat?: number;
20
+ utxoPolicy?: UtxoPolicy;
21
+ };
22
+ relayer?: {
23
+ baseUrl: string;
24
+ apiKey?: string;
25
+ };
26
+ }
27
+ export interface ArtifactV5 {
28
+ version: 5;
29
+ createdAt: string;
30
+ simfTemplatePath?: string;
31
+ params?: {
32
+ minHeight?: number;
33
+ signerXonly?: string;
34
+ };
35
+ compiled?: {
36
+ program?: string;
37
+ cmr?: string;
38
+ internalKey?: string;
39
+ contractAddress?: string;
40
+ };
41
+ toolchain?: {
42
+ simcPath?: string;
43
+ halSimplicity?: string;
44
+ };
45
+ }
46
+ export interface SimplicityArtifact {
47
+ version: 6;
48
+ kind: "simplicity-artifact";
49
+ createdAt: string;
50
+ network: NetworkName;
51
+ source: {
52
+ mode: "file" | "preset";
53
+ simfPath?: string;
54
+ preset?: string;
55
+ templateVars?: Record<string, string | number>;
56
+ };
57
+ compiled: {
58
+ program: string;
59
+ cmr: string;
60
+ internalKey: string;
61
+ contractAddress: string;
62
+ };
63
+ toolchain: {
64
+ simcPath: string;
65
+ halSimplicity: string;
66
+ };
67
+ metadata: {
68
+ sdkVersion: string;
69
+ notes: string | null;
70
+ };
71
+ legacy?: {
72
+ simfTemplatePath?: string;
73
+ params?: {
74
+ minHeight?: number;
75
+ signerXonly?: string;
76
+ };
77
+ };
78
+ }
79
+ export type AnyArtifact = ArtifactV5 | SimplicityArtifact;
80
+ export interface CompileFromFileInput {
81
+ simfPath: string;
82
+ templateVars?: Record<string, string | number>;
83
+ artifactPath?: string;
84
+ }
85
+ export interface CompileFromPresetInput {
86
+ preset: string;
87
+ params: Record<string, string | number>;
88
+ artifactPath?: string;
89
+ }
90
+ export interface DeploymentInfo {
91
+ contractAddress: string;
92
+ internalKey: string;
93
+ cmr: string;
94
+ network: NetworkName;
95
+ instructions: string[];
96
+ }
97
+ export interface ContractUtxo {
98
+ txid: string;
99
+ vout: number;
100
+ scriptPubKey: string;
101
+ asset: string;
102
+ sat: number;
103
+ height?: number;
104
+ confirmed: boolean;
105
+ }
106
+ export interface SignerConfig {
107
+ type: "schnorrPrivkeyHex";
108
+ privkeyHex: string;
109
+ }
110
+ export interface WitnessValueInput {
111
+ type: string;
112
+ value: string;
113
+ }
114
+ export interface WitnessConfig {
115
+ source?: string;
116
+ values?: Record<string, WitnessValueInput>;
117
+ signers?: Record<string, SignerConfig>;
118
+ }
119
+ export interface CallBaseInput {
120
+ wallet: string;
121
+ toAddress: string;
122
+ sendAmount?: number;
123
+ feeSat?: number;
124
+ utxoPolicy?: UtxoPolicy;
125
+ signer?: SignerConfig;
126
+ expectedLiquidReceiver?: string;
127
+ purpose?: string;
128
+ periodId?: string;
129
+ bondDefinitionId?: string;
130
+ sequence?: number;
131
+ witness?: WitnessConfig;
132
+ }
133
+ export interface InspectCallInput extends CallBaseInput {
134
+ signer: SignerConfig;
135
+ }
136
+ export interface ExecuteCallInput extends CallBaseInput {
137
+ signer: SignerConfig;
138
+ broadcast?: boolean;
139
+ verbose?: boolean;
140
+ }
141
+ export interface SummaryOutput {
142
+ n: number;
143
+ value: number | null;
144
+ asset: string | null;
145
+ address: string | null;
146
+ scriptPubKeyHex: string | null;
147
+ isFee: boolean;
148
+ }
149
+ export interface PsetSummary {
150
+ network: string;
151
+ purpose?: string;
152
+ bondDefinitionId?: string | null;
153
+ periodId?: string | null;
154
+ contract: {
155
+ address: string;
156
+ cmr: string;
157
+ internalKey: string;
158
+ program: string;
159
+ minHeight?: number;
160
+ };
161
+ expectedLiquidReceiver?: string | null;
162
+ inputs: Array<{
163
+ txid: string | null;
164
+ vout: number | null;
165
+ sequence: number | null;
166
+ }>;
167
+ outputs: SummaryOutput[];
168
+ fee: unknown;
169
+ }
170
+ export interface InspectResult {
171
+ mode: "inspect";
172
+ summary: PsetSummary;
173
+ summaryHash: string;
174
+ summaryCanonicalJson: string;
175
+ psetBase64: string;
176
+ contractUtxo: ContractUtxo;
177
+ warnings: string[];
178
+ }
179
+ export interface ExecuteResult {
180
+ mode: "execute";
181
+ summary: PsetSummary;
182
+ summaryHash: string;
183
+ summaryCanonicalJson: string;
184
+ psetBase64: string;
185
+ rawTxHex: string;
186
+ txId?: string;
187
+ broadcasted: boolean;
188
+ contractUtxo: ContractUtxo;
189
+ }
190
+ export interface GaslessExecuteInput {
191
+ relayer?: import("../gasless/RelayerClient").RelayerClient;
192
+ fromLabel?: string;
193
+ wallet?: string;
194
+ sponsorWallet?: string;
195
+ toAddress: string;
196
+ signer: SignerConfig;
197
+ witness?: WitnessConfig;
198
+ sendAmount?: number;
199
+ feeSat?: number;
200
+ contractChangeAddress?: string;
201
+ sponsorChangeAddress?: string;
202
+ utxoPolicy?: UtxoPolicy;
203
+ broadcast?: boolean;
204
+ }
205
+ export interface GaslessExecuteResult {
206
+ mode: "gasless-execute";
207
+ summary: PsetSummary;
208
+ summaryHash: string;
209
+ summaryCanonicalJson: string;
210
+ psetBase64: string;
211
+ rawTxHex: string;
212
+ txId?: string;
213
+ broadcasted: boolean;
214
+ contractUtxo: ContractUtxo;
215
+ sponsorInput: {
216
+ txid: string;
217
+ vout: number;
218
+ amountSat: number;
219
+ };
220
+ }
221
+ export interface WaitForFundingInput {
222
+ minAmountSat?: number;
223
+ pollIntervalMs?: number;
224
+ timeoutMs?: number;
225
+ utxoPolicy?: UtxoPolicy;
226
+ }
227
+ export interface PresetManifestEntry {
228
+ id: string;
229
+ title: string;
230
+ description: string;
231
+ simfTemplatePath: string;
232
+ parameterSchema: Record<string, "string" | "number">;
233
+ witnessSchema?: Record<string, {
234
+ type: string;
235
+ signerAlias?: string;
236
+ description?: string;
237
+ }>;
238
+ exampleWitness?: {
239
+ signers?: Record<string, {
240
+ type: "schnorrPrivkeyHex";
241
+ privkeyHex: string;
242
+ }>;
243
+ values?: Record<string, {
244
+ type: string;
245
+ value: string;
246
+ }>;
247
+ };
248
+ executionProfile: {
249
+ witnessMode: "inlineSignature";
250
+ supportsGasless: boolean;
251
+ supportsDirectExecute: boolean;
252
+ supportsRelayerExecute: boolean;
253
+ requiredWitnessFields: string[];
254
+ defaultFeeSat: number;
255
+ recommendedUtxoPolicy: UtxoPolicy;
256
+ };
257
+ exampleParams: Record<string, string | number>;
258
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import { PsetStatusResult, RelayerClientConfig, RequestPsetInput, RequestPsetResult, RequestSimplicityExecutionInput, RequestSimplicityExecutionResult, SimplicityStatusResult, SubmitSignedPsetInput, SubmitSignedPsetResult, SubmitSimplicityExecutionInput, SubmitSimplicityExecutionResult } from "./types";
2
+ export declare class RelayerClient {
3
+ private readonly config;
4
+ constructor(config: RelayerClientConfig);
5
+ private headers;
6
+ private parseResponse;
7
+ requestPset(input: RequestPsetInput): Promise<RequestPsetResult>;
8
+ submitSignedPset(input: SubmitSignedPsetInput): Promise<SubmitSignedPsetResult>;
9
+ getPsetStatus(psetId: string): Promise<PsetStatusResult>;
10
+ requestSimplicityExecution(input: RequestSimplicityExecutionInput): Promise<RequestSimplicityExecutionResult>;
11
+ submitSimplicityExecution(input: SubmitSimplicityExecutionInput): Promise<SubmitSimplicityExecutionResult>;
12
+ getSimplicityStatus(requestId: string): Promise<SimplicityStatusResult>;
13
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelayerClient = void 0;
4
+ const errors_1 = require("../core/errors");
5
+ class RelayerClient {
6
+ config;
7
+ constructor(config) {
8
+ this.config = config;
9
+ }
10
+ headers() {
11
+ return {
12
+ "content-type": "application/json",
13
+ "x-api-key": this.config.apiKey,
14
+ };
15
+ }
16
+ async parseResponse(response) {
17
+ let payload = null;
18
+ try {
19
+ payload = await response.json();
20
+ }
21
+ catch {
22
+ payload = null;
23
+ }
24
+ if (!response.ok) {
25
+ throw new errors_1.RelayerError(payload?.error?.message ?? `Relayer request failed with status ${response.status}`, payload, response.status);
26
+ }
27
+ return payload;
28
+ }
29
+ async requestPset(input) {
30
+ const response = await fetch(`${this.config.baseUrl}/pset/request`, {
31
+ method: "POST",
32
+ headers: this.headers(),
33
+ body: JSON.stringify(input),
34
+ });
35
+ return this.parseResponse(response);
36
+ }
37
+ async submitSignedPset(input) {
38
+ const response = await fetch(`${this.config.baseUrl}/pset/submit`, {
39
+ method: "POST",
40
+ headers: this.headers(),
41
+ body: JSON.stringify(input),
42
+ });
43
+ return this.parseResponse(response);
44
+ }
45
+ async getPsetStatus(psetId) {
46
+ const response = await fetch(`${this.config.baseUrl}/pset/${psetId}`, {
47
+ method: "GET",
48
+ headers: this.headers(),
49
+ });
50
+ return this.parseResponse(response);
51
+ }
52
+ async requestSimplicityExecution(input) {
53
+ const response = await fetch(`${this.config.baseUrl}/simplicity/request`, {
54
+ method: "POST",
55
+ headers: this.headers(),
56
+ body: JSON.stringify(input),
57
+ });
58
+ return this.parseResponse(response);
59
+ }
60
+ async submitSimplicityExecution(input) {
61
+ const response = await fetch(`${this.config.baseUrl}/simplicity/submit`, {
62
+ method: "POST",
63
+ headers: this.headers(),
64
+ body: JSON.stringify(input),
65
+ });
66
+ return this.parseResponse(response);
67
+ }
68
+ async getSimplicityStatus(requestId) {
69
+ const response = await fetch(`${this.config.baseUrl}/simplicity/${requestId}`, {
70
+ method: "GET",
71
+ headers: this.headers(),
72
+ });
73
+ return this.parseResponse(response);
74
+ }
75
+ }
76
+ exports.RelayerClient = RelayerClient;
@@ -0,0 +1,144 @@
1
+ export interface RelayerClientConfig {
2
+ baseUrl: string;
3
+ apiKey: string;
4
+ }
5
+ export interface RequestPsetInput {
6
+ amount: number;
7
+ toAddress: string;
8
+ fromLabel: string;
9
+ }
10
+ export interface RequestPsetResult {
11
+ psetId: string;
12
+ psetBase64: string;
13
+ summary: {
14
+ assetId: string;
15
+ amountSat: number;
16
+ toAddress: string;
17
+ userInput: {
18
+ txid: string;
19
+ vout: number;
20
+ amountSat: number;
21
+ };
22
+ userChangeSat: number;
23
+ maxFeeSat: number;
24
+ expiresAt: string;
25
+ summaryHash: string;
26
+ };
27
+ }
28
+ export interface SubmitSignedPsetInput {
29
+ psetId: string;
30
+ signedPsetBase64: string;
31
+ }
32
+ export interface SubmitSignedPsetResult {
33
+ txId: string;
34
+ status: "BROADCASTED";
35
+ summaryHash: string;
36
+ broadcastAt: string;
37
+ }
38
+ export interface PsetStatusResult {
39
+ psetId: string;
40
+ status: string;
41
+ summaryHash: string;
42
+ expiresAt: string;
43
+ txId: string | null;
44
+ }
45
+ export interface GaslessTransferInput {
46
+ relayer?: import("./RelayerClient").RelayerClient;
47
+ amount: number;
48
+ toAddress: string;
49
+ fromLabel: string;
50
+ userWallet: string;
51
+ }
52
+ export interface GaslessTransferResult {
53
+ request: RequestPsetResult;
54
+ signedPsetBase64: string;
55
+ submit: SubmitSignedPsetResult;
56
+ }
57
+ export interface RequestSimplicityExecutionInput {
58
+ fromLabel: string;
59
+ artifact: {
60
+ compiled: {
61
+ program: string;
62
+ cmr: string;
63
+ internalKey: string;
64
+ contractAddress: string;
65
+ };
66
+ source: {
67
+ simfPath?: string;
68
+ templateVars?: Record<string, string | number>;
69
+ };
70
+ legacy?: {
71
+ params?: {
72
+ minHeight?: number;
73
+ };
74
+ };
75
+ network?: string;
76
+ };
77
+ toAddress: string;
78
+ sendAmount?: number;
79
+ feeSat?: number;
80
+ }
81
+ export interface RequestSimplicityExecutionResult {
82
+ requestId: string;
83
+ psetBase64: string;
84
+ summaryCanonicalJson: string;
85
+ detailedSummary: {
86
+ contract: {
87
+ program: string;
88
+ cmr: string;
89
+ internalKey: string;
90
+ contractAddress: string;
91
+ };
92
+ expectedReceiver: string;
93
+ inputs: Array<{
94
+ txid: string | null;
95
+ vout: number | null;
96
+ sequence: number | null;
97
+ }>;
98
+ outputs: Array<{
99
+ n: number;
100
+ amount: number | null;
101
+ asset: string | null;
102
+ scriptPubKeyHex: string | null;
103
+ address: string | null;
104
+ isFee: boolean;
105
+ }>;
106
+ fee: Record<string, number> | null;
107
+ locktime: number;
108
+ };
109
+ summary: {
110
+ toAddress: string;
111
+ sendAmountSat: number;
112
+ feeSat: number;
113
+ summaryHash: string;
114
+ expiresAt: string;
115
+ contractInput: {
116
+ txid: string;
117
+ vout: number;
118
+ amountSat: number;
119
+ };
120
+ sponsorInput: {
121
+ txid: string;
122
+ vout: number;
123
+ amountSat: number;
124
+ };
125
+ };
126
+ }
127
+ export interface SubmitSimplicityExecutionInput {
128
+ requestId: string;
129
+ signedPsetBase64: string;
130
+ }
131
+ export interface SubmitSimplicityExecutionResult {
132
+ txId: string;
133
+ status: "BROADCASTED";
134
+ summaryHash: string;
135
+ broadcastAt: string;
136
+ rawTxHex: string;
137
+ }
138
+ export interface SimplicityStatusResult {
139
+ requestId: string;
140
+ status: string;
141
+ summaryHash: string;
142
+ expiresAt: string;
143
+ txId: string | null;
144
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export { createSimplicityClient, SimplicityClient } from "./client/SimplicityClient";
2
+ export { CompiledContract } from "./client/ContractFactory";
3
+ export { DeployedContract } from "./client/DeployedContract";
4
+ export { RelayerClient } from "./gasless/RelayerClient";
5
+ export * from "./core/types";
6
+ export * from "./core/errors";
7
+ export { listPresets, getPresetOrThrow } from "./core/presets";
8
+ export { loadArtifact, saveArtifact, normalizeArtifact } from "./core/artifact";
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.normalizeArtifact = exports.saveArtifact = exports.loadArtifact = exports.getPresetOrThrow = exports.listPresets = exports.RelayerClient = exports.DeployedContract = exports.CompiledContract = exports.SimplicityClient = exports.createSimplicityClient = void 0;
18
+ var SimplicityClient_1 = require("./client/SimplicityClient");
19
+ Object.defineProperty(exports, "createSimplicityClient", { enumerable: true, get: function () { return SimplicityClient_1.createSimplicityClient; } });
20
+ Object.defineProperty(exports, "SimplicityClient", { enumerable: true, get: function () { return SimplicityClient_1.SimplicityClient; } });
21
+ var ContractFactory_1 = require("./client/ContractFactory");
22
+ Object.defineProperty(exports, "CompiledContract", { enumerable: true, get: function () { return ContractFactory_1.CompiledContract; } });
23
+ var DeployedContract_1 = require("./client/DeployedContract");
24
+ Object.defineProperty(exports, "DeployedContract", { enumerable: true, get: function () { return DeployedContract_1.DeployedContract; } });
25
+ var RelayerClient_1 = require("./gasless/RelayerClient");
26
+ Object.defineProperty(exports, "RelayerClient", { enumerable: true, get: function () { return RelayerClient_1.RelayerClient; } });
27
+ __exportStar(require("./core/types"), exports);
28
+ __exportStar(require("./core/errors"), exports);
29
+ var presets_1 = require("./core/presets");
30
+ Object.defineProperty(exports, "listPresets", { enumerable: true, get: function () { return presets_1.listPresets; } });
31
+ Object.defineProperty(exports, "getPresetOrThrow", { enumerable: true, get: function () { return presets_1.getPresetOrThrow; } });
32
+ var artifact_1 = require("./core/artifact");
33
+ Object.defineProperty(exports, "loadArtifact", { enumerable: true, get: function () { return artifact_1.loadArtifact; } });
34
+ Object.defineProperty(exports, "saveArtifact", { enumerable: true, get: function () { return artifact_1.saveArtifact; } });
35
+ Object.defineProperty(exports, "normalizeArtifact", { enumerable: true, get: function () { return artifact_1.normalizeArtifact; } });
@@ -0,0 +1,35 @@
1
+ fn sha2(string: u256) -> u256 {
2
+ let hasher: Ctx8 = jet::sha_256_ctx_8_init();
3
+ let hasher: Ctx8 = jet::sha_256_ctx_8_add_32(hasher, string);
4
+ jet::sha_256_ctx_8_finalize(hasher)
5
+ }
6
+
7
+ fn checksig(pk: Pubkey, sig: Signature) {
8
+ let msg: u256 = jet::sig_all_hash();
9
+ jet::bip_0340_verify((pk, msg), sig);
10
+ }
11
+
12
+ fn complete_spend(preimage: u256, recipient_sig: Signature) {
13
+ let hash: u256 = sha2(preimage);
14
+ let expected_hash: u256 = 0x{{EXPECTED_HASH}};
15
+ assert!(jet::eq_256(hash, expected_hash));
16
+ let recipient_pk: Pubkey = 0x{{RECIPIENT_XONLY}};
17
+ checksig(recipient_pk, recipient_sig);
18
+ }
19
+
20
+ fn cancel_spend(sender_sig: Signature) {
21
+ let timeout: Height = {{TIMEOUT_HEIGHT}};
22
+ jet::check_lock_height(timeout);
23
+ let sender_pk: Pubkey = 0x{{SENDER_XONLY}};
24
+ checksig(sender_pk, sender_sig)
25
+ }
26
+
27
+ fn main() {
28
+ match witness::COMPLETE_OR_CANCEL {
29
+ Left(preimage_sig: (u256, Signature)) => {
30
+ let (preimage, recipient_sig): (u256, Signature) = preimage_sig;
31
+ complete_spend(preimage, recipient_sig);
32
+ },
33
+ Right(sender_sig: Signature) => cancel_spend(sender_sig),
34
+ }
35
+ }
@@ -0,0 +1 @@
1
+ export { PRESET_MANIFEST } from "../core/presets";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PRESET_MANIFEST = void 0;
4
+ var presets_1 = require("../core/presets");
5
+ Object.defineProperty(exports, "PRESET_MANIFEST", { enumerable: true, get: function () { return presets_1.PRESET_MANIFEST; } });
@@ -0,0 +1,4 @@
1
+ fn main() {
2
+ let signer: Pubkey = 0x{{SIGNER_XONLY}};
3
+ jet::bip_0340_verify((signer, jet::sig_all_hash()), witness::SIGNER_SIGNATURE)
4
+ }
@@ -0,0 +1,5 @@
1
+ fn main() {
2
+ jet::check_lock_height({{MIN_HEIGHT}});
3
+ let signer: Pubkey = 0x{{SIGNER_XONLY}};
4
+ jet::bip_0340_verify((signer, jet::sig_all_hash()), witness::SIGNER_SIGNATURE)
5
+ }
@@ -0,0 +1,26 @@
1
+ fn checksig(pk: Pubkey, sig: Signature) {
2
+ let msg: u256 = jet::sig_all_hash();
3
+ jet::bip_0340_verify((pk, msg), sig);
4
+ }
5
+
6
+ fn transfer_spend(sender_sig: Signature, recipient_sig: Signature) {
7
+ let sender_pk: Pubkey = 0x{{SENDER_XONLY}};
8
+ checksig(sender_pk, sender_sig);
9
+ let recipient_pk: Pubkey = 0x{{RECIPIENT_XONLY}};
10
+ checksig(recipient_pk, recipient_sig);
11
+ }
12
+
13
+ fn timeout_spend(sender_sig: Signature) {
14
+ let sender_pk: Pubkey = 0x{{SENDER_XONLY}};
15
+ checksig(sender_pk, sender_sig);
16
+ let timeout: Height = {{TIMEOUT_HEIGHT}};
17
+ jet::check_lock_height(timeout);
18
+ }
19
+
20
+ fn main() {
21
+ let sender_sig: Signature = witness::SENDER_SIG;
22
+ match witness::TRANSFER_OR_TIMEOUT {
23
+ Some(recipient_sig: Signature) => transfer_spend(sender_sig, recipient_sig),
24
+ None => timeout_spend(sender_sig),
25
+ }
26
+ }
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@hazbase/simplicity",
3
+ "version": "0.0.1",
4
+ "description": "An SDK for Simplicity on Liquid",
5
+ "author": "IndieSquare Inc <info@hazbase.com>",
6
+ "keywords": [
7
+ "hazBase",
8
+ "backend",
9
+ "simplicity",
10
+ "liquid",
11
+ "bitcoin",
12
+ "sidechain",
13
+ "smart-contracts",
14
+ "sdk"
15
+ ],
16
+ "homepage": "https://lp.hazbase.com/",
17
+ "repository": "hazbase/simplicity",
18
+ "license": "Apache-2.0",
19
+ "main": "dist/index.js",
20
+ "types": "dist/index.d.ts",
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "!dist/test",
30
+ "README.md"
31
+ ],
32
+ "bin": {
33
+ "simplicity-cli": "dist/cli.js"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc && node scripts/copy-presets.mjs",
37
+ "start": "node dist/cli.js",
38
+ "test": "npm run build && node --test dist/test",
39
+ "e2e:simplicity-relayer": "npm run build && node scripts/e2e-simplicity-relayer.mjs"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^22.0.0",
43
+ "typescript": "^5.5.0"
44
+ }
45
+ }