@meshsdk/transaction 1.7.7 → 1.7.9
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.cjs +180 -1
- package/dist/index.d.cts +61 -2
- package/dist/index.d.ts +61 -2
- package/dist/index.js +180 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -52,10 +52,13 @@ var MeshTxBuilderCore = class {
|
|
|
52
52
|
plutusMintingScriptVersion;
|
|
53
53
|
addingPlutusWithdrawal = false;
|
|
54
54
|
plutusWithdrawalScriptVersion;
|
|
55
|
+
addingPlutusVote = false;
|
|
56
|
+
plutusVoteScriptVersion;
|
|
55
57
|
_protocolParams = import_common.DEFAULT_PROTOCOL_PARAMETERS;
|
|
56
58
|
mintItem;
|
|
57
59
|
txInQueueItem;
|
|
58
60
|
withdrawalItem;
|
|
61
|
+
voteItem;
|
|
59
62
|
collateralQueueItem;
|
|
60
63
|
refScriptTxInQueueItem;
|
|
61
64
|
meshTxBuilderBody;
|
|
@@ -661,7 +664,7 @@ var MeshTxBuilderCore = class {
|
|
|
661
664
|
return this;
|
|
662
665
|
};
|
|
663
666
|
/**
|
|
664
|
-
* Set the instruction that it is currently using
|
|
667
|
+
* Set the instruction that it is currently using a Plutus withdrawal scripts
|
|
665
668
|
* @returns The MeshTxBuilder instance
|
|
666
669
|
*/
|
|
667
670
|
withdrawalPlutusScriptV1 = () => {
|
|
@@ -789,6 +792,158 @@ var MeshTxBuilderCore = class {
|
|
|
789
792
|
);
|
|
790
793
|
return this;
|
|
791
794
|
};
|
|
795
|
+
/**
|
|
796
|
+
* Set the instruction that it is currently using a Plutus voting scripts
|
|
797
|
+
* @param languageVersion The Plutus script version
|
|
798
|
+
* @returns The MeshTxBuilder instance
|
|
799
|
+
*/
|
|
800
|
+
votePlutusScript = (languageVersion) => {
|
|
801
|
+
this.addingPlutusVote = true;
|
|
802
|
+
this.plutusVoteScriptVersion = languageVersion;
|
|
803
|
+
return this;
|
|
804
|
+
};
|
|
805
|
+
/**
|
|
806
|
+
* Set the instruction that it is currently using V1 Plutus voting scripts
|
|
807
|
+
* @returns The MeshTxBuilder instance
|
|
808
|
+
*/
|
|
809
|
+
votePlutusScriptV1 = () => {
|
|
810
|
+
this.addingPlutusVote = true;
|
|
811
|
+
this.plutusVoteScriptVersion = "V1";
|
|
812
|
+
return this;
|
|
813
|
+
};
|
|
814
|
+
/**
|
|
815
|
+
* Set the instruction that it is currently using V2 Plutus voting scripts
|
|
816
|
+
* @returns The MeshTxBuilder instance
|
|
817
|
+
*/
|
|
818
|
+
votePlutusScriptV2 = () => {
|
|
819
|
+
this.addingPlutusVote = true;
|
|
820
|
+
this.plutusVoteScriptVersion = "V2";
|
|
821
|
+
return this;
|
|
822
|
+
};
|
|
823
|
+
/**
|
|
824
|
+
* Set the instruction that it is currently using V3 Plutus voting scripts
|
|
825
|
+
* @returns The MeshTxBuilder instance
|
|
826
|
+
*/
|
|
827
|
+
votePlutusScriptV3 = () => {
|
|
828
|
+
this.addingPlutusVote = true;
|
|
829
|
+
this.plutusVoteScriptVersion = "V3";
|
|
830
|
+
return this;
|
|
831
|
+
};
|
|
832
|
+
/**
|
|
833
|
+
* Add a vote in the MeshTxBuilder instance
|
|
834
|
+
* @param voter The voter, can be a ConstitutionalCommitee, a DRep or a StakePool
|
|
835
|
+
* @param govActionId - The transaction hash and transaction id of the governance action
|
|
836
|
+
* @param votingProcedure - The voting kind (Yes, No, Abstain) with an optional anchor
|
|
837
|
+
* @returns The MeshTxBuilder instance
|
|
838
|
+
*/
|
|
839
|
+
vote = (voter, govActionId, votingProcedure) => {
|
|
840
|
+
if (this.voteItem) {
|
|
841
|
+
this.queueVote();
|
|
842
|
+
}
|
|
843
|
+
if (this.addingPlutusVote) {
|
|
844
|
+
const vote = {
|
|
845
|
+
type: "ScriptVote",
|
|
846
|
+
vote: {
|
|
847
|
+
voter,
|
|
848
|
+
govActionId,
|
|
849
|
+
votingProcedure
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
this.voteItem = vote;
|
|
853
|
+
} else {
|
|
854
|
+
const vote = {
|
|
855
|
+
type: "BasicVote",
|
|
856
|
+
vote: {
|
|
857
|
+
voter,
|
|
858
|
+
govActionId,
|
|
859
|
+
votingProcedure
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
this.voteItem = vote;
|
|
863
|
+
}
|
|
864
|
+
return this;
|
|
865
|
+
};
|
|
866
|
+
/**
|
|
867
|
+
* Add a voting script to the MeshTxBuilder instance
|
|
868
|
+
* @param scriptCbor The script in CBOR format
|
|
869
|
+
* @returns The MeshTxBuilder instance
|
|
870
|
+
*/
|
|
871
|
+
voteScript = (scriptCbor) => {
|
|
872
|
+
if (!this.voteItem) throw Error("voteScript: Undefined vote");
|
|
873
|
+
if (this.voteItem.type === "BasicVote") {
|
|
874
|
+
this.voteItem = {
|
|
875
|
+
type: "SimpleScriptVote",
|
|
876
|
+
vote: this.voteItem.vote,
|
|
877
|
+
simpleScriptSource: {
|
|
878
|
+
type: "Provided",
|
|
879
|
+
scriptCode: scriptCbor
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
} else if (this.voteItem.type === "ScriptVote") {
|
|
883
|
+
this.voteItem.scriptSource = {
|
|
884
|
+
type: "Provided",
|
|
885
|
+
script: {
|
|
886
|
+
code: scriptCbor,
|
|
887
|
+
version: this.plutusVoteScriptVersion || "V2"
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
} else if (this.voteItem.type === "SimpleScriptVote") {
|
|
891
|
+
throw Error("voteScript: Script is already defined for current vote");
|
|
892
|
+
}
|
|
893
|
+
return this;
|
|
894
|
+
};
|
|
895
|
+
/**
|
|
896
|
+
* Add a vote reference to the MeshTxBuilder instance
|
|
897
|
+
* @param txHash The transaction hash of reference UTxO
|
|
898
|
+
* @param txIndex The transaction index of reference UTxO
|
|
899
|
+
* @param scriptSize The script size in bytes of the vote script (can be obtained by script hex length / 2)
|
|
900
|
+
* @param scriptHash The script hash of the vote script
|
|
901
|
+
* @returns The MeshTxBuilder instance
|
|
902
|
+
*/
|
|
903
|
+
voteTxInReference = (txHash, txIndex, scriptSize, scriptHash) => {
|
|
904
|
+
if (!this.voteItem) throw Error("voteTxInReference: Undefined vote");
|
|
905
|
+
if (this.voteItem.type === "BasicVote")
|
|
906
|
+
throw Error(
|
|
907
|
+
"voteTxInReference: Adding script reference to a basic vote"
|
|
908
|
+
);
|
|
909
|
+
if (this.voteItem.type === "ScriptVote") {
|
|
910
|
+
this.voteItem.scriptSource = {
|
|
911
|
+
type: "Inline",
|
|
912
|
+
txHash,
|
|
913
|
+
txIndex,
|
|
914
|
+
scriptHash,
|
|
915
|
+
version: this.plutusWithdrawalScriptVersion || "V2",
|
|
916
|
+
scriptSize
|
|
917
|
+
};
|
|
918
|
+
} else if (this.voteItem.type === "SimpleScriptVote") {
|
|
919
|
+
this.voteItem.simpleScriptSource = {
|
|
920
|
+
type: "Inline",
|
|
921
|
+
txHash,
|
|
922
|
+
txIndex,
|
|
923
|
+
scriptSize,
|
|
924
|
+
simpleScriptHash: scriptHash
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
return this;
|
|
928
|
+
};
|
|
929
|
+
/**
|
|
930
|
+
* Set the transaction vote redeemer value in the MeshTxBuilder instance
|
|
931
|
+
* @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
932
|
+
* @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
933
|
+
* @param exUnits The execution units budget for the redeemer
|
|
934
|
+
* @returns The MeshTxBuilder instance
|
|
935
|
+
*/
|
|
936
|
+
voteRedeemerValue = (redeemer, type = "Mesh", exUnits = { ...import_common.DEFAULT_REDEEMER_BUDGET }) => {
|
|
937
|
+
if (!this.voteItem) throw Error("voteRedeemerValue: Undefined vote");
|
|
938
|
+
if (!(this.voteItem.type === "ScriptVote"))
|
|
939
|
+
throw Error("voteRedeemerValue: Adding redeemer to non plutus vote");
|
|
940
|
+
this.voteItem.redeemer = this.castBuilderDataToRedeemer(
|
|
941
|
+
redeemer,
|
|
942
|
+
type,
|
|
943
|
+
exUnits
|
|
944
|
+
);
|
|
945
|
+
return this;
|
|
946
|
+
};
|
|
792
947
|
/**
|
|
793
948
|
* Creates a pool registration certificate, and adds it to the transaction
|
|
794
949
|
* @param poolParams Parameters for pool registration
|
|
@@ -1141,6 +1296,9 @@ var MeshTxBuilderCore = class {
|
|
|
1141
1296
|
if (this.withdrawalItem) {
|
|
1142
1297
|
this.queueWithdrawal();
|
|
1143
1298
|
}
|
|
1299
|
+
if (this.voteItem) {
|
|
1300
|
+
this.queueVote();
|
|
1301
|
+
}
|
|
1144
1302
|
};
|
|
1145
1303
|
queueInput = () => {
|
|
1146
1304
|
if (!this.txInQueueItem) throw Error("queueInput: Undefined input");
|
|
@@ -1192,6 +1350,25 @@ var MeshTxBuilderCore = class {
|
|
|
1192
1350
|
this.meshTxBuilderBody.withdrawals.push(this.withdrawalItem);
|
|
1193
1351
|
this.withdrawalItem = void 0;
|
|
1194
1352
|
};
|
|
1353
|
+
queueVote = () => {
|
|
1354
|
+
if (!this.voteItem) {
|
|
1355
|
+
throw Error("queueVote: Undefined vote");
|
|
1356
|
+
}
|
|
1357
|
+
if (this.voteItem.type === "ScriptVote") {
|
|
1358
|
+
if (!this.voteItem.scriptSource) {
|
|
1359
|
+
throw Error("queueVote: Missing vote script information");
|
|
1360
|
+
}
|
|
1361
|
+
if (!this.voteItem.redeemer) {
|
|
1362
|
+
throw Error("queueVote: Missing vote redeemer information");
|
|
1363
|
+
}
|
|
1364
|
+
} else if (this.voteItem.type === "SimpleScriptVote") {
|
|
1365
|
+
if (!this.voteItem.simpleScriptSource) {
|
|
1366
|
+
throw Error("queueVote: Missing vote script information");
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
this.meshTxBuilderBody.votes.push(this.voteItem);
|
|
1370
|
+
this.voteItem = void 0;
|
|
1371
|
+
};
|
|
1195
1372
|
castRawDataToJsonString = (rawData) => {
|
|
1196
1373
|
if (typeof rawData === "object") {
|
|
1197
1374
|
return import_json_bigint.default.stringify(rawData);
|
|
@@ -1391,11 +1568,13 @@ var MeshTxBuilderCore = class {
|
|
|
1391
1568
|
this.addingPlutusMint = false;
|
|
1392
1569
|
this.plutusMintingScriptVersion = void 0;
|
|
1393
1570
|
this.addingPlutusWithdrawal = false;
|
|
1571
|
+
this.addingPlutusVote = false;
|
|
1394
1572
|
this.plutusWithdrawalScriptVersion = void 0;
|
|
1395
1573
|
this._protocolParams = import_common.DEFAULT_PROTOCOL_PARAMETERS;
|
|
1396
1574
|
this.mintItem = void 0;
|
|
1397
1575
|
this.txInQueueItem = void 0;
|
|
1398
1576
|
this.withdrawalItem = void 0;
|
|
1577
|
+
this.voteItem = void 0;
|
|
1399
1578
|
this.collateralQueueItem = void 0;
|
|
1400
1579
|
this.refScriptTxInQueueItem = void 0;
|
|
1401
1580
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Protocol, MintItem, TxIn, Withdrawal, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, Asset, BuilderData, LanguageVersion, PoolParams, Anchor, DRep, UTxO, UtxoSelectionStrategy, Network, Redeemer, Action, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, NativeScript, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
|
|
1
|
+
import { Protocol, MintItem, TxIn, Withdrawal, Vote, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, Asset, BuilderData, LanguageVersion, Voter, VotingProcedure, PoolParams, Anchor, DRep, UTxO, UtxoSelectionStrategy, Network, Redeemer, Action, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, NativeScript, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
|
|
2
2
|
|
|
3
3
|
declare class MeshTxBuilderCore {
|
|
4
4
|
txEvaluationMultiplier: number;
|
|
@@ -9,10 +9,13 @@ declare class MeshTxBuilderCore {
|
|
|
9
9
|
private plutusMintingScriptVersion;
|
|
10
10
|
private addingPlutusWithdrawal;
|
|
11
11
|
private plutusWithdrawalScriptVersion;
|
|
12
|
+
private addingPlutusVote;
|
|
13
|
+
private plutusVoteScriptVersion;
|
|
12
14
|
protected _protocolParams: Protocol;
|
|
13
15
|
protected mintItem?: MintItem;
|
|
14
16
|
protected txInQueueItem?: TxIn;
|
|
15
17
|
protected withdrawalItem?: Withdrawal;
|
|
18
|
+
protected voteItem?: Vote;
|
|
16
19
|
protected collateralQueueItem?: PubKeyTxIn;
|
|
17
20
|
protected refScriptTxInQueueItem?: RefTxIn;
|
|
18
21
|
meshTxBuilderBody: MeshTxBuilderBody;
|
|
@@ -241,7 +244,7 @@ declare class MeshTxBuilderCore {
|
|
|
241
244
|
*/
|
|
242
245
|
withdrawalPlutusScript: (languageVersion: LanguageVersion) => this;
|
|
243
246
|
/**
|
|
244
|
-
* Set the instruction that it is currently using
|
|
247
|
+
* Set the instruction that it is currently using a Plutus withdrawal scripts
|
|
245
248
|
* @returns The MeshTxBuilder instance
|
|
246
249
|
*/
|
|
247
250
|
withdrawalPlutusScriptV1: () => this;
|
|
@@ -288,6 +291,61 @@ declare class MeshTxBuilderCore {
|
|
|
288
291
|
mem: number;
|
|
289
292
|
steps: number;
|
|
290
293
|
}) => this;
|
|
294
|
+
/**
|
|
295
|
+
* Set the instruction that it is currently using a Plutus voting scripts
|
|
296
|
+
* @param languageVersion The Plutus script version
|
|
297
|
+
* @returns The MeshTxBuilder instance
|
|
298
|
+
*/
|
|
299
|
+
votePlutusScript: (languageVersion: LanguageVersion) => this;
|
|
300
|
+
/**
|
|
301
|
+
* Set the instruction that it is currently using V1 Plutus voting scripts
|
|
302
|
+
* @returns The MeshTxBuilder instance
|
|
303
|
+
*/
|
|
304
|
+
votePlutusScriptV1: () => this;
|
|
305
|
+
/**
|
|
306
|
+
* Set the instruction that it is currently using V2 Plutus voting scripts
|
|
307
|
+
* @returns The MeshTxBuilder instance
|
|
308
|
+
*/
|
|
309
|
+
votePlutusScriptV2: () => this;
|
|
310
|
+
/**
|
|
311
|
+
* Set the instruction that it is currently using V3 Plutus voting scripts
|
|
312
|
+
* @returns The MeshTxBuilder instance
|
|
313
|
+
*/
|
|
314
|
+
votePlutusScriptV3: () => this;
|
|
315
|
+
/**
|
|
316
|
+
* Add a vote in the MeshTxBuilder instance
|
|
317
|
+
* @param voter The voter, can be a ConstitutionalCommitee, a DRep or a StakePool
|
|
318
|
+
* @param govActionId - The transaction hash and transaction id of the governance action
|
|
319
|
+
* @param votingProcedure - The voting kind (Yes, No, Abstain) with an optional anchor
|
|
320
|
+
* @returns The MeshTxBuilder instance
|
|
321
|
+
*/
|
|
322
|
+
vote: (voter: Voter, govActionId: RefTxIn, votingProcedure: VotingProcedure) => this;
|
|
323
|
+
/**
|
|
324
|
+
* Add a voting script to the MeshTxBuilder instance
|
|
325
|
+
* @param scriptCbor The script in CBOR format
|
|
326
|
+
* @returns The MeshTxBuilder instance
|
|
327
|
+
*/
|
|
328
|
+
voteScript: (scriptCbor: string) => this;
|
|
329
|
+
/**
|
|
330
|
+
* Add a vote reference to the MeshTxBuilder instance
|
|
331
|
+
* @param txHash The transaction hash of reference UTxO
|
|
332
|
+
* @param txIndex The transaction index of reference UTxO
|
|
333
|
+
* @param scriptSize The script size in bytes of the vote script (can be obtained by script hex length / 2)
|
|
334
|
+
* @param scriptHash The script hash of the vote script
|
|
335
|
+
* @returns The MeshTxBuilder instance
|
|
336
|
+
*/
|
|
337
|
+
voteTxInReference: (txHash: string, txIndex: number, scriptSize?: string, scriptHash?: string) => this;
|
|
338
|
+
/**
|
|
339
|
+
* Set the transaction vote redeemer value in the MeshTxBuilder instance
|
|
340
|
+
* @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
341
|
+
* @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
342
|
+
* @param exUnits The execution units budget for the redeemer
|
|
343
|
+
* @returns The MeshTxBuilder instance
|
|
344
|
+
*/
|
|
345
|
+
voteRedeemerValue: (redeemer: BuilderData["content"], type?: BuilderData["type"], exUnits?: {
|
|
346
|
+
mem: number;
|
|
347
|
+
steps: number;
|
|
348
|
+
}) => this;
|
|
291
349
|
/**
|
|
292
350
|
* Creates a pool registration certificate, and adds it to the transaction
|
|
293
351
|
* @param poolParams Parameters for pool registration
|
|
@@ -422,6 +480,7 @@ declare class MeshTxBuilderCore {
|
|
|
422
480
|
private queueInput;
|
|
423
481
|
private queueMint;
|
|
424
482
|
private queueWithdrawal;
|
|
483
|
+
private queueVote;
|
|
425
484
|
protected castRawDataToJsonString: (rawData: object | string) => string;
|
|
426
485
|
protected castBuilderDataToRedeemer: (redeemer: BuilderData["content"], type?: BuilderData["type"], exUnits?: {
|
|
427
486
|
mem: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Protocol, MintItem, TxIn, Withdrawal, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, Asset, BuilderData, LanguageVersion, PoolParams, Anchor, DRep, UTxO, UtxoSelectionStrategy, Network, Redeemer, Action, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, NativeScript, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
|
|
1
|
+
import { Protocol, MintItem, TxIn, Withdrawal, Vote, PubKeyTxIn, RefTxIn, MeshTxBuilderBody, Asset, BuilderData, LanguageVersion, Voter, VotingProcedure, PoolParams, Anchor, DRep, UTxO, UtxoSelectionStrategy, Network, Redeemer, Action, IFetcher, ISubmitter, IEvaluator, IMeshTxSerializer, ScriptSource, SimpleScriptSourceInfo, NativeScript, IInitiator, Recipient, Token, PlutusScript, Budget, Data, Mint } from '@meshsdk/common';
|
|
2
2
|
|
|
3
3
|
declare class MeshTxBuilderCore {
|
|
4
4
|
txEvaluationMultiplier: number;
|
|
@@ -9,10 +9,13 @@ declare class MeshTxBuilderCore {
|
|
|
9
9
|
private plutusMintingScriptVersion;
|
|
10
10
|
private addingPlutusWithdrawal;
|
|
11
11
|
private plutusWithdrawalScriptVersion;
|
|
12
|
+
private addingPlutusVote;
|
|
13
|
+
private plutusVoteScriptVersion;
|
|
12
14
|
protected _protocolParams: Protocol;
|
|
13
15
|
protected mintItem?: MintItem;
|
|
14
16
|
protected txInQueueItem?: TxIn;
|
|
15
17
|
protected withdrawalItem?: Withdrawal;
|
|
18
|
+
protected voteItem?: Vote;
|
|
16
19
|
protected collateralQueueItem?: PubKeyTxIn;
|
|
17
20
|
protected refScriptTxInQueueItem?: RefTxIn;
|
|
18
21
|
meshTxBuilderBody: MeshTxBuilderBody;
|
|
@@ -241,7 +244,7 @@ declare class MeshTxBuilderCore {
|
|
|
241
244
|
*/
|
|
242
245
|
withdrawalPlutusScript: (languageVersion: LanguageVersion) => this;
|
|
243
246
|
/**
|
|
244
|
-
* Set the instruction that it is currently using
|
|
247
|
+
* Set the instruction that it is currently using a Plutus withdrawal scripts
|
|
245
248
|
* @returns The MeshTxBuilder instance
|
|
246
249
|
*/
|
|
247
250
|
withdrawalPlutusScriptV1: () => this;
|
|
@@ -288,6 +291,61 @@ declare class MeshTxBuilderCore {
|
|
|
288
291
|
mem: number;
|
|
289
292
|
steps: number;
|
|
290
293
|
}) => this;
|
|
294
|
+
/**
|
|
295
|
+
* Set the instruction that it is currently using a Plutus voting scripts
|
|
296
|
+
* @param languageVersion The Plutus script version
|
|
297
|
+
* @returns The MeshTxBuilder instance
|
|
298
|
+
*/
|
|
299
|
+
votePlutusScript: (languageVersion: LanguageVersion) => this;
|
|
300
|
+
/**
|
|
301
|
+
* Set the instruction that it is currently using V1 Plutus voting scripts
|
|
302
|
+
* @returns The MeshTxBuilder instance
|
|
303
|
+
*/
|
|
304
|
+
votePlutusScriptV1: () => this;
|
|
305
|
+
/**
|
|
306
|
+
* Set the instruction that it is currently using V2 Plutus voting scripts
|
|
307
|
+
* @returns The MeshTxBuilder instance
|
|
308
|
+
*/
|
|
309
|
+
votePlutusScriptV2: () => this;
|
|
310
|
+
/**
|
|
311
|
+
* Set the instruction that it is currently using V3 Plutus voting scripts
|
|
312
|
+
* @returns The MeshTxBuilder instance
|
|
313
|
+
*/
|
|
314
|
+
votePlutusScriptV3: () => this;
|
|
315
|
+
/**
|
|
316
|
+
* Add a vote in the MeshTxBuilder instance
|
|
317
|
+
* @param voter The voter, can be a ConstitutionalCommitee, a DRep or a StakePool
|
|
318
|
+
* @param govActionId - The transaction hash and transaction id of the governance action
|
|
319
|
+
* @param votingProcedure - The voting kind (Yes, No, Abstain) with an optional anchor
|
|
320
|
+
* @returns The MeshTxBuilder instance
|
|
321
|
+
*/
|
|
322
|
+
vote: (voter: Voter, govActionId: RefTxIn, votingProcedure: VotingProcedure) => this;
|
|
323
|
+
/**
|
|
324
|
+
* Add a voting script to the MeshTxBuilder instance
|
|
325
|
+
* @param scriptCbor The script in CBOR format
|
|
326
|
+
* @returns The MeshTxBuilder instance
|
|
327
|
+
*/
|
|
328
|
+
voteScript: (scriptCbor: string) => this;
|
|
329
|
+
/**
|
|
330
|
+
* Add a vote reference to the MeshTxBuilder instance
|
|
331
|
+
* @param txHash The transaction hash of reference UTxO
|
|
332
|
+
* @param txIndex The transaction index of reference UTxO
|
|
333
|
+
* @param scriptSize The script size in bytes of the vote script (can be obtained by script hex length / 2)
|
|
334
|
+
* @param scriptHash The script hash of the vote script
|
|
335
|
+
* @returns The MeshTxBuilder instance
|
|
336
|
+
*/
|
|
337
|
+
voteTxInReference: (txHash: string, txIndex: number, scriptSize?: string, scriptHash?: string) => this;
|
|
338
|
+
/**
|
|
339
|
+
* Set the transaction vote redeemer value in the MeshTxBuilder instance
|
|
340
|
+
* @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
341
|
+
* @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
342
|
+
* @param exUnits The execution units budget for the redeemer
|
|
343
|
+
* @returns The MeshTxBuilder instance
|
|
344
|
+
*/
|
|
345
|
+
voteRedeemerValue: (redeemer: BuilderData["content"], type?: BuilderData["type"], exUnits?: {
|
|
346
|
+
mem: number;
|
|
347
|
+
steps: number;
|
|
348
|
+
}) => this;
|
|
291
349
|
/**
|
|
292
350
|
* Creates a pool registration certificate, and adds it to the transaction
|
|
293
351
|
* @param poolParams Parameters for pool registration
|
|
@@ -422,6 +480,7 @@ declare class MeshTxBuilderCore {
|
|
|
422
480
|
private queueInput;
|
|
423
481
|
private queueMint;
|
|
424
482
|
private queueWithdrawal;
|
|
483
|
+
private queueVote;
|
|
425
484
|
protected castRawDataToJsonString: (rawData: object | string) => string;
|
|
426
485
|
protected castBuilderDataToRedeemer: (redeemer: BuilderData["content"], type?: BuilderData["type"], exUnits?: {
|
|
427
486
|
mem: number;
|
package/dist/index.js
CHANGED
|
@@ -19,10 +19,13 @@ var MeshTxBuilderCore = class {
|
|
|
19
19
|
plutusMintingScriptVersion;
|
|
20
20
|
addingPlutusWithdrawal = false;
|
|
21
21
|
plutusWithdrawalScriptVersion;
|
|
22
|
+
addingPlutusVote = false;
|
|
23
|
+
plutusVoteScriptVersion;
|
|
22
24
|
_protocolParams = DEFAULT_PROTOCOL_PARAMETERS;
|
|
23
25
|
mintItem;
|
|
24
26
|
txInQueueItem;
|
|
25
27
|
withdrawalItem;
|
|
28
|
+
voteItem;
|
|
26
29
|
collateralQueueItem;
|
|
27
30
|
refScriptTxInQueueItem;
|
|
28
31
|
meshTxBuilderBody;
|
|
@@ -628,7 +631,7 @@ var MeshTxBuilderCore = class {
|
|
|
628
631
|
return this;
|
|
629
632
|
};
|
|
630
633
|
/**
|
|
631
|
-
* Set the instruction that it is currently using
|
|
634
|
+
* Set the instruction that it is currently using a Plutus withdrawal scripts
|
|
632
635
|
* @returns The MeshTxBuilder instance
|
|
633
636
|
*/
|
|
634
637
|
withdrawalPlutusScriptV1 = () => {
|
|
@@ -756,6 +759,158 @@ var MeshTxBuilderCore = class {
|
|
|
756
759
|
);
|
|
757
760
|
return this;
|
|
758
761
|
};
|
|
762
|
+
/**
|
|
763
|
+
* Set the instruction that it is currently using a Plutus voting scripts
|
|
764
|
+
* @param languageVersion The Plutus script version
|
|
765
|
+
* @returns The MeshTxBuilder instance
|
|
766
|
+
*/
|
|
767
|
+
votePlutusScript = (languageVersion) => {
|
|
768
|
+
this.addingPlutusVote = true;
|
|
769
|
+
this.plutusVoteScriptVersion = languageVersion;
|
|
770
|
+
return this;
|
|
771
|
+
};
|
|
772
|
+
/**
|
|
773
|
+
* Set the instruction that it is currently using V1 Plutus voting scripts
|
|
774
|
+
* @returns The MeshTxBuilder instance
|
|
775
|
+
*/
|
|
776
|
+
votePlutusScriptV1 = () => {
|
|
777
|
+
this.addingPlutusVote = true;
|
|
778
|
+
this.plutusVoteScriptVersion = "V1";
|
|
779
|
+
return this;
|
|
780
|
+
};
|
|
781
|
+
/**
|
|
782
|
+
* Set the instruction that it is currently using V2 Plutus voting scripts
|
|
783
|
+
* @returns The MeshTxBuilder instance
|
|
784
|
+
*/
|
|
785
|
+
votePlutusScriptV2 = () => {
|
|
786
|
+
this.addingPlutusVote = true;
|
|
787
|
+
this.plutusVoteScriptVersion = "V2";
|
|
788
|
+
return this;
|
|
789
|
+
};
|
|
790
|
+
/**
|
|
791
|
+
* Set the instruction that it is currently using V3 Plutus voting scripts
|
|
792
|
+
* @returns The MeshTxBuilder instance
|
|
793
|
+
*/
|
|
794
|
+
votePlutusScriptV3 = () => {
|
|
795
|
+
this.addingPlutusVote = true;
|
|
796
|
+
this.plutusVoteScriptVersion = "V3";
|
|
797
|
+
return this;
|
|
798
|
+
};
|
|
799
|
+
/**
|
|
800
|
+
* Add a vote in the MeshTxBuilder instance
|
|
801
|
+
* @param voter The voter, can be a ConstitutionalCommitee, a DRep or a StakePool
|
|
802
|
+
* @param govActionId - The transaction hash and transaction id of the governance action
|
|
803
|
+
* @param votingProcedure - The voting kind (Yes, No, Abstain) with an optional anchor
|
|
804
|
+
* @returns The MeshTxBuilder instance
|
|
805
|
+
*/
|
|
806
|
+
vote = (voter, govActionId, votingProcedure) => {
|
|
807
|
+
if (this.voteItem) {
|
|
808
|
+
this.queueVote();
|
|
809
|
+
}
|
|
810
|
+
if (this.addingPlutusVote) {
|
|
811
|
+
const vote = {
|
|
812
|
+
type: "ScriptVote",
|
|
813
|
+
vote: {
|
|
814
|
+
voter,
|
|
815
|
+
govActionId,
|
|
816
|
+
votingProcedure
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
this.voteItem = vote;
|
|
820
|
+
} else {
|
|
821
|
+
const vote = {
|
|
822
|
+
type: "BasicVote",
|
|
823
|
+
vote: {
|
|
824
|
+
voter,
|
|
825
|
+
govActionId,
|
|
826
|
+
votingProcedure
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
this.voteItem = vote;
|
|
830
|
+
}
|
|
831
|
+
return this;
|
|
832
|
+
};
|
|
833
|
+
/**
|
|
834
|
+
* Add a voting script to the MeshTxBuilder instance
|
|
835
|
+
* @param scriptCbor The script in CBOR format
|
|
836
|
+
* @returns The MeshTxBuilder instance
|
|
837
|
+
*/
|
|
838
|
+
voteScript = (scriptCbor) => {
|
|
839
|
+
if (!this.voteItem) throw Error("voteScript: Undefined vote");
|
|
840
|
+
if (this.voteItem.type === "BasicVote") {
|
|
841
|
+
this.voteItem = {
|
|
842
|
+
type: "SimpleScriptVote",
|
|
843
|
+
vote: this.voteItem.vote,
|
|
844
|
+
simpleScriptSource: {
|
|
845
|
+
type: "Provided",
|
|
846
|
+
scriptCode: scriptCbor
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
} else if (this.voteItem.type === "ScriptVote") {
|
|
850
|
+
this.voteItem.scriptSource = {
|
|
851
|
+
type: "Provided",
|
|
852
|
+
script: {
|
|
853
|
+
code: scriptCbor,
|
|
854
|
+
version: this.plutusVoteScriptVersion || "V2"
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
} else if (this.voteItem.type === "SimpleScriptVote") {
|
|
858
|
+
throw Error("voteScript: Script is already defined for current vote");
|
|
859
|
+
}
|
|
860
|
+
return this;
|
|
861
|
+
};
|
|
862
|
+
/**
|
|
863
|
+
* Add a vote reference to the MeshTxBuilder instance
|
|
864
|
+
* @param txHash The transaction hash of reference UTxO
|
|
865
|
+
* @param txIndex The transaction index of reference UTxO
|
|
866
|
+
* @param scriptSize The script size in bytes of the vote script (can be obtained by script hex length / 2)
|
|
867
|
+
* @param scriptHash The script hash of the vote script
|
|
868
|
+
* @returns The MeshTxBuilder instance
|
|
869
|
+
*/
|
|
870
|
+
voteTxInReference = (txHash, txIndex, scriptSize, scriptHash) => {
|
|
871
|
+
if (!this.voteItem) throw Error("voteTxInReference: Undefined vote");
|
|
872
|
+
if (this.voteItem.type === "BasicVote")
|
|
873
|
+
throw Error(
|
|
874
|
+
"voteTxInReference: Adding script reference to a basic vote"
|
|
875
|
+
);
|
|
876
|
+
if (this.voteItem.type === "ScriptVote") {
|
|
877
|
+
this.voteItem.scriptSource = {
|
|
878
|
+
type: "Inline",
|
|
879
|
+
txHash,
|
|
880
|
+
txIndex,
|
|
881
|
+
scriptHash,
|
|
882
|
+
version: this.plutusWithdrawalScriptVersion || "V2",
|
|
883
|
+
scriptSize
|
|
884
|
+
};
|
|
885
|
+
} else if (this.voteItem.type === "SimpleScriptVote") {
|
|
886
|
+
this.voteItem.simpleScriptSource = {
|
|
887
|
+
type: "Inline",
|
|
888
|
+
txHash,
|
|
889
|
+
txIndex,
|
|
890
|
+
scriptSize,
|
|
891
|
+
simpleScriptHash: scriptHash
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
return this;
|
|
895
|
+
};
|
|
896
|
+
/**
|
|
897
|
+
* Set the transaction vote redeemer value in the MeshTxBuilder instance
|
|
898
|
+
* @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
899
|
+
* @param type The redeemer data type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
900
|
+
* @param exUnits The execution units budget for the redeemer
|
|
901
|
+
* @returns The MeshTxBuilder instance
|
|
902
|
+
*/
|
|
903
|
+
voteRedeemerValue = (redeemer, type = "Mesh", exUnits = { ...DEFAULT_REDEEMER_BUDGET }) => {
|
|
904
|
+
if (!this.voteItem) throw Error("voteRedeemerValue: Undefined vote");
|
|
905
|
+
if (!(this.voteItem.type === "ScriptVote"))
|
|
906
|
+
throw Error("voteRedeemerValue: Adding redeemer to non plutus vote");
|
|
907
|
+
this.voteItem.redeemer = this.castBuilderDataToRedeemer(
|
|
908
|
+
redeemer,
|
|
909
|
+
type,
|
|
910
|
+
exUnits
|
|
911
|
+
);
|
|
912
|
+
return this;
|
|
913
|
+
};
|
|
759
914
|
/**
|
|
760
915
|
* Creates a pool registration certificate, and adds it to the transaction
|
|
761
916
|
* @param poolParams Parameters for pool registration
|
|
@@ -1108,6 +1263,9 @@ var MeshTxBuilderCore = class {
|
|
|
1108
1263
|
if (this.withdrawalItem) {
|
|
1109
1264
|
this.queueWithdrawal();
|
|
1110
1265
|
}
|
|
1266
|
+
if (this.voteItem) {
|
|
1267
|
+
this.queueVote();
|
|
1268
|
+
}
|
|
1111
1269
|
};
|
|
1112
1270
|
queueInput = () => {
|
|
1113
1271
|
if (!this.txInQueueItem) throw Error("queueInput: Undefined input");
|
|
@@ -1159,6 +1317,25 @@ var MeshTxBuilderCore = class {
|
|
|
1159
1317
|
this.meshTxBuilderBody.withdrawals.push(this.withdrawalItem);
|
|
1160
1318
|
this.withdrawalItem = void 0;
|
|
1161
1319
|
};
|
|
1320
|
+
queueVote = () => {
|
|
1321
|
+
if (!this.voteItem) {
|
|
1322
|
+
throw Error("queueVote: Undefined vote");
|
|
1323
|
+
}
|
|
1324
|
+
if (this.voteItem.type === "ScriptVote") {
|
|
1325
|
+
if (!this.voteItem.scriptSource) {
|
|
1326
|
+
throw Error("queueVote: Missing vote script information");
|
|
1327
|
+
}
|
|
1328
|
+
if (!this.voteItem.redeemer) {
|
|
1329
|
+
throw Error("queueVote: Missing vote redeemer information");
|
|
1330
|
+
}
|
|
1331
|
+
} else if (this.voteItem.type === "SimpleScriptVote") {
|
|
1332
|
+
if (!this.voteItem.simpleScriptSource) {
|
|
1333
|
+
throw Error("queueVote: Missing vote script information");
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
this.meshTxBuilderBody.votes.push(this.voteItem);
|
|
1337
|
+
this.voteItem = void 0;
|
|
1338
|
+
};
|
|
1162
1339
|
castRawDataToJsonString = (rawData) => {
|
|
1163
1340
|
if (typeof rawData === "object") {
|
|
1164
1341
|
return JSONBig.stringify(rawData);
|
|
@@ -1358,11 +1535,13 @@ var MeshTxBuilderCore = class {
|
|
|
1358
1535
|
this.addingPlutusMint = false;
|
|
1359
1536
|
this.plutusMintingScriptVersion = void 0;
|
|
1360
1537
|
this.addingPlutusWithdrawal = false;
|
|
1538
|
+
this.addingPlutusVote = false;
|
|
1361
1539
|
this.plutusWithdrawalScriptVersion = void 0;
|
|
1362
1540
|
this._protocolParams = DEFAULT_PROTOCOL_PARAMETERS;
|
|
1363
1541
|
this.mintItem = void 0;
|
|
1364
1542
|
this.txInQueueItem = void 0;
|
|
1365
1543
|
this.withdrawalItem = void 0;
|
|
1544
|
+
this.voteItem = void 0;
|
|
1366
1545
|
this.collateralQueueItem = void 0;
|
|
1367
1546
|
this.refScriptTxInQueueItem = void 0;
|
|
1368
1547
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/transaction",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"browser": "./dist/index.js",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"typescript": "^5.3.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@meshsdk/common": "1.7.
|
|
39
|
-
"@meshsdk/core-csl": "1.7.
|
|
40
|
-
"@meshsdk/core-cst": "1.7.
|
|
38
|
+
"@meshsdk/common": "1.7.9",
|
|
39
|
+
"@meshsdk/core-csl": "1.7.9",
|
|
40
|
+
"@meshsdk/core-cst": "1.7.9",
|
|
41
41
|
"json-bigint": "^1.0.0"
|
|
42
42
|
},
|
|
43
43
|
"prettier": "@meshsdk/configs/prettier",
|