@meshsdk/transaction 1.8.14 → 1.9.0-beta-39

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/dist/index.d.cts CHANGED
@@ -1,4 +1,13 @@
1
- import { Protocol, MintItem, TxIn, Withdrawal, Vote, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, Asset, BuilderData, LanguageVersion, Voter, VotingProcedure, PoolParams, Anchor, DRep, Metadatum, UTxO, UtxoSelectionStrategy, Network, Redeemer, Action, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, NativeScript, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
1
+ import { UTxO, TxOutput, Action, Protocol, MintItem, TxIn, Withdrawal, Vote, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, Asset, BuilderData, LanguageVersion, Voter, VotingProcedure, PoolParams, Anchor, DRep, Metadatum, Network, Redeemer, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, Certificate, MintParam, Output, NativeScript as NativeScript$1, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
2
+ import { NativeScript } from '@meshsdk/core-cst';
3
+
4
+ interface TransactionPrototype {
5
+ newInputs: Set<UTxO>;
6
+ newOutputs: Set<TxOutput>;
7
+ change: Array<TxOutput>;
8
+ fee: bigint;
9
+ redeemers?: Array<Omit<Action, 'data'>>;
10
+ }
2
11
 
3
12
  declare class MeshTxBuilderCore {
4
13
  txEvaluationMultiplier: number;
@@ -461,11 +470,8 @@ declare class MeshTxBuilderCore {
461
470
  /**
462
471
  * Selects utxos to fill output value and puts them into inputs
463
472
  * @param extraInputs The inputs already placed into the object will remain, these extra inputs will be used to fill the remaining value needed
464
- * @param strategy The strategy to be used in utxo selection
465
- * @param threshold Extra value needed to be selected for, usually for paying fees and min UTxO value of change output (default to 5000000)
466
- * @param includeTxFees Whether to include transaction fees in the threshold (default to true)
467
473
  */
468
- selectUtxosFrom: (extraInputs: UTxO[], strategy?: UtxoSelectionStrategy, threshold?: string, includeTxFees?: boolean) => this;
474
+ selectUtxosFrom: (extraInputs: UTxO[]) => this;
469
475
  /**
470
476
  * Set the protocol parameters to be used for the transaction other than the default one
471
477
  * @param params (Part of) the protocol parameters to be used for the transaction
@@ -484,6 +490,18 @@ declare class MeshTxBuilderCore {
484
490
  * @returns The MeshTxBuilder instance
485
491
  */
486
492
  setNetwork: (network: Network | number[][]) => this;
493
+ /**
494
+ * Add a transaction that is used as input, but not yet reflected on the global blockchain
495
+ * @param txHex The transaction hex of chained transaction
496
+ * @returns The MeshTxBuilderCore instance
497
+ */
498
+ chainTx(txHex: string): this;
499
+ /**
500
+ * Add a transaction input to provide information for offline evaluation
501
+ * @param input The input to be added
502
+ * @returns The MeshTxBuilderCore instance
503
+ */
504
+ inputForEvaluation(input: UTxO): this;
487
505
  protected queueAllLastItem: () => void;
488
506
  private queueInput;
489
507
  private queueMint;
@@ -494,11 +512,13 @@ declare class MeshTxBuilderCore {
494
512
  mem: number;
495
513
  steps: number;
496
514
  }) => Redeemer;
497
- protected updateRedeemer: (meshTxBuilderBody: MeshTxBuilderBody, txEvaluation: Omit<Action, "data">[]) => void;
515
+ protected updateRedeemer: (meshTxBuilderBody: MeshTxBuilderBody, txEvaluation: Omit<Action, "data">[], doNotUseMultiplier?: boolean) => void;
498
516
  addUtxosFromSelection: () => void;
499
517
  removeDuplicateInputs: () => void;
518
+ removeDuplicateRefInputs: () => void;
500
519
  emptyTxBuilderBody: () => () => MeshTxBuilderBody;
501
520
  reset: () => void;
521
+ protected _cloneCore<T extends MeshTxBuilderCore>(createInstance: () => T): T;
502
522
  }
503
523
 
504
524
  /**
@@ -523,24 +543,39 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
523
543
  submitter?: ISubmitter;
524
544
  evaluator?: IEvaluator;
525
545
  txHex: string;
546
+ verbose: boolean;
526
547
  protected queriedTxHashes: Set<string>;
527
548
  protected queriedUTxOs: {
528
549
  [x: string]: UTxO[];
529
550
  };
530
551
  protected utxosWithRefScripts: UTxO[];
531
552
  constructor({ serializer, fetcher, submitter, evaluator, params, isHydra, verbose, }?: MeshTxBuilderOptions);
553
+ serializeMockTx: () => string;
554
+ /**
555
+ * It builds the transaction query the blockchain for missing information
556
+ * @param customizedTx The optional customized transaction body
557
+ * @returns The transaction in hex, unbalanced
558
+ */
559
+ completeUnbalanced: (customizedTx?: MeshTxBuilderBody) => string;
560
+ completeSync: (customizedTx?: MeshTxBuilderBody) => string;
532
561
  /**
533
562
  * It builds the transaction and query the blockchain for missing information
534
563
  * @param customizedTx The optional customized transaction body
535
564
  * @returns The signed transaction in hex ready to submit / signed by client
536
565
  */
537
566
  complete: (customizedTx?: Partial<MeshTxBuilderBody>) => Promise<string>;
567
+ selectUtxos: () => Promise<TransactionPrototype>;
568
+ updateByTxPrototype: (selectionSkeleton: TransactionPrototype, final?: boolean) => Promise<void>;
569
+ getUtxosForSelection: () => Promise<UTxO[]>;
570
+ sortTxParts: () => void;
571
+ evaluateRedeemers: () => Promise<void>;
572
+ protected getRedeemerCosts: () => Omit<Action, "data">[];
538
573
  /**
539
574
  * It builds the transaction without dependencies
540
575
  * @param customizedTx The optional customized transaction body
541
- * @returns The signed transaction in hex ready to submit / signed by client
576
+ * @returns The transaction in hex, unbalanced
542
577
  */
543
- completeSync: (customizedTx?: MeshTxBuilderBody) => string;
578
+ completeUnbalancedSync: (customizedTx?: MeshTxBuilderBody) => string;
544
579
  /**
545
580
  * Complete the signing process
546
581
  * @returns The signed transaction in hex
@@ -557,7 +592,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
557
592
  * @param txHash The TxIn object that contains the txHash and txIndex, while missing amount and address information
558
593
  */
559
594
  protected getUTxOInfo: (txHash: string) => Promise<void>;
560
- protected queryAllTxInfo: (incompleteTxIns: TxIn[], incompleteMints: MintItem[]) => Promise<void[]>;
595
+ protected queryAllTxInfo: (incompleteTxIns: TxIn[], incompleteScriptSources: ScriptSource[], incompleteSimpleScriptSources: SimpleScriptSourceInfo[]) => Promise<void[]>;
561
596
  protected completeTxInformation: (input: TxIn) => void;
562
597
  protected completeInputInfo: (input: TxIn) => void;
563
598
  protected completeScriptInfo: (scriptSource: ScriptSource) => void;
@@ -566,16 +601,65 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
566
601
  protected isInputInfoComplete: (txIn: TxIn) => boolean;
567
602
  protected isMintComplete: (mint: MintItem) => boolean;
568
603
  protected isRefScriptInfoComplete: (scriptSource: ScriptSource) => boolean;
604
+ protected isSimpleRefScriptInfoComplete: (simpleScriptSource: SimpleScriptSourceInfo) => boolean;
605
+ protected completeSerialization: (customizedTx?: Partial<MeshTxBuilderBody>) => Promise<string>;
606
+ protected completeTxParts: () => Promise<void>;
607
+ protected collectAllRequiredSignatures: () => {
608
+ keyHashes: Set<string>;
609
+ byronAddresses: Set<string>;
610
+ };
611
+ protected getInputsRequiredSignatures(): {
612
+ paymentCreds: Set<string>;
613
+ byronAddresses: Set<string>;
614
+ };
615
+ protected getWithdrawalRequiredSignatures(): Set<string>;
616
+ protected getCertificatesRequiredSignatures(): Set<string>;
617
+ protected getVoteRequiredSignatures(): Set<string>;
618
+ protected getMintRequiredSignatures: () => Set<string>;
619
+ protected getTotalWithdrawal: () => bigint;
620
+ protected getTotalDeposit: () => bigint;
621
+ protected getTotalRefund: () => bigint;
622
+ protected getTotalMint: () => Asset[];
623
+ protected getNativeScriptPubKeys: (nativeScript: NativeScript) => Set<string>;
624
+ protected getVoteNativeScript: (cert: Vote) => NativeScript | undefined;
625
+ protected getCertificateNativeScript: (cert: Certificate) => NativeScript | undefined;
626
+ protected getMintNativeScript: (mint: MintParam) => NativeScript | undefined;
627
+ protected getWithdrawalNativeScript: (withdrawal: Withdrawal) => NativeScript | undefined;
628
+ protected getInputNativeScript(txIn: TxIn): NativeScript | undefined;
629
+ protected getInlinedNativeScript: (txHash: string, index: number) => NativeScript | undefined;
630
+ protected makeTxId: (txHash: string, index: number) => string;
631
+ protected getTotalReferenceInputsSize: () => bigint;
632
+ protected getAllReferenceInputsSizes: () => Map<string, bigint>;
633
+ protected getBodyReferenceInputsSizes: () => [string, bigint][];
634
+ protected getInputsReferenceInputsSizes: () => [string, bigint][];
635
+ protected getMintsReferenceInputsSizes: () => [string, bigint][];
636
+ protected getWithdrawalsReferenceInputsSizes: () => [string, bigint][];
637
+ protected getVotesReferenceInputsSizes: () => [string, bigint][];
638
+ protected getCertificatesReferenceInputsSizes: () => [string, bigint][];
639
+ getTotalExecutionUnits: () => {
640
+ memUnits: bigint;
641
+ stepUnits: bigint;
642
+ };
643
+ getSerializedSize: () => number;
644
+ calculateFee: () => bigint;
645
+ calculateFeeForSerializedTx: (txSize: number) => bigint;
646
+ calculateRefScriptFee: () => bigint;
647
+ calculateRedeemersFee: () => bigint;
648
+ calculateMinLovelaceForOutput: (output: Output) => bigint;
649
+ protected clone(): MeshTxBuilder;
569
650
  }
570
651
 
571
652
  declare class ForgeScript {
572
653
  static withOneSignature(address: string): string;
573
- static fromNativeScript(script: NativeScript): string;
654
+ static fromNativeScript(script: NativeScript$1): string;
574
655
  }
575
656
 
576
657
  interface TransactionOptions extends MeshTxBuilderOptions {
577
658
  initiator: IInitiator;
578
659
  }
660
+ /**
661
+ * Deprecated - Use `MeshTxBuilder` instead
662
+ */
579
663
  declare class Transaction {
580
664
  txBuilder: MeshTxBuilder;
581
665
  initiator: IInitiator;
@@ -587,7 +671,8 @@ declare class Transaction {
587
671
  static readMetadata(cborTx: string): string;
588
672
  static writeMetadata(cborTx: string, cborTxMetadata: string): string;
589
673
  /**
590
- * Adds an output to the transaction.
674
+ * [Deprecated] - `Transaction` class is on planning for V2.
675
+ * Use `MeshTxBuilder` instead for tx-building for now.
591
676
  *
592
677
  * @param recipient The recipient of the output.
593
678
  * @param assets The assets to send. Provide string for lovelace and Asset[] for tokens and/or lovelace.
@@ -596,7 +681,9 @@ declare class Transaction {
596
681
  */
597
682
  sendAssets(recipient: Recipient, assets: Asset[] | string): Transaction;
598
683
  /**
599
- * Suggest deprecated - Adds a transaction output to the transaction.
684
+ * [Deprecated] - `Transaction` class is on planning for V2.
685
+ * Use `MeshTxBuilder` instead for tx-building for now.
686
+ *
600
687
  * Use sendAssets instead:
601
688
  * ```ts
602
689
  * this.sendAssets(recipient, lovelace);
@@ -611,7 +698,9 @@ declare class Transaction {
611
698
  */
612
699
  sendLovelace(recipient: Recipient, lovelace: string): Transaction;
613
700
  /**
614
- * Suggest deprecated - Adds stable coins transaction output to the transaction.
701
+ * [Deprecated] - `Transaction` class is on planning for V2.
702
+ * Use `MeshTxBuilder` instead for tx-building for now.
703
+ *
615
704
  * Please use sendAssets with helper function to obtain token unit instead:
616
705
  * ```ts
617
706
  * const assets = [{ unit: SUPPORTED_TOKENS.GIMBAL, quantity: "100" }]
@@ -628,8 +717,8 @@ declare class Transaction {
628
717
  */
629
718
  sendToken(recipient: Recipient, ticker: Token, amount: string): Transaction;
630
719
  /**
631
- * Adds an output to the transaction.
632
- * Suggest deprecated - use sendAssets instead:
720
+ * [Deprecated] - `Transaction` class is on planning for V2.
721
+ * Use `MeshTxBuilder` instead for tx-building for now.
633
722
  *
634
723
  * ```ts
635
724
  * const assets = value.output.amount;
@@ -643,26 +732,35 @@ declare class Transaction {
643
732
  */
644
733
  sendValue(recipient: Recipient, value: UTxO): Transaction;
645
734
  /**
646
- * Sets the inputs for the transaction.
735
+ * [Deprecated] - `Transaction` class is on planning for V2.
736
+ * Use `MeshTxBuilder` instead for tx-building for now.
647
737
  *
648
738
  * @param {UTxO[]} inputs The inputs to set.
649
739
  * @returns {Transaction} The transaction.
650
740
  */
651
741
  setTxInputs(inputs: UTxO[]): Transaction;
652
742
  /**
653
- * Sets the reference inputs for the transaction.
743
+ * [Deprecated] - `Transaction` class is on planning for V2.
744
+ * Use `MeshTxBuilder` instead for tx-building for now.
654
745
  *
655
746
  * @param {UTxO[]} inputs The reference inputs to set.
656
747
  * @returns {Transaction} The transaction.
657
748
  */
658
749
  setTxRefInputs(inputs: UTxO[]): Transaction;
659
750
  /**
751
+ * [Deprecated] - `Transaction` class is on planning for V2.
752
+ * Use `MeshTxBuilder` instead for tx-building for now.
753
+ *
660
754
  * Sets the native script for the transaction.
661
755
  * @param {NativeScript} script The native script to spend from.
662
756
  * @param {UTxO} utxo The UTxO attached to the script.
663
757
  * @returns {Transaction} The Transaction object.
664
758
  */
665
- setNativeScriptInput(script: NativeScript, utxo: UTxO): Transaction;
759
+ setNativeScriptInput(script: NativeScript$1, utxo: UTxO): Transaction;
760
+ /**
761
+ * [Deprecated] - `Transaction` class is on planning for V2.
762
+ * Use `MeshTxBuilder` instead for tx-building for now.
763
+ */
666
764
  redeemValue(options: {
667
765
  value: UTxO;
668
766
  script: PlutusScript | UTxO;
@@ -671,13 +769,24 @@ declare class Transaction {
671
769
  };
672
770
  datum?: Data | UTxO;
673
771
  }): Transaction;
772
+ /**
773
+ * [Deprecated] - `Transaction` class is on planning for V2.
774
+ * Use `MeshTxBuilder` instead for tx-building for now.
775
+ */
674
776
  mintAsset(forgeScript: string | PlutusScript | UTxO, mint: Mint, redeemer?: Pick<Action, "data"> & {
675
777
  budget?: Budget;
676
778
  }): Transaction;
779
+ /**
780
+ * [Deprecated] - `Transaction` class is on planning for V2.
781
+ * Use `MeshTxBuilder` instead for tx-building for now.
782
+ */
677
783
  burnAsset(forgeScript: string | PlutusScript | UTxO, asset: Asset, redeemer?: Pick<Action, "data"> & {
678
784
  budget?: Budget;
679
785
  }): Transaction;
680
786
  /**
787
+ * [Deprecated] - `Transaction` class is on planning for V2.
788
+ * Use `MeshTxBuilder` instead for tx-building for now.
789
+ *
681
790
  * Sets the change address for the transaction.
682
791
  *
683
792
  * @param {string} changeAddress The change address.
@@ -685,6 +794,9 @@ declare class Transaction {
685
794
  */
686
795
  setChangeAddress(changeAddress: string): Transaction;
687
796
  /**
797
+ * [Deprecated] - `Transaction` class is on planning for V2.
798
+ * Use `MeshTxBuilder` instead for tx-building for now.
799
+ *
688
800
  * Sets the collateral for the transaction.
689
801
  *
690
802
  * @param {UTxO[]} collateral - Set the UTxO for collateral.
@@ -692,12 +804,18 @@ declare class Transaction {
692
804
  */
693
805
  setCollateral(collateral: UTxO[]): Transaction;
694
806
  /**
807
+ * [Deprecated] - `Transaction` class is on planning for V2.
808
+ * Use `MeshTxBuilder` instead for tx-building for now.
809
+ *
695
810
  * Sets the network to use, this is mainly to know the cost models to be used to calculate script integrity hash
696
811
  * @param network The specific network this transaction is being built for ("testnet" | "preview" | "preprod" | "mainnet")
697
812
  * @returns The Transaction object.
698
813
  */
699
814
  setNetwork: (network: Network) => this;
700
815
  /**
816
+ * [Deprecated] - `Transaction` class is on planning for V2.
817
+ * Use `MeshTxBuilder` instead for tx-building for now.
818
+ *
701
819
  * Sets the required signers for the transaction.
702
820
  *
703
821
  * @param {string[]} addresses The addresses of the required signers.
@@ -705,7 +823,10 @@ declare class Transaction {
705
823
  */
706
824
  setRequiredSigners(addresses: string[]): Transaction;
707
825
  /**
708
- * Set the time to live for the transaction.
826
+ * [Deprecated] - `Transaction` class is on planning for V2.
827
+ * Use `MeshTxBuilder` instead for tx-building for now.
828
+ *
829
+ * Set the time to live for the transaction.
709
830
  *
710
831
  * @param {string} slot The slot number to expire the transaction at.
711
832
  * @returns {Transaction} The Transaction object.
@@ -713,7 +834,10 @@ declare class Transaction {
713
834
  */
714
835
  setTimeToExpire(slot: string): Transaction;
715
836
  /**
716
- * Sets the start slot for the transaction.
837
+ * [Deprecated] - `Transaction` class is on planning for V2.
838
+ * Use `MeshTxBuilder` instead for tx-building for now.
839
+ *
840
+ * Sets the start slot for the transaction.
717
841
  *
718
842
  * @param {string} slot The start slot for the transaction.
719
843
  * @returns {Transaction} The Transaction object.
@@ -721,7 +845,10 @@ declare class Transaction {
721
845
  */
722
846
  setTimeToStart(slot: string): Transaction;
723
847
  /**
724
- * Add a JSON metadata entry to the transaction.
848
+ * [Deprecated] - `Transaction` class is on planning for V2.
849
+ * Use `MeshTxBuilder` instead for tx-building for now.
850
+ *
851
+ * Add a JSON metadata entry to the transaction.
725
852
  *
726
853
  * @param {number} label The label to use for the metadata entry.
727
854
  * @param {unknown} metadata The value to use for the metadata entry.
@@ -729,13 +856,37 @@ declare class Transaction {
729
856
  * @see {@link https://meshjs.dev/apis/transaction#setMetadata}
730
857
  */
731
858
  setMetadata(label: number, metadata: Metadatum | object): Transaction;
859
+ /**
860
+ * [Deprecated] - `Transaction` class is on planning for V2.
861
+ * Use `MeshTxBuilder` instead for tx-building for now.
862
+ */
732
863
  withdrawRewards(rewardAddress: string, lovelace: string): Transaction;
864
+ /**
865
+ * [Deprecated] - `Transaction` class is on planning for V2.
866
+ * Use `MeshTxBuilder` instead for tx-building for now.
867
+ */
733
868
  delegateStake(rewardAddress: string, poolId: string): Transaction;
869
+ /**
870
+ * [Deprecated] - `Transaction` class is on planning for V2.
871
+ * Use `MeshTxBuilder` instead for tx-building for now.
872
+ */
734
873
  deregisterStake(rewardAddress: string): Transaction;
874
+ /**
875
+ * [Deprecated] - `Transaction` class is on planning for V2.
876
+ * Use `MeshTxBuilder` instead for tx-building for now.
877
+ */
735
878
  registerStake(rewardAddress: string): Transaction;
879
+ /**
880
+ * [Deprecated] - `Transaction` class is on planning for V2.
881
+ * Use `MeshTxBuilder` instead for tx-building for now.
882
+ */
736
883
  registerPool(params: PoolParams): Transaction;
884
+ /**
885
+ * [Deprecated] - `Transaction` class is on planning for V2.
886
+ * Use `MeshTxBuilder` instead for tx-building for now.
887
+ */
737
888
  retirePool(poolId: string, epochNo: number): Transaction;
738
- build(): Promise<string>;
889
+ build(balanced?: Boolean): Promise<string>;
739
890
  protected mintPlutusScript(script: PlutusScript): MeshTxBuilder;
740
891
  protected spendingPlutusScript(script: PlutusScript): MeshTxBuilder;
741
892
  private addCollateralIfNeeded;