@arkade-os/sdk 0.5.0-rc.2 → 0.5.0-rc.20
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 +90 -83
- package/dist/adapters/expo.cjs +5 -6
- package/dist/adapters/expo.d.cts +4 -4
- package/dist/adapters/expo.d.ts +4 -4
- package/dist/adapters/expo.js +3 -4
- package/dist/{asyncStorageTaskQueue-C5rBYlru.d.ts → asyncStorageTaskQueue-aL7K14e4.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-BuDvgWh6.d.cts → asyncStorageTaskQueue-x8ok3tJy.d.cts} +2 -2
- package/dist/{chunk-43FKNLX4.cjs → chunk-5SLUXXWQ.cjs} +357 -1114
- package/dist/chunk-5SLUXXWQ.cjs.map +1 -0
- package/dist/{chunk-HLCGYOIH.cjs → chunk-6YVGWOLG.cjs} +37 -36
- package/dist/chunk-6YVGWOLG.cjs.map +1 -0
- package/dist/{chunk-4PKLULWT.js → chunk-AARSVV3S.js} +109 -246
- package/dist/chunk-AARSVV3S.js.map +1 -0
- package/dist/{chunk-D25O4EGY.cjs → chunk-AFJSJACF.cjs} +12 -10
- package/dist/chunk-AFJSJACF.cjs.map +1 -0
- package/dist/{chunk-6DNR46C7.js → chunk-IM3J3T5P.js} +7 -5
- package/dist/chunk-IM3J3T5P.js.map +1 -0
- package/dist/{chunk-ISO4TI5J.js → chunk-NR4XYTN3.js} +566 -459
- package/dist/chunk-NR4XYTN3.js.map +1 -0
- package/dist/{chunk-ZRNQV6HV.js → chunk-O2ZZD5Z6.js} +4578 -4396
- package/dist/chunk-O2ZZD5Z6.js.map +1 -0
- package/dist/{chunk-ZOTXDOS5.js → chunk-P267BXL7.js} +30 -29
- package/dist/chunk-P267BXL7.js.map +1 -0
- package/dist/{chunk-NVZJSKZS.cjs → chunk-P42MGA4K.cjs} +121 -257
- package/dist/chunk-P42MGA4K.cjs.map +1 -0
- package/dist/{chunk-GMZZQXV5.cjs → chunk-QARA4IYT.cjs} +4961 -4767
- package/dist/chunk-QARA4IYT.cjs.map +1 -0
- package/dist/{chunk-JZWLXNHV.cjs → chunk-T6N6B7HK.cjs} +574 -464
- package/dist/chunk-T6N6B7HK.cjs.map +1 -0
- package/dist/{chunk-3R476TDV.js → chunk-TIVYJIIX.js} +293 -1071
- package/dist/chunk-TIVYJIIX.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -10
- package/dist/contracts/handlers/index.d.cts +5 -5
- package/dist/contracts/handlers/index.d.ts +5 -5
- package/dist/contracts/handlers/index.js +2 -3
- package/dist/{delegate-BAX5QftB.d.ts → delegate-BT5iON1T.d.ts} +1 -1
- package/dist/{delegate-1yp1HyP7.d.cts → delegate-u6kXTtWY.d.cts} +1 -1
- package/dist/index-BCnhItOQ.d.cts +639 -0
- package/dist/{index-DUxufw76.d.cts → index-CK5QbTmZ.d.cts} +1387 -2404
- package/dist/{index-DUxufw76.d.ts → index-CK5QbTmZ.d.ts} +1387 -2404
- package/dist/index-D1D4cR-G.d.ts +639 -0
- package/dist/index.cjs +375 -340
- package/dist/index.d.cts +784 -1197
- package/dist/index.d.ts +784 -1197
- package/dist/index.js +4 -5
- package/dist/repositories/realm/index.cjs +201 -106
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +28 -16
- package/dist/repositories/realm/index.d.ts +28 -16
- package/dist/repositories/realm/index.js +190 -95
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +301 -189
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +32 -21
- package/dist/repositories/sqlite/index.d.ts +32 -21
- package/dist/repositories/sqlite/index.js +294 -182
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-D_iPiZIi.d.ts → taskRunner-BeYR6NpQ.d.ts} +2 -2
- package/dist/{taskRunner-Dr3NStc0.d.cts → taskRunner-Csey3EYJ.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -15
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +10 -16
- package/dist/wallet/expo/background.d.ts +10 -16
- package/dist/wallet/expo/background.js +6 -7
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +16 -23
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +6 -9
- package/dist/wallet/expo/index.d.ts +6 -9
- package/dist/wallet/expo/index.js +8 -15
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/wallet-DG3Qmbmt.d.cts +1848 -0
- package/dist/wallet-DzSLMxBZ.d.ts +1848 -0
- package/dist/worker/expo/index.cjs +9 -10
- package/dist/worker/expo/index.cjs.map +1 -1
- package/dist/worker/expo/index.d.cts +6 -6
- package/dist/worker/expo/index.d.ts +6 -6
- package/dist/worker/expo/index.js +5 -6
- package/dist/worker/expo/index.js.map +1 -1
- package/package.json +12 -51
- package/dist/adapters/asyncStorage.cjs +0 -48
- package/dist/adapters/asyncStorage.cjs.map +0 -1
- package/dist/adapters/asyncStorage.d.cts +0 -16
- package/dist/adapters/asyncStorage.d.ts +0 -16
- package/dist/adapters/asyncStorage.js +0 -46
- package/dist/adapters/asyncStorage.js.map +0 -1
- package/dist/adapters/fileSystem.cjs +0 -116
- package/dist/adapters/fileSystem.cjs.map +0 -1
- package/dist/adapters/fileSystem.d.cts +0 -17
- package/dist/adapters/fileSystem.d.ts +0 -17
- package/dist/adapters/fileSystem.js +0 -93
- package/dist/adapters/fileSystem.js.map +0 -1
- package/dist/adapters/indexedDB.cjs +0 -103
- package/dist/adapters/indexedDB.cjs.map +0 -1
- package/dist/adapters/indexedDB.d.cts +0 -18
- package/dist/adapters/indexedDB.d.ts +0 -18
- package/dist/adapters/indexedDB.js +0 -101
- package/dist/adapters/indexedDB.js.map +0 -1
- package/dist/adapters/localStorage.cjs +0 -50
- package/dist/adapters/localStorage.cjs.map +0 -1
- package/dist/adapters/localStorage.d.cts +0 -14
- package/dist/adapters/localStorage.d.ts +0 -14
- package/dist/adapters/localStorage.js +0 -48
- package/dist/adapters/localStorage.js.map +0 -1
- package/dist/chunk-3R476TDV.js.map +0 -1
- package/dist/chunk-43FKNLX4.cjs.map +0 -1
- package/dist/chunk-4PKLULWT.js.map +0 -1
- package/dist/chunk-5BLDMQED.cjs +0 -18
- package/dist/chunk-5BLDMQED.cjs.map +0 -1
- package/dist/chunk-6DNR46C7.js.map +0 -1
- package/dist/chunk-D25O4EGY.cjs.map +0 -1
- package/dist/chunk-GMZZQXV5.cjs.map +0 -1
- package/dist/chunk-HLCGYOIH.cjs.map +0 -1
- package/dist/chunk-ISO4TI5J.js.map +0 -1
- package/dist/chunk-JZWLXNHV.cjs.map +0 -1
- package/dist/chunk-NSBPE2FW.js +0 -15
- package/dist/chunk-NSBPE2FW.js.map +0 -1
- package/dist/chunk-NVZJSKZS.cjs.map +0 -1
- package/dist/chunk-ZOTXDOS5.js.map +0 -1
- package/dist/chunk-ZRNQV6HV.js.map +0 -1
- package/dist/hdWalletCapable-CmEU0NP1.d.ts +0 -2232
- package/dist/hdWalletCapable-eJgaT-ec.d.cts +0 -2232
- package/dist/index-Bem5vKzX.d.ts +0 -850
- package/dist/index-C0IanN1m.d.cts +0 -11
- package/dist/index-C0IanN1m.d.ts +0 -11
- package/dist/index-W_oMcOmG.d.cts +0 -850
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
import { bv as ContractHandler, w as RelativeTimelock, bG as Discoverable, V as VtxoScript, x as TapLeafScript, dw as TapscriptDeriving } from './index-CK5QbTmZ.cjs';
|
|
2
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-u6kXTtWY.cjs';
|
|
3
|
+
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Registry for contract handlers.
|
|
7
|
+
*
|
|
8
|
+
* Each contract type ("default", "vhtlc", etc.) has a handler that knows
|
|
9
|
+
* how to create VtxoScripts, serialize params, and select spending paths.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Register a custom handler
|
|
14
|
+
* contractHandlers.register(myCustomHandler);
|
|
15
|
+
*
|
|
16
|
+
* // Get handler for a type
|
|
17
|
+
* const handler = contractHandlers.get("vhtlc");
|
|
18
|
+
* const script = handler.createScript(contract.params);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare class ContractHandlerRegistry {
|
|
22
|
+
private handlers;
|
|
23
|
+
/** @throws If a handler for this type is already registered */
|
|
24
|
+
register(handler: ContractHandler<unknown>): void;
|
|
25
|
+
get(type: string): ContractHandler<unknown> | undefined;
|
|
26
|
+
/** @throws If no handler is registered for this type */
|
|
27
|
+
getOrThrow(type: string): ContractHandler<unknown>;
|
|
28
|
+
has(type: string): boolean;
|
|
29
|
+
getRegisteredTypes(): string[];
|
|
30
|
+
/** Unregister a handler (mainly for testing). */
|
|
31
|
+
unregister(type: string): boolean;
|
|
32
|
+
/** Clear all handlers (mainly for testing). */
|
|
33
|
+
clear(): void;
|
|
34
|
+
}
|
|
35
|
+
/** Global registry of contract handlers. */
|
|
36
|
+
declare const contractHandlers: ContractHandlerRegistry;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Typed parameters for DefaultVtxo contracts.
|
|
40
|
+
*/
|
|
41
|
+
interface DefaultContractParams {
|
|
42
|
+
pubKey: Uint8Array;
|
|
43
|
+
serverPubKey: Uint8Array;
|
|
44
|
+
csvTimelock: RelativeTimelock;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Handler for default wallet VTXOs.
|
|
48
|
+
*
|
|
49
|
+
* Default contracts use the standard forfeit + exit tapscript:
|
|
50
|
+
* - forfeit: (Alice + Server) multisig for collaborative spending
|
|
51
|
+
* - exit: (Alice) + CSV timelock for unilateral exit
|
|
52
|
+
*/
|
|
53
|
+
declare const DefaultContractHandler: ContractHandler<DefaultContractParams, DefaultVtxo.Script> & Discoverable;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Typed parameters for DelegateVtxo contracts.
|
|
57
|
+
*/
|
|
58
|
+
interface DelegateContractParams {
|
|
59
|
+
pubKey: Uint8Array;
|
|
60
|
+
serverPubKey: Uint8Array;
|
|
61
|
+
delegatePubKey: Uint8Array;
|
|
62
|
+
csvTimelock: RelativeTimelock;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Handler for delegate wallet virtual outputs.
|
|
66
|
+
*
|
|
67
|
+
* Delegate contracts extend the default tapscript with an additional delegate path:
|
|
68
|
+
* - forfeit: (Alice + Server) multisig for collaborative spending
|
|
69
|
+
* - exit: (Alice) + CSV timelock for unilateral exit
|
|
70
|
+
* - delegate: (Alice + Delegate + Server) multisig for delegated renewal
|
|
71
|
+
*/
|
|
72
|
+
declare const DelegateContractHandler: ContractHandler<DelegateContractParams, DelegateVtxo.Script> & Discoverable;
|
|
73
|
+
|
|
74
|
+
/** Virtual Hash Time Lock Contract (VHTLC) namespace. */
|
|
75
|
+
declare namespace VHTLC {
|
|
76
|
+
export interface Options {
|
|
77
|
+
sender: Bytes;
|
|
78
|
+
receiver: Bytes;
|
|
79
|
+
server: Bytes;
|
|
80
|
+
preimageHash: Bytes;
|
|
81
|
+
refundLocktime: bigint;
|
|
82
|
+
unilateralClaimDelay: RelativeTimelock;
|
|
83
|
+
unilateralRefundDelay: RelativeTimelock;
|
|
84
|
+
unilateralRefundWithoutReceiverDelay: RelativeTimelock;
|
|
85
|
+
/**
|
|
86
|
+
* The emulator covenant leaves, ALL OR NOTHING. Adds three leaves the emulator co-signs
|
|
87
|
+
* under a covenant pinning the payout to a pre-committed destination:
|
|
88
|
+
*
|
|
89
|
+
* - `nonInteractiveClaim`: `server` + covenant-tweaked emulator, paying
|
|
90
|
+
* `receiverPkScript`; the claim can be pushed without the receiver online.
|
|
91
|
+
* - `nonInteractiveRefund`: `server` + `receiver` + covenant-tweaked emulator, paying
|
|
92
|
+
* `senderPkScript`, no timelock; recoverable even if the sender's key is lost.
|
|
93
|
+
* - `nonInteractiveRefundWithoutReceiver`: `server` + the SAME co-signer as
|
|
94
|
+
* `nonInteractiveRefund`, paying `senderPkScript` after `refundLocktime`; the only
|
|
95
|
+
* refund tier needing no participant signature.
|
|
96
|
+
*
|
|
97
|
+
* One flag, not one per leaf: nothing on the wire says which leaves a quote carries, so
|
|
98
|
+
* each optional leaf multiplies the tree shapes a counterparty must derive to verify an
|
|
99
|
+
* address. All-or-nothing keeps it at two.
|
|
100
|
+
*
|
|
101
|
+
* Leaf order fixes the merkle root: the suite is appended after the six signature leaves
|
|
102
|
+
* (claim, refund, timelocked refund), so a script with it NEVER collides with one without.
|
|
103
|
+
*
|
|
104
|
+
* STABLE PER RELEASE: a future covenant leaf joins only behind a NEW option, so
|
|
105
|
+
* re-deriving a lockup with the SDK that quoted it reproduces its address byte-for-byte.
|
|
106
|
+
*/
|
|
107
|
+
nonInteractiveParameters?: {
|
|
108
|
+
/**
|
|
109
|
+
* Emulator public key, 32-byte x-only or 33-byte compressed. ONE key, tweaked per
|
|
110
|
+
* covenant destination, co-signs every suite leaf; BIP-341 sighashes committing to
|
|
111
|
+
* the tapleaf hash keep a signature for one leaf from replaying against another.
|
|
112
|
+
*/
|
|
113
|
+
emulatorPubkey: Bytes;
|
|
114
|
+
/** Where the claim covenant pays: the receiver's P2TR pkScript, 34 bytes. */
|
|
115
|
+
receiverPkScript: Bytes;
|
|
116
|
+
/**
|
|
117
|
+
* Where BOTH refund covenants pay: the sender's P2TR pkScript, 34 bytes. Shared, so
|
|
118
|
+
* the two refund leaves cannot diverge.
|
|
119
|
+
*/
|
|
120
|
+
senderPkScript: Bytes;
|
|
121
|
+
/**
|
|
122
|
+
* LEGACY REBUILD ONLY, never for a new lockup. Builds the suite WITHOUT the
|
|
123
|
+
* timelocked refund leaf, the shape of lockups funded before it shipped; a leaf can't
|
|
124
|
+
* be retrofitted onto a committed address, so re-deriving those needs this.
|
|
125
|
+
*/
|
|
126
|
+
legacy?: "preTimelockedRefund";
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Denominate this contract in an Arkade ASSET. Only the covenant (non-interactive)
|
|
130
|
+
* leaves change; the signature leaves assert nothing about value.
|
|
131
|
+
*
|
|
132
|
+
* The covenants then also require the output to carry at least the input's amount of
|
|
133
|
+
* THIS asset and exactly one asset. The sat clause is RETAINED: dropping it would let a
|
|
134
|
+
* spend strip the sats, as the sat-only covenant lets a spend strip the asset.
|
|
135
|
+
*
|
|
136
|
+
* ONLY THE BOUND ASSET IS PROTECTED. `INSPECTOUTASSETCOUNT == 1` constrains only the
|
|
137
|
+
* covenant's output; arkd's conservation rule lets extra assets on the funding VTXO be
|
|
138
|
+
* routed to another output the spender chooses. Fund it with the named asset only.
|
|
139
|
+
*
|
|
140
|
+
* A canonical Asset ID is the pair `(genesis txid, group index)`, never a single blob.
|
|
141
|
+
*/
|
|
142
|
+
asset?: {
|
|
143
|
+
/**
|
|
144
|
+
* Genesis txid, 32 bytes, in CANONICAL order (the leading 32 bytes of a serialized
|
|
145
|
+
* Asset ID). Do not pre-reverse: the covenant reverses internally for the wire-order
|
|
146
|
+
* opcodes, and a pre-reversed id silently makes the covenant leaves unspendable.
|
|
147
|
+
*/
|
|
148
|
+
txid: Bytes;
|
|
149
|
+
/** The asset group index within that genesis transaction. */
|
|
150
|
+
groupIndex: number;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Shared construction for every VHTLC script version; versions differ only in the
|
|
155
|
+
* preimage-condition fragment `claim`/`unilateralClaim`/`nonInteractiveClaim` are built from.
|
|
156
|
+
*/
|
|
157
|
+
abstract class BaseScript extends VtxoScript {
|
|
158
|
+
readonly options: Options;
|
|
159
|
+
readonly claimScript: string;
|
|
160
|
+
readonly refundScript: string;
|
|
161
|
+
readonly refundWithoutReceiverScript: string;
|
|
162
|
+
readonly unilateralClaimScript: string;
|
|
163
|
+
readonly unilateralRefundScript: string;
|
|
164
|
+
readonly unilateralRefundWithoutReceiverScript: string;
|
|
165
|
+
readonly nonInteractiveClaimScript?: string;
|
|
166
|
+
readonly nonInteractiveClaimArkadeScript?: Bytes;
|
|
167
|
+
readonly nonInteractiveRefundScript?: string;
|
|
168
|
+
readonly nonInteractiveRefundArkadeScript?: Bytes;
|
|
169
|
+
readonly nonInteractiveRefundWithoutReceiverScript?: string;
|
|
170
|
+
readonly nonInteractiveRefundWithoutReceiverArkadeScript?: Bytes;
|
|
171
|
+
protected constructor(options: Options, preimageCondition: (hash: Bytes) => Bytes);
|
|
172
|
+
/** Return the collaborative claim tapleaf script. */
|
|
173
|
+
claim(): TapLeafScript;
|
|
174
|
+
/** Return the collaborative refund tapleaf script. */
|
|
175
|
+
refund(): TapLeafScript;
|
|
176
|
+
/** Return the refund-without-receiver tapleaf script. */
|
|
177
|
+
refundWithoutReceiver(): TapLeafScript;
|
|
178
|
+
/** Return the unilateral claim tapleaf script. */
|
|
179
|
+
unilateralClaim(): TapLeafScript;
|
|
180
|
+
/** Return the unilateral refund tapleaf script. */
|
|
181
|
+
unilateralRefund(): TapLeafScript;
|
|
182
|
+
/** Return the unilateral refund-without-receiver tapleaf script. */
|
|
183
|
+
unilateralRefundWithoutReceiver(): TapLeafScript;
|
|
184
|
+
/** Return the non-interactive claim tapleaf script as well as the ArkadeScript. */
|
|
185
|
+
nonInteractiveClaim(): [TapLeafScript, Bytes];
|
|
186
|
+
/** Return the non-interactive refund tapleaf script as well as the ArkadeScript. */
|
|
187
|
+
nonInteractiveRefund(): [TapLeafScript, Bytes];
|
|
188
|
+
/**
|
|
189
|
+
* Return the timelocked non-interactive refund tapleaf and its ArkadeScript.
|
|
190
|
+
*
|
|
191
|
+
* Spent through the generic covenant path ({@link EmulatorProvider},
|
|
192
|
+
* {@link ArkadeTransactionBuilder}): build the ark tx on this leaf plus its checkpoint;
|
|
193
|
+
* attach this ArkadeScript to the input in an `EmulatorPacket` (type 1, empty witness:
|
|
194
|
+
* the script pushes its own index with `PUSHCURRENTINPUTINDEX`) inside an `Extension`
|
|
195
|
+
* OP_RETURN; attach the input's creating ark tx as `PrevArkTx` (the emulator can't
|
|
196
|
+
* otherwise resolve its prevout); POST to the emulator's `/v1/tx`. The emulator co-signs
|
|
197
|
+
* for `nirCosigner` only if `enforcePayTo(senderPkScript)` holds, and finalizes with arkd.
|
|
198
|
+
* `server`'s signature is still required at consensus level, outside the covenant.
|
|
199
|
+
*
|
|
200
|
+
* The emulator does not check `refundLocktime`: it co-signs an immature spend and arkd's
|
|
201
|
+
* CLTV refuses it. arkd also refuses a block-height `refundLocktime`
|
|
202
|
+
* (< `CLTV_HEIGHT_THRESHOLD`, 500,000,000) on a forfeit-eligible leaf regardless of
|
|
203
|
+
* maturity: use a seconds-typed (Unix timestamp) value.
|
|
204
|
+
*/
|
|
205
|
+
nonInteractiveRefundWithoutReceiver(): [TapLeafScript, Bytes];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Virtual Hash Time Lock Contract (VHTLC) script implementation.
|
|
209
|
+
*
|
|
210
|
+
* VHTLC enables atomic swaps and conditional payments in the Arkade protocol.
|
|
211
|
+
* It provides multiple spending paths:
|
|
212
|
+
*
|
|
213
|
+
* - **claim**: Receiver can claim funds by revealing the preimage
|
|
214
|
+
* - **refund**: Sender and receiver can collaboratively refund
|
|
215
|
+
* - **refundWithoutReceiver**: Sender can refund after locktime expires
|
|
216
|
+
* - **unilateralClaim**: Receiver can claim unilaterally after delay
|
|
217
|
+
* - **unilateralRefund**: Sender and receiver can refund unilaterally after delay
|
|
218
|
+
* - **unilateralRefundWithoutReceiver**: Sender can refund unilaterally after delay
|
|
219
|
+
* - **nonInteractive\*** (with `nonInteractiveParameters`): emulator covenant leaves; see
|
|
220
|
+
* {@link VHTLC.Options.nonInteractiveParameters}
|
|
221
|
+
*
|
|
222
|
+
* Prefer {@link ScriptV2} (same leaves and options, plus a claim-preimage length check).
|
|
223
|
+
*
|
|
224
|
+
* **The `vhtlc` contract handler registers none of the covenant leaves**: its params carry
|
|
225
|
+
* no covenant fields, so a V1 script built with `nonInteractiveParameters` can be funded but
|
|
226
|
+
* not registered (`ContractManager` refuses the six-leaf script mismatch). Use the
|
|
227
|
+
* `vhtlc-v2` handler, which round-trips the suite.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const vhtlc = new VHTLC.Script({
|
|
232
|
+
* sender: alicePubKey,
|
|
233
|
+
* receiver: bobPubKey,
|
|
234
|
+
* server: serverPubKey,
|
|
235
|
+
* preimageHash: hash160(secret),
|
|
236
|
+
* refundLocktime: BigInt(chainTip + 10),
|
|
237
|
+
* unilateralClaimDelay: { type: 'blocks', value: 100n },
|
|
238
|
+
* unilateralRefundDelay: { type: 'blocks', value: 102n },
|
|
239
|
+
* unilateralRefundWithoutReceiverDelay: { type: 'blocks', value: 103n }
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
export class Script extends BaseScript {
|
|
244
|
+
constructor(options: Options);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* {@link Script} built with {@link preimageConditionScriptV2} for every preimage-gated leaf.
|
|
248
|
+
* A separate class rather than a flag: the two give different script bytes (so addresses)
|
|
249
|
+
* for the same keys, which should be a compile-time-visible choice.
|
|
250
|
+
*/
|
|
251
|
+
export class ScriptV2 extends BaseScript {
|
|
252
|
+
constructor(options: Options);
|
|
253
|
+
}
|
|
254
|
+
export { };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Typed parameters for VHTLC contracts. */
|
|
258
|
+
interface VHTLCContractParams {
|
|
259
|
+
sender: Uint8Array;
|
|
260
|
+
receiver: Uint8Array;
|
|
261
|
+
server: Uint8Array;
|
|
262
|
+
preimageHash: Uint8Array;
|
|
263
|
+
refundLocktime: bigint;
|
|
264
|
+
unilateralClaimDelay: RelativeTimelock;
|
|
265
|
+
unilateralRefundDelay: RelativeTimelock;
|
|
266
|
+
unilateralRefundWithoutReceiverDelay: RelativeTimelock;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Handler for Virtual Hash Time Lock Contract (VHTLC).
|
|
270
|
+
*
|
|
271
|
+
* VHTLC supports multiple spending paths:
|
|
272
|
+
*
|
|
273
|
+
* Collaborative paths (with server):
|
|
274
|
+
* - claim: Receiver + Server with preimage
|
|
275
|
+
* - refund: Sender + Receiver + Server
|
|
276
|
+
* - refundWithoutReceiver: Sender + Server after CLTV locktime
|
|
277
|
+
*
|
|
278
|
+
* Unilateral paths (without server):
|
|
279
|
+
* - unilateralClaim: Receiver with preimage after CSV delay
|
|
280
|
+
* - unilateralRefund: Sender + Receiver after CSV delay
|
|
281
|
+
* - unilateralRefundWithoutReceiver: Sender after CSV delay
|
|
282
|
+
*/
|
|
283
|
+
declare const VHTLCContractHandler: ContractHandler<VHTLCContractParams, VHTLC.Script> & TapscriptDeriving<VHTLC.Script>;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Typed parameters for {@link VHTLC.ScriptV2} contracts: `VHTLCContractParams` verbatim (both
|
|
287
|
+
* versions take the same {@link VHTLC.Options}), plus the asset and emulator covenant suite the
|
|
288
|
+
* swap corridor's lockup carries.
|
|
289
|
+
*/
|
|
290
|
+
interface VHTLCV2ContractParams {
|
|
291
|
+
sender: Uint8Array;
|
|
292
|
+
receiver: Uint8Array;
|
|
293
|
+
server: Uint8Array;
|
|
294
|
+
preimageHash: Uint8Array;
|
|
295
|
+
refundLocktime: bigint;
|
|
296
|
+
unilateralClaimDelay: RelativeTimelock;
|
|
297
|
+
unilateralRefundDelay: RelativeTimelock;
|
|
298
|
+
unilateralRefundWithoutReceiverDelay: RelativeTimelock;
|
|
299
|
+
/**
|
|
300
|
+
* The Arkade asset the covenant leaves bind, if any.
|
|
301
|
+
*
|
|
302
|
+
* @see VHTLC.Options.asset
|
|
303
|
+
*/
|
|
304
|
+
asset?: {
|
|
305
|
+
/** The asset's genesis txid, 32 bytes, canonical order — as the serialized Asset ID carries it. */
|
|
306
|
+
txid: Uint8Array;
|
|
307
|
+
/** The asset group index within that genesis transaction. */
|
|
308
|
+
groupIndex: number;
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* The emulator covenant suite, all or nothing — mirrors {@link
|
|
312
|
+
* VHTLC.Options.nonInteractiveParameters}, including `legacy: "preTimelockedRefund"` for
|
|
313
|
+
* eight-leaf rows funded before the timelocked refund leaf shipped.
|
|
314
|
+
*/
|
|
315
|
+
nonInteractiveParameters?: {
|
|
316
|
+
receiverPkScript: Uint8Array;
|
|
317
|
+
emulatorPubkey: Uint8Array;
|
|
318
|
+
senderPkScript: Uint8Array;
|
|
319
|
+
/** @see VHTLC.Options.nonInteractiveParameters.legacy */
|
|
320
|
+
legacy?: "preTimelockedRefund";
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Handler for {@link VHTLC.ScriptV2} — the VHTLC whose preimage leaves add `OP_SIZE 32
|
|
325
|
+
* OP_EQUALVERIFY`, built by the RFQ swap corridor (`@arkade-os/swap`'s `lightningSendContract`).
|
|
326
|
+
*
|
|
327
|
+
* A separate type rather than a flag on `vhtlc`: V1 and V2 derive different pkScripts for the same
|
|
328
|
+
* keys and `upsertContractRow` rejects a row whose script doesn't match its params, so one type
|
|
329
|
+
* can't serve both (and they can never collide). A use-named type (`swap-lockup`) loses because
|
|
330
|
+
* contracts are keyed by script: a second use of the same ScriptV2 would fight over one row.
|
|
331
|
+
*
|
|
332
|
+
* Only the four leaves a single-key wallet can sign are offered: `claim`/`unilateralClaim` to the
|
|
333
|
+
* receiver, `refundWithoutReceiver` (CLTV)/`unilateralRefundWithoutReceiver` to the sender.
|
|
334
|
+
* `refund`/`unilateralRefund` need the counterparty's signature and no protocol message asks for
|
|
335
|
+
* one; the three `nonInteractive*` leaves are the emulator's. CSV leaves are offered only in the
|
|
336
|
+
* non-collaborative context. Selection matches the `vhtlc` handler rung-for-rung, pinned by
|
|
337
|
+
* `test/contracts/vhtlcV2-handler.test.ts`.
|
|
338
|
+
*/
|
|
339
|
+
declare const VHTLCV2ContractHandler: ContractHandler<VHTLCV2ContractParams, VHTLC.ScriptV2> & TapscriptDeriving<VHTLC.ScriptV2>;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Typed parameters for boarding contracts: the `default` shape, with `csvTimelock` carrying the
|
|
343
|
+
* server's boarding-exit delay (`ArkadeInfo.boardingExitDelay`) instead of the unilateral-exit
|
|
344
|
+
* delay.
|
|
345
|
+
*/
|
|
346
|
+
type BoardingContractParams = DefaultContractParams;
|
|
347
|
+
/**
|
|
348
|
+
* Handler for the boarding contract (registered type `boarding`), which derives the on-chain
|
|
349
|
+
* address used to board funds. Same `DefaultVtxo.Script` shape and path logic as `default`; only
|
|
350
|
+
* the CSV differs (`boardingExitDelay` vs `unilateralExitDelay`).
|
|
351
|
+
*
|
|
352
|
+
* {@link Discoverable.discoverAt} probes the **on-chain** UTXO set at the P2TR address, not the
|
|
353
|
+
* Ark indexer, and no-ops when `deps.boardingTimelock` / `deps.onchainNetwork` are absent.
|
|
354
|
+
*
|
|
355
|
+
* Default/boarding collision: a script owns exactly one repository row. A sound server keeps
|
|
356
|
+
* boardingExitDelay > unilateralExitDelay (equal delays expose it to a double-spend); if they
|
|
357
|
+
* coincide the two scripts are byte-identical. Discovery still emits `type: "boarding"` and the
|
|
358
|
+
* row is resolved first-wins in {@link ContractManager.upsertContract}; the scan probes boarding
|
|
359
|
+
* first so a both-purpose rotated index keeps its on-chain UTXO and any L2 VTXO recoverable.
|
|
360
|
+
* Funds are spendable either way, but consumers must NOT identify boarding by
|
|
361
|
+
* `contract.type === "boarding"` — match by script via `wallet.getBoardingAddress()` /
|
|
362
|
+
* `wallet.boardingTapscript`.
|
|
363
|
+
*/
|
|
364
|
+
declare const BoardingContractHandler: ContractHandler<BoardingContractParams, DefaultVtxo.Script> & Discoverable;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Arkade Program model & compiler.
|
|
368
|
+
*
|
|
369
|
+
* A {@link Program} is the artifact shape shared with the ArkadeScript
|
|
370
|
+
* compiler: named functions, each split into a `tapscript` segment enforced
|
|
371
|
+
* on-chain and an optional `arkadeScript` segment emulated by the co-signing
|
|
372
|
+
* service. This module owns everything that is *pure data → script*:
|
|
373
|
+
*
|
|
374
|
+
* - the Program/segment/token types,
|
|
375
|
+
* - `$param` resolution ({@link resolveAsm}), witness and timelock resolution,
|
|
376
|
+
* - program validation ({@link validateProgram}) — typed constructor params
|
|
377
|
+
* are authoritative when present,
|
|
378
|
+
* - {@link ArkadeProgramScript} — a {@link VtxoScript} compiled from a
|
|
379
|
+
* program, its constructor args and the signer keys,
|
|
380
|
+
* - artifact JSON (de)serialization ({@link parseArtifact} /
|
|
381
|
+
* {@link stringifyArtifact}) and the string-keyed contract params used to
|
|
382
|
+
* persist a program contract through the `src/contracts` pipeline.
|
|
383
|
+
*
|
|
384
|
+
* Keeping this free of provider/transaction imports lets the generic
|
|
385
|
+
* `arkade` contract handler (src/contracts/handlers/arkade.ts) and the
|
|
386
|
+
* high-level `ArkadeContract` client share one compilation path.
|
|
387
|
+
*
|
|
388
|
+
* @module arkade/program
|
|
389
|
+
*/
|
|
390
|
+
|
|
391
|
+
/** A token in an `asm` array: an opcode name, a number/bigint push, raw bytes, or a `$param` placeholder. */
|
|
392
|
+
type AsmToken = string | number | bigint | Uint8Array;
|
|
393
|
+
/** A constructor argument or resolved value. */
|
|
394
|
+
type ArkadeParamValue = Uint8Array | bigint | number;
|
|
395
|
+
/** A function call argument (function input). */
|
|
396
|
+
type ArkadeArgValue = Uint8Array | bigint | number;
|
|
397
|
+
/**
|
|
398
|
+
* The declared type of a function input, used to derive the static TS type of
|
|
399
|
+
* the corresponding `functions.<name>(...)` argument. Byte-like types map to
|
|
400
|
+
* `Uint8Array`; `int` maps to `bigint | number`.
|
|
401
|
+
*/
|
|
402
|
+
type ArkadeArgType = "bytes" | "pubkey" | "sig" | "hash" | "int";
|
|
403
|
+
/**
|
|
404
|
+
* Maps an {@link ArkadeArgType} to its TypeScript argument type.
|
|
405
|
+
* @internal
|
|
406
|
+
*/
|
|
407
|
+
interface ArkadeValueType {
|
|
408
|
+
bytes: Uint8Array;
|
|
409
|
+
pubkey: Uint8Array;
|
|
410
|
+
sig: Uint8Array;
|
|
411
|
+
hash: Uint8Array;
|
|
412
|
+
int: bigint | number;
|
|
413
|
+
}
|
|
414
|
+
/** A typed function input or constructor param: a name plus its {@link ArkadeArgType}. */
|
|
415
|
+
interface InputDef {
|
|
416
|
+
name: string;
|
|
417
|
+
type: ArkadeArgType;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* A function input or constructor param declaration: either a typed descriptor
|
|
421
|
+
* `{ name, type }` (the argument is statically typed and its bound value is
|
|
422
|
+
* validated) or a bare name string (the argument falls back to the loose
|
|
423
|
+
* {@link ArkadeArgValue}).
|
|
424
|
+
*/
|
|
425
|
+
type InputRef = string | InputDef;
|
|
426
|
+
/** Constructor pubkey `$param` tweaked by `fn`'s covenant. */
|
|
427
|
+
interface TweakedSigner {
|
|
428
|
+
tweak: string;
|
|
429
|
+
fn: string;
|
|
430
|
+
}
|
|
431
|
+
/** A `"$param"` reference, literal x-only bytes, or a {@link TweakedSigner}. */
|
|
432
|
+
type SignerRef = string | Uint8Array | TweakedSigner;
|
|
433
|
+
/** A witness-stack item: a function-input name, a `"$param"`, a literal number/bigint (minimal script-num), or raw bytes. */
|
|
434
|
+
type WitnessRef = string | number | bigint | Uint8Array;
|
|
435
|
+
/** Bitcoin Script segment of a spending path — enforced on-chain. */
|
|
436
|
+
interface TapscriptSegment {
|
|
437
|
+
/**
|
|
438
|
+
* Required signers. A path with `arkadeScript` also appends the emulator
|
|
439
|
+
* co-signer, unless `emulator` is `null`.
|
|
440
|
+
*/
|
|
441
|
+
signers: SignerRef[];
|
|
442
|
+
/**
|
|
443
|
+
* Covenant named by `<EMULATOR_KEY:fn>`. `null` when this leaf belongs to a
|
|
444
|
+
* covenant but signs with a constructor-key tweak instead. Omitted on
|
|
445
|
+
* hand-written programs, which still append the co-signer.
|
|
446
|
+
*/
|
|
447
|
+
emulator?: string | null;
|
|
448
|
+
/**
|
|
449
|
+
* Optional standard-opcode condition (e.g. a hashlock), encoded into a
|
|
450
|
+
* ConditionMultisig leaf — or ConditionCSVMultisig when combined with `csv`.
|
|
451
|
+
*/
|
|
452
|
+
asm?: AsmToken[];
|
|
453
|
+
/**
|
|
454
|
+
* Relative timelock (CSV). The value is a literal or a `"$param"` reference
|
|
455
|
+
* resolved against the constructor args (same convention as {@link SignerRef}).
|
|
456
|
+
* `"blocks"` and `"seconds"` are counts; `"sequence"` is a raw BIP68
|
|
457
|
+
* sequence, which is what an `arkadec` CSV operand holds.
|
|
458
|
+
* Combinable with `asm` (condition + CSV); mutually exclusive with `cltv`.
|
|
459
|
+
*/
|
|
460
|
+
csv?: {
|
|
461
|
+
type: "blocks" | "seconds" | "sequence";
|
|
462
|
+
value: bigint | string;
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* Absolute timelock (CLTV): a literal or a `"$param"` reference.
|
|
466
|
+
* Mutually exclusive with `csv`/`asm`.
|
|
467
|
+
*/
|
|
468
|
+
cltv?: bigint | string;
|
|
469
|
+
/** Items satisfying the condition (e.g. an HTLC preimage); set via the ConditionWitness PSBT field. */
|
|
470
|
+
witness?: WitnessRef[];
|
|
471
|
+
}
|
|
472
|
+
/** Arkade Script segment of a spending path — emulated, bound via the key tweak. */
|
|
473
|
+
interface ArkadeSegment {
|
|
474
|
+
/** Raw Arkade opcodes with `$param` placeholders. */
|
|
475
|
+
asm: AsmToken[];
|
|
476
|
+
/** The arkade-script witness stack (e.g. an output index). */
|
|
477
|
+
witness?: WitnessRef[];
|
|
478
|
+
}
|
|
479
|
+
/** One named spending path. */
|
|
480
|
+
interface ArkadeFunction {
|
|
481
|
+
/**
|
|
482
|
+
* The function ABI: an ordered list of call arguments. Each entry is a typed
|
|
483
|
+
* descriptor `{ name, type }` (which gives the matching `functions.<name>`
|
|
484
|
+
* argument a precise static type) or a bare name string (loose
|
|
485
|
+
* {@link ArkadeArgValue}). Absent for nullary paths (e.g. exit/cancel).
|
|
486
|
+
*/
|
|
487
|
+
inputs?: readonly InputRef[];
|
|
488
|
+
tapscript: TapscriptSegment;
|
|
489
|
+
/** Present for covenant paths; absent for pure-tapscript paths (cancel/exit). */
|
|
490
|
+
arkadeScript?: ArkadeSegment;
|
|
491
|
+
}
|
|
492
|
+
declare const SUPPORTED_PROGRAM_VERSION = 0;
|
|
493
|
+
/** An Arkade contract program (hand-written or compiler-emitted). */
|
|
494
|
+
interface Program {
|
|
495
|
+
version: number;
|
|
496
|
+
/**
|
|
497
|
+
* Optional program name — metadata only: round-tripped through the
|
|
498
|
+
* artifact JSON, never used in compilation or the taproot tree.
|
|
499
|
+
*/
|
|
500
|
+
name?: string;
|
|
501
|
+
/**
|
|
502
|
+
* Ordered constructor parameters. Bare name strings are documentation only
|
|
503
|
+
* (the legacy hand-written form); typed descriptors `{ name, type }` make
|
|
504
|
+
* the list authoritative — see {@link validateProgram}.
|
|
505
|
+
*/
|
|
506
|
+
params?: readonly InputRef[];
|
|
507
|
+
functions: Record<string, ArkadeFunction>;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Resolve an `asm` array to bytes: substitute `$param` placeholders from `bind`,
|
|
511
|
+
* pass everything else (opcode names, numbers, raw byte pushes) through to the
|
|
512
|
+
* Arkade script encoder. The SDK does not interpret opcodes — this is pure
|
|
513
|
+
* substitution + encoding. To embed a signer key (server, user, or any
|
|
514
|
+
* other), pass it as a `$param` in the constructor args; there is no
|
|
515
|
+
* `<SERVER_KEY>`/`<COSIGNER_KEY>` token.
|
|
516
|
+
*/
|
|
517
|
+
declare function resolveAsm(asm: AsmToken[], bind: Record<string, ArkadeParamValue>): Uint8Array;
|
|
518
|
+
/**
|
|
519
|
+
* Resolve one witness-stack item to bytes.
|
|
520
|
+
*
|
|
521
|
+
* - raw bytes pass through;
|
|
522
|
+
* - numbers/bigints encode as minimal script-nums;
|
|
523
|
+
* - `"$param"` strings resolve against the program's constructor args;
|
|
524
|
+
* - any other string is a function-input name and resolves against `callArgs`
|
|
525
|
+
* (throws when the input is unbound — e.g. outside a function call).
|
|
526
|
+
*/
|
|
527
|
+
declare function witnessRefToBytes(ref: WitnessRef, callArgs: Record<string, ArkadeArgValue>, programArgs: Record<string, ArkadeParamValue>): Uint8Array;
|
|
528
|
+
/**
|
|
529
|
+
* Validate a program's constructor-parameter declarations against the bound
|
|
530
|
+
* args. A `params` list of bare name strings is documentation only (the
|
|
531
|
+
* legacy hand-written form — no checks). When at least one entry is a typed
|
|
532
|
+
* descriptor (the compiler-emitted form), the list is authoritative: every
|
|
533
|
+
* declared param must be bound in `args`, every `"$name"` reference in the
|
|
534
|
+
* program must be declared, and typed entries validate their bound value
|
|
535
|
+
* (bytes-like types require a Uint8Array — 32 bytes for `pubkey`, 64 for
|
|
536
|
+
* `sig`; `int` requires a bigint/number).
|
|
537
|
+
*/
|
|
538
|
+
declare function validateProgram(program: Program, args: Record<string, ArkadeParamValue>): void;
|
|
539
|
+
/** The signer keys a program is compiled against. */
|
|
540
|
+
interface ProgramKeys {
|
|
541
|
+
/** The Arkade Service signer key (x-only) — used for address derivation and collaborative-path detection, not for `$param` resolution. */
|
|
542
|
+
serverKey: Uint8Array;
|
|
543
|
+
/** The wallet's x-only key — identifies which inputs the wallet signs. */
|
|
544
|
+
userKey?: Uint8Array;
|
|
545
|
+
/** The co-signer (emulator) key — required only for covenant (`arkadeScript`) functions. */
|
|
546
|
+
emulatorKey?: Uint8Array;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* A single spending path, fully resolved at compilation: its definition, the
|
|
550
|
+
* committed leaf body, the per-path arkade-script bytes (covenant paths only),
|
|
551
|
+
* and the {@link TapLeafScript} (control block) for spending it.
|
|
552
|
+
*/
|
|
553
|
+
interface CompiledProgramFunction {
|
|
554
|
+
name: string;
|
|
555
|
+
def: ArkadeFunction;
|
|
556
|
+
/** The committed leaf script (body). */
|
|
557
|
+
leafScript: Uint8Array;
|
|
558
|
+
/** Resolved arkade-script bytes; undefined for pure-tapscript paths. */
|
|
559
|
+
arkadeScript?: Uint8Array;
|
|
560
|
+
/** Resolved signer keys (x-only), in the declared `signers` order. */
|
|
561
|
+
signerKeys: Uint8Array[];
|
|
562
|
+
/** Resolved once — the taproot leaf + control block for this path. */
|
|
563
|
+
tapLeafScript: TapLeafScript;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* A {@link VtxoScript} compiled from an Arkade {@link Program}, its
|
|
567
|
+
* constructor args and the signer keys.
|
|
568
|
+
*
|
|
569
|
+
* This is the single compilation path shared by the high-level
|
|
570
|
+
* `ArkadeContract` client and the `"arkade"` contract handler: both produce
|
|
571
|
+
* byte-identical taproot trees for the same (program, args, keys), so a
|
|
572
|
+
* contract registered through the `src/contracts` pipeline re-derives the
|
|
573
|
+
* exact script it was created with.
|
|
574
|
+
*/
|
|
575
|
+
declare class ArkadeProgramScript extends VtxoScript {
|
|
576
|
+
readonly program: Program;
|
|
577
|
+
readonly args: Record<string, ArkadeParamValue>;
|
|
578
|
+
readonly keys: ProgramKeys;
|
|
579
|
+
/** Spending paths in declaration order. */
|
|
580
|
+
readonly compiled: CompiledProgramFunction[];
|
|
581
|
+
constructor(program: Program, args: Record<string, ArkadeParamValue>, keys: ProgramKeys);
|
|
582
|
+
/** The compiled spending path with the given function name, if any. */
|
|
583
|
+
functionByName(name: string): CompiledProgramFunction | undefined;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Convert a Program JSON artifact into a {@link Program}. Byte values are
|
|
587
|
+
* encoded as `0x`-prefixed hex strings in `asm`/`witness`/`signers`; opcode names,
|
|
588
|
+
* `$param` placeholders and numbers pass through unchanged.
|
|
589
|
+
*
|
|
590
|
+
* This is *not* the JSON `arkadec` writes. That artifact lists spend groups in
|
|
591
|
+
* an array and uses `<param>` placeholders and raw leaf assembly; pass it to
|
|
592
|
+
* {@link programFromArtifact} instead.
|
|
593
|
+
*/
|
|
594
|
+
declare function parseArtifact(artifact: {
|
|
595
|
+
version?: number;
|
|
596
|
+
name?: string;
|
|
597
|
+
params?: readonly InputRef[];
|
|
598
|
+
functions: unknown;
|
|
599
|
+
}): Program;
|
|
600
|
+
/**
|
|
601
|
+
* Serialize a {@link Program} to compiler-artifact JSON — the inverse of
|
|
602
|
+
* {@link parseArtifact}: bytes become `0x`-hex strings; bigint tokens become
|
|
603
|
+
* plain numbers (or, above `Number.MAX_SAFE_INTEGER`, `0x`-hex of their
|
|
604
|
+
* minimal script-num bytes, which the script encoder pushes identically);
|
|
605
|
+
* literal timelock values serialize as decimal strings while `"$param"`
|
|
606
|
+
* timelock references are emitted as-is.
|
|
607
|
+
*/
|
|
608
|
+
declare function stringifyArtifact(program: Program): string;
|
|
609
|
+
/**
|
|
610
|
+
* Typed parameters of an `"arkade"` contract as persisted through the
|
|
611
|
+
* `src/contracts` pipeline. The program serializes as artifact JSON, args as
|
|
612
|
+
* a JSON map (`0x`-hex bytes, decimal-string bigints), keys as hex — so a
|
|
613
|
+
* stored contract row re-derives its script fully offline.
|
|
614
|
+
*/
|
|
615
|
+
interface ArkadeContractParams {
|
|
616
|
+
program: Program;
|
|
617
|
+
args: Record<string, ArkadeParamValue>;
|
|
618
|
+
serverKey: Uint8Array;
|
|
619
|
+
userKey?: Uint8Array;
|
|
620
|
+
emulatorKey?: Uint8Array;
|
|
621
|
+
}
|
|
622
|
+
/** Serialize {@link ArkadeContractParams} to the string map `Contract.params` requires. */
|
|
623
|
+
declare function serializeArkadeContractParams(typed: ArkadeContractParams): Record<string, string>;
|
|
624
|
+
/** Parse the string map persisted in `Contract.params` back into typed params. */
|
|
625
|
+
declare function deserializeArkadeContractParams(params: Record<string, string>): ArkadeContractParams;
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Generic handler for artifact/program-based Arkade contracts.
|
|
629
|
+
*
|
|
630
|
+
* Persists the full {@link ArkadeContractParams} (program artifact JSON, args,
|
|
631
|
+
* signer keys) as string params, so any contract created via
|
|
632
|
+
* `arkade.contract(program, args)` participates in the standard contract
|
|
633
|
+
* pipeline: ContractManager persistence and validation, watcher events,
|
|
634
|
+
* repository-backed balances, and offline script re-derivation. Rebuild a
|
|
635
|
+
* callable contract from a stored row with `ArkadeContract.fromContract`.
|
|
636
|
+
*/
|
|
637
|
+
declare const ArkadeContractHandler: ContractHandler<ArkadeContractParams, ArkadeProgramScript> & TapscriptDeriving<ArkadeProgramScript>;
|
|
638
|
+
|
|
639
|
+
export { type ArkadeParamValue as A, BoardingContractHandler as B, type CompiledProgramFunction as C, DefaultContractHandler as D, VHTLCV2ContractHandler as E, type VHTLCV2ContractParams as F, contractHandlers as G, type InputRef as I, type Program as P, SUPPORTED_PROGRAM_VERSION as S, type TapscriptSegment as T, VHTLC as V, type WitnessRef as W, ArkadeProgramScript as a, type ProgramKeys as b, type ArkadeArgValue as c, type ArkadeFunction as d, type InputDef as e, type ArkadeValueType as f, type ArkadeArgType as g, type ArkadeContractParams as h, type ArkadeSegment as i, type AsmToken as j, type SignerRef as k, type TweakedSigner as l, deserializeArkadeContractParams as m, stringifyArtifact as n, ArkadeContractHandler as o, parseArtifact as p, type BoardingContractParams as q, resolveAsm as r, serializeArkadeContractParams as s, type DefaultContractParams as t, DelegateContractHandler as u, validateProgram as v, witnessRefToBytes as w, type DelegateContractParams as x, VHTLCContractHandler as y, type VHTLCContractParams as z };
|