@@ -255,6 +255,7 @@ declare export var NativeScriptKind: {|
255
255
256
256
declare export var ScriptHashNamespace: {|
257
257
+NativeScript: 0, // 0
258
+ +PlutusScript: 1, // 1
258
259
|};
259
260
260
261
/**
@@ -2773,10 +2774,9 @@ declare export class NativeScript {
2773
2774
static from_bytes(bytes: Uint8Array): NativeScript;
2774
2775
2775
2776
/**
2776
- * @param {number} namespace
2777
2777
* @returns {ScriptHash}
2778
2778
*/
2779
- hash(namespace: number ): ScriptHash;
2779
+ hash(): ScriptHash;
2780
2780
2781
2781
/**
2782
2782
* @param {ScriptPubkey} script_pubkey
@@ -3218,6 +3218,11 @@ declare export class PlutusScript {
3218
3218
* @returns {Uint8Array}
3219
3219
*/
3220
3220
bytes(): Uint8Array;
3221
+
3222
+ /**
3223
+ * @returns {ScriptHash}
3224
+ */
3225
+ hash(): ScriptHash;
3221
3226
}
3222
3227
/**
3223
3228
*/
@@ -3256,6 +3261,64 @@ declare export class PlutusScripts {
3256
3261
*/
3257
3262
add(elem: PlutusScript): void;
3258
3263
}
3264
+ /**
3265
+ */
3266
+ declare export class PlutusWitness {
3267
+ free(): void;
3268
+
3269
+ /**
3270
+ * @param {PlutusScript} script
3271
+ * @param {PlutusData} datum
3272
+ * @param {Redeemer} redeemer
3273
+ * @returns {PlutusWitness}
3274
+ */
3275
+ static new(
3276
+ script: PlutusScript,
3277
+ datum: PlutusData,
3278
+ redeemer: Redeemer
3279
+ ): PlutusWitness;
3280
+
3281
+ /**
3282
+ * @returns {PlutusScript}
3283
+ */
3284
+ script(): PlutusScript;
3285
+
3286
+ /**
3287
+ * @returns {PlutusData}
3288
+ */
3289
+ datum(): PlutusData;
3290
+
3291
+ /**
3292
+ * @returns {Redeemer}
3293
+ */
3294
+ redeemer(): Redeemer;
3295
+ }
3296
+ /**
3297
+ */
3298
+ declare export class PlutusWitnesses {
3299
+ free(): void;
3300
+
3301
+ /**
3302
+ * @returns {PlutusWitnesses}
3303
+ */
3304
+ static new(): PlutusWitnesses;
3305
+
3306
+ /**
3307
+ * @returns {number}
3308
+ */
3309
+ len(): number;
3310
+
3311
+ /**
3312
+ * @param {number} index
3313
+ * @returns {PlutusWitness}
3314
+ */
3315
+ get(index: number): PlutusWitness;
3316
+
3317
+ /**
3318
+ * @param {PlutusWitness} elem
3319
+ */
3320
+ add(elem: PlutusWitness): void;
3321
+ }
3259
3322
/**
3260
3323
*/
3261
3324
declare export class Pointer {
@@ -5244,6 +5307,13 @@ declare export class TransactionBuilder {
5244
5307
): void;
5245
5308
5246
5309
/**
5310
+ * This method adds the input to the builder BUT leaves a missing spot for the witness native script
5311
+ *
5312
+ * After adding the input with this method, use `.add_required_native_input_scripts`
5313
+ * and `.add_required_plutus_input_scripts` to add the witness scripts
5314
+ *
5315
+ * Or instead use `.add_native_script_input` and `.add_plutus_script_input`
5316
+ * to add inputs right along with the script, instead of the script hash
5247
5317
* @param {ScriptHash} hash
5248
5318
* @param {TransactionInput} input
5249
5319
* @param {Value} amount
@@ -5254,6 +5324,30 @@ declare export class TransactionBuilder {
5254
5324
amount: Value
5255
5325
): void;
5256
5326
5327
+ /**
5328
+ * This method will add the input to the builder and also register the required native script witness
5329
+ * @param {NativeScript} script
5330
+ * @param {TransactionInput} input
5331
+ * @param {Value} amount
5332
+ */
5333
+ add_native_script_input(
5334
+ script: NativeScript,
5335
+ input: TransactionInput,
5336
+ amount: Value
5337
+ ): void;
5338
+
5339
+ /**
5340
+ * This method will add the input to the builder and also register the required plutus witness
5341
+ * @param {PlutusWitness} witness
5342
+ * @param {TransactionInput} input
5343
+ * @param {Value} amount
5344
+ */
5345
+ add_plutus_script_input(
5346
+ witness: PlutusWitness,
5347
+ input: TransactionInput,
5348
+ amount: Value
5349
+ ): void;
5350
+
5257
5351
/**
5258
5352
* @param {ByronAddress} hash
5259
5353
* @param {TransactionInput} input
@@ -5266,12 +5360,55 @@ declare export class TransactionBuilder {
5266
5360
): void;
5267
5361
5268
5362
/**
5363
+ * Note that for script inputs this method will use underlying generic `.add_script_input`
5364
+ * which leaves a required empty spot for the script witness (or witnesses in case of Plutus).
5365
+ * You can use `.add_native_script_input` or `.add_plutus_script_input` directly to register the input along with the witness.
5269
5366
* @param {Address} address
5270
5367
* @param {TransactionInput} input
5271
5368
* @param {Value} amount
5272
5369
*/
5273
5370
add_input(address: Address, input: TransactionInput, amount: Value): void;
5274
5371
5372
+ /**
5373
+ * Returns the number of still missing input scripts (either native or plutus)
5374
+ * Use `.add_required_native_input_scripts` or `.add_required_plutus_input_scripts` to add the missing scripts
5375
+ * @returns {number}
5376
+ */
5377
+ count_missing_input_scripts(): number;
5378
+
5379
+ /**
5380
+ * Try adding the specified scripts as witnesses for ALREADY ADDED script inputs
5381
+ * Any scripts that don't match any of the previously added inputs will be ignored
5382
+ * Returns the number of remaining required missing witness scripts
5383
+ * Use `.count_missing_input_scripts` to find the number of still missing scripts
5384
+ * @param {NativeScripts} scripts
5385
+ * @returns {number}
5386
+ */
5387
+ add_required_native_input_scripts(scripts: NativeScripts): number;
5388
+
5389
+ /**
5390
+ * Try adding the specified scripts as witnesses for ALREADY ADDED script inputs
5391
+ * Any scripts that don't match any of the previously added inputs will be ignored
5392
+ * Returns the number of remaining required missing witness scripts
5393
+ * Use `.count_missing_input_scripts` to find the number of still missing scripts
5394
+ * @param {PlutusWitnesses} scripts
5395
+ * @returns {number}
5396
+ */
5397
+ add_required_plutus_input_scripts(scripts: PlutusWitnesses): number;
5398
+
5399
+ /**
5400
+ * Returns a copy of the current script input witness scripts in the builder
5401
+ * @returns {NativeScripts | void}
5402
+ */
5403
+ get_native_input_scripts(): NativeScripts | void;
5404
+
5405
+ /**
5406
+ * Returns a copy of the current plutus input witness scripts in the builder.
5407
+ * NOTE: each plutus witness will be cloned with a specific corresponding input index
5408
+ * @returns {PlutusWitnesses | void}
5409
+ */
5410
+ get_plutus_input_scripts(): PlutusWitnesses | void;
5411
+
5275
5412
/**
5276
5413
* calculates how much the fee would increase if you added a given output
5277
5414
* @param {Address} address
@@ -5522,6 +5659,31 @@ declare export class TransactionBuilder {
5522
5659
*/
5523
5660
add_change_if_needed(address: Address): boolean;
5524
5661
5662
+ /**
5663
+ * This method will calculate the script hash data
5664
+ * using the plutus datums and redeemers already present in the builder
5665
+ * along with the provided cost model, and will register the calculated value
5666
+ * in the builder to be used when building the tx body.
5667
+ * In case there are no plutus input witnesses present - nothing will change
5668
+ * You can set specific hash value using `.set_script_data_hash`
5669
+ * @param {Costmdls} cost_models
5670
+ */
5671
+ calc_script_data_hash(cost_models: Costmdls): void;
5672
+
5673
+ /**
5674
+ * Sets the specified hash value.
5675
+ * Alternatively you can use `.calc_script_data_hash` to calculate the hash automatically.
5676
+ * Or use `.remove_script_data_hash` to delete the previously set value
5677
+ * @param {ScriptDataHash} hash
5678
+ */
5679
+ set_script_data_hash(hash: ScriptDataHash): void;
5680
+
5681
+ /**
5682
+ * Deletes any previously set plutus data hash value.
5683
+ * Use `.set_script_data_hash` or `.calc_script_data_hash` to set it.
5684
+ */
5685
+ remove_script_data_hash(): void;
5686
+
5525
5687
/**
5526
5688
* @returns {number}
5527
5689
*/
@@ -5544,10 +5706,17 @@ declare export class TransactionBuilder {
5544
5706
* Returns full Transaction object with the body and the auxiliary data
5545
5707
* NOTE: witness_set will contain all mint_scripts if any been added or set
5546
5708
* NOTE: is_valid set to true
5709
+ * NOTE: Will fail in case there are any script inputs added with no corresponding witness
5547
5710
* @returns {Transaction}
5548
5711
*/
5549
5712
build_tx(): Transaction;
5550
5713
5714
+ /**
5715
+ * Similar to `.build_tx()` but will NOT fail in case there are missing script witnesses
5716
+ * @returns {Transaction}
5717
+ */
5718
+ build_tx_unsafe(): Transaction;
5719
+
5551
5720
/**
5552
5721
* warning: sum of all parts of a transaction must equal 0. You cannot just set the fee to the min value and forget about it
5553
5722
* warning: min_fee may be slightly larger than the actual minimum fee (ex: a few lovelaces)
@@ -6167,6 +6336,16 @@ declare export class TransactionWitnessSets {
6167
6336
*/
6168
6337
add(elem: TransactionWitnessSet): void;
6169
6338
}
6339
+ /**
6340
+ */
6341
+ declare export class TxBuilderConstants {
6342
+ free(): void;
6343
+
6344
+ /**
6345
+ * @returns {Costmdls}
6346
+ */
6347
+ static plutus_default_cost_models(): Costmdls;
6348
+ }
6170
6349
/**
6171
6350
*/
6172
6351
declare export class URL {
0 commit comments