@meshsdk/transaction 1.6.13 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +69 -28
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +69 -28
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -114,7 +114,7 @@ var MeshTxBuilderCore = class {
|
|
|
114
114
|
simpleScriptTxIn: {
|
|
115
115
|
scriptSource: {
|
|
116
116
|
type: "Provided",
|
|
117
|
-
|
|
117
|
+
scriptCode: scriptCbor
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
};
|
|
@@ -191,33 +191,42 @@ var MeshTxBuilderCore = class {
|
|
|
191
191
|
}
|
|
192
192
|
return this;
|
|
193
193
|
};
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Native script - Set the reference input where it would also be spent in the transaction
|
|
196
|
+
* @param txHash The transaction hash of the reference UTxO
|
|
197
|
+
* @param txIndex The transaction index of the reference UTxO
|
|
198
|
+
* @param spendingScriptHash The script hash of the spending script
|
|
199
|
+
* @returns The MeshTxBuilder instance
|
|
200
|
+
*/
|
|
201
|
+
simpleScriptTxInReference = (txHash, txIndex, spendingScriptHash, scriptSize) => {
|
|
202
|
+
if (!this.txInQueueItem) throw Error("Undefined input");
|
|
203
|
+
if (this.txInQueueItem.type === "Script") {
|
|
204
|
+
throw Error(
|
|
205
|
+
"simpleScriptTxInReference called on a plutus script, use spendingTxInReference instead"
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
if (this.txInQueueItem.type === "SimpleScript") {
|
|
209
|
+
throw Error(
|
|
210
|
+
"simpleScriptTxInReference called on a native script input that already has a script defined"
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
if (this.txInQueueItem.type === "PubKey") {
|
|
214
|
+
this.txInQueueItem = {
|
|
215
|
+
type: "SimpleScript",
|
|
216
|
+
txIn: this.txInQueueItem.txIn,
|
|
217
|
+
simpleScriptTxIn: {
|
|
218
|
+
scriptSource: {
|
|
219
|
+
type: "Inline",
|
|
220
|
+
txHash,
|
|
221
|
+
txIndex,
|
|
222
|
+
simpleScriptHash: spendingScriptHash,
|
|
223
|
+
scriptSize
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
return this;
|
|
229
|
+
};
|
|
221
230
|
/**
|
|
222
231
|
* Set the redeemer for the reference input to be spent in same transaction
|
|
223
232
|
* @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
@@ -323,6 +332,38 @@ var MeshTxBuilderCore = class {
|
|
|
323
332
|
}
|
|
324
333
|
return this;
|
|
325
334
|
};
|
|
335
|
+
/**
|
|
336
|
+
* Set the output embed datum for transaction
|
|
337
|
+
* @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
338
|
+
* @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
339
|
+
* @returns The MeshTxBuilder instance
|
|
340
|
+
*/
|
|
341
|
+
txOutDatumEmbedValue = (datum, type = "Mesh") => {
|
|
342
|
+
let content = datum;
|
|
343
|
+
if (this.txOutput) {
|
|
344
|
+
if (type === "Mesh") {
|
|
345
|
+
this.txOutput.datum = {
|
|
346
|
+
type: "Embedded",
|
|
347
|
+
data: {
|
|
348
|
+
type,
|
|
349
|
+
content
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
if (type === "JSON") {
|
|
355
|
+
content = this.castRawDataToJsonString(datum);
|
|
356
|
+
}
|
|
357
|
+
this.txOutput.datum = {
|
|
358
|
+
type: "Embedded",
|
|
359
|
+
data: {
|
|
360
|
+
type,
|
|
361
|
+
content
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
return this;
|
|
366
|
+
};
|
|
326
367
|
/**
|
|
327
368
|
* Set the reference script to be attached with the output
|
|
328
369
|
* @param scriptCbor The CBOR hex of the script to be attached to UTxO as reference script
|
package/dist/index.d.cts
CHANGED
|
@@ -45,6 +45,14 @@ declare class MeshTxBuilderCore {
|
|
|
45
45
|
* @returns The MeshTxBuilder instance
|
|
46
46
|
*/
|
|
47
47
|
txInInlineDatumPresent: () => this;
|
|
48
|
+
/**
|
|
49
|
+
* Native script - Set the reference input where it would also be spent in the transaction
|
|
50
|
+
* @param txHash The transaction hash of the reference UTxO
|
|
51
|
+
* @param txIndex The transaction index of the reference UTxO
|
|
52
|
+
* @param spendingScriptHash The script hash of the spending script
|
|
53
|
+
* @returns The MeshTxBuilder instance
|
|
54
|
+
*/
|
|
55
|
+
simpleScriptTxInReference: (txHash: string, txIndex: number, spendingScriptHash?: string, scriptSize?: string) => this;
|
|
48
56
|
/**
|
|
49
57
|
* Set the redeemer for the reference input to be spent in same transaction
|
|
50
58
|
* @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
@@ -77,6 +85,13 @@ declare class MeshTxBuilderCore {
|
|
|
77
85
|
* @returns The MeshTxBuilder instance
|
|
78
86
|
*/
|
|
79
87
|
txOutInlineDatumValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
|
|
88
|
+
/**
|
|
89
|
+
* Set the output embed datum for transaction
|
|
90
|
+
* @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
91
|
+
* @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
92
|
+
* @returns The MeshTxBuilder instance
|
|
93
|
+
*/
|
|
94
|
+
txOutDatumEmbedValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
|
|
80
95
|
/**
|
|
81
96
|
* Set the reference script to be attached with the output
|
|
82
97
|
* @param scriptCbor The CBOR hex of the script to be attached to UTxO as reference script
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,14 @@ declare class MeshTxBuilderCore {
|
|
|
45
45
|
* @returns The MeshTxBuilder instance
|
|
46
46
|
*/
|
|
47
47
|
txInInlineDatumPresent: () => this;
|
|
48
|
+
/**
|
|
49
|
+
* Native script - Set the reference input where it would also be spent in the transaction
|
|
50
|
+
* @param txHash The transaction hash of the reference UTxO
|
|
51
|
+
* @param txIndex The transaction index of the reference UTxO
|
|
52
|
+
* @param spendingScriptHash The script hash of the spending script
|
|
53
|
+
* @returns The MeshTxBuilder instance
|
|
54
|
+
*/
|
|
55
|
+
simpleScriptTxInReference: (txHash: string, txIndex: number, spendingScriptHash?: string, scriptSize?: string) => this;
|
|
48
56
|
/**
|
|
49
57
|
* Set the redeemer for the reference input to be spent in same transaction
|
|
50
58
|
* @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
@@ -77,6 +85,13 @@ declare class MeshTxBuilderCore {
|
|
|
77
85
|
* @returns The MeshTxBuilder instance
|
|
78
86
|
*/
|
|
79
87
|
txOutInlineDatumValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
|
|
88
|
+
/**
|
|
89
|
+
* Set the output embed datum for transaction
|
|
90
|
+
* @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
91
|
+
* @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
92
|
+
* @returns The MeshTxBuilder instance
|
|
93
|
+
*/
|
|
94
|
+
txOutDatumEmbedValue: (datum: BuilderData["content"], type?: BuilderData["type"]) => this;
|
|
80
95
|
/**
|
|
81
96
|
* Set the reference script to be attached with the output
|
|
82
97
|
* @param scriptCbor The CBOR hex of the script to be attached to UTxO as reference script
|
package/dist/index.js
CHANGED
|
@@ -80,7 +80,7 @@ var MeshTxBuilderCore = class {
|
|
|
80
80
|
simpleScriptTxIn: {
|
|
81
81
|
scriptSource: {
|
|
82
82
|
type: "Provided",
|
|
83
|
-
|
|
83
|
+
scriptCode: scriptCbor
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
};
|
|
@@ -157,33 +157,42 @@ var MeshTxBuilderCore = class {
|
|
|
157
157
|
}
|
|
158
158
|
return this;
|
|
159
159
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Native script - Set the reference input where it would also be spent in the transaction
|
|
162
|
+
* @param txHash The transaction hash of the reference UTxO
|
|
163
|
+
* @param txIndex The transaction index of the reference UTxO
|
|
164
|
+
* @param spendingScriptHash The script hash of the spending script
|
|
165
|
+
* @returns The MeshTxBuilder instance
|
|
166
|
+
*/
|
|
167
|
+
simpleScriptTxInReference = (txHash, txIndex, spendingScriptHash, scriptSize) => {
|
|
168
|
+
if (!this.txInQueueItem) throw Error("Undefined input");
|
|
169
|
+
if (this.txInQueueItem.type === "Script") {
|
|
170
|
+
throw Error(
|
|
171
|
+
"simpleScriptTxInReference called on a plutus script, use spendingTxInReference instead"
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
if (this.txInQueueItem.type === "SimpleScript") {
|
|
175
|
+
throw Error(
|
|
176
|
+
"simpleScriptTxInReference called on a native script input that already has a script defined"
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
if (this.txInQueueItem.type === "PubKey") {
|
|
180
|
+
this.txInQueueItem = {
|
|
181
|
+
type: "SimpleScript",
|
|
182
|
+
txIn: this.txInQueueItem.txIn,
|
|
183
|
+
simpleScriptTxIn: {
|
|
184
|
+
scriptSource: {
|
|
185
|
+
type: "Inline",
|
|
186
|
+
txHash,
|
|
187
|
+
txIndex,
|
|
188
|
+
simpleScriptHash: spendingScriptHash,
|
|
189
|
+
scriptSize
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return this;
|
|
195
|
+
};
|
|
187
196
|
/**
|
|
188
197
|
* Set the redeemer for the reference input to be spent in same transaction
|
|
189
198
|
* @param redeemer The redeemer in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
@@ -289,6 +298,38 @@ var MeshTxBuilderCore = class {
|
|
|
289
298
|
}
|
|
290
299
|
return this;
|
|
291
300
|
};
|
|
301
|
+
/**
|
|
302
|
+
* Set the output embed datum for transaction
|
|
303
|
+
* @param datum The datum in Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
304
|
+
* @param type The datum type, either Mesh Data type, JSON in raw constructor like format, or CBOR hex string
|
|
305
|
+
* @returns The MeshTxBuilder instance
|
|
306
|
+
*/
|
|
307
|
+
txOutDatumEmbedValue = (datum, type = "Mesh") => {
|
|
308
|
+
let content = datum;
|
|
309
|
+
if (this.txOutput) {
|
|
310
|
+
if (type === "Mesh") {
|
|
311
|
+
this.txOutput.datum = {
|
|
312
|
+
type: "Embedded",
|
|
313
|
+
data: {
|
|
314
|
+
type,
|
|
315
|
+
content
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
return this;
|
|
319
|
+
}
|
|
320
|
+
if (type === "JSON") {
|
|
321
|
+
content = this.castRawDataToJsonString(datum);
|
|
322
|
+
}
|
|
323
|
+
this.txOutput.datum = {
|
|
324
|
+
type: "Embedded",
|
|
325
|
+
data: {
|
|
326
|
+
type,
|
|
327
|
+
content
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
return this;
|
|
332
|
+
};
|
|
292
333
|
/**
|
|
293
334
|
* Set the reference script to be attached with the output
|
|
294
335
|
* @param scriptCbor The CBOR hex of the script to be attached to UTxO as reference script
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/transaction",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"typescript": "^5.3.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@meshsdk/common": "
|
|
38
|
-
"@meshsdk/core-csl": "
|
|
39
|
-
"@meshsdk/core-cst": "
|
|
37
|
+
"@meshsdk/common": "1.7.1",
|
|
38
|
+
"@meshsdk/core-csl": "1.7.1",
|
|
39
|
+
"@meshsdk/core-cst": "1.7.1",
|
|
40
40
|
"json-bigint": "^1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"prettier": "@meshsdk/configs/prettier",
|