@meshsdk/transaction 1.9.0-beta.3 → 1.9.0-beta.4
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 +108 -39
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +102 -32
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(index_exports);
|
|
41
41
|
|
|
42
42
|
// src/mesh-tx-builder/index.ts
|
|
43
|
+
var import_common2 = require("@meshsdk/common");
|
|
43
44
|
var import_core_cst = require("@meshsdk/core-cst");
|
|
44
45
|
|
|
45
46
|
// src/mesh-tx-builder/tx-builder-core.ts
|
|
@@ -1470,7 +1471,6 @@ var MeshTxBuilderCore = class {
|
|
|
1470
1471
|
}
|
|
1471
1472
|
}
|
|
1472
1473
|
this.meshTxBuilderBody.inputs.push(this.txInQueueItem);
|
|
1473
|
-
this.inputForEvaluation((0, import_common.txInToUtxo)(this.txInQueueItem.txIn));
|
|
1474
1474
|
this.txInQueueItem = void 0;
|
|
1475
1475
|
};
|
|
1476
1476
|
queueMint = () => {
|
|
@@ -1801,25 +1801,93 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
|
|
|
1801
1801
|
for (let collateral of this.meshTxBuilderBody.collaterals) {
|
|
1802
1802
|
collateral.txIn.scriptSize = 0;
|
|
1803
1803
|
}
|
|
1804
|
-
const { inputs, collaterals, mints } = this.meshTxBuilderBody;
|
|
1804
|
+
const { inputs, collaterals, mints, withdrawals, votes, certificates } = this.meshTxBuilderBody;
|
|
1805
1805
|
const incompleteTxIns = [...inputs, ...collaterals].filter(
|
|
1806
1806
|
(txIn) => !this.isInputComplete(txIn)
|
|
1807
1807
|
);
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1808
|
+
let incompleteScriptSources = [];
|
|
1809
|
+
let incompleteSimpleScriptSources = [];
|
|
1810
|
+
inputs.forEach((txIn) => {
|
|
1811
|
+
if (txIn.type === "Script" && txIn.scriptTxIn.scriptSource?.type === "Inline") {
|
|
1812
|
+
if (!this.isRefScriptInfoComplete(txIn.scriptTxIn.scriptSource)) {
|
|
1813
|
+
incompleteScriptSources.push(txIn.scriptTxIn.scriptSource);
|
|
1814
|
+
}
|
|
1815
|
+
} else if (txIn.type === "SimpleScript" && txIn.simpleScriptTxIn?.scriptSource?.type === "Inline") {
|
|
1816
|
+
if (!this.isSimpleRefScriptInfoComplete(
|
|
1817
|
+
txIn.simpleScriptTxIn.scriptSource
|
|
1818
|
+
)) {
|
|
1819
|
+
incompleteSimpleScriptSources.push(
|
|
1820
|
+
txIn.simpleScriptTxIn.scriptSource
|
|
1821
|
+
);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1812
1824
|
});
|
|
1813
|
-
|
|
1825
|
+
mints.forEach((mint) => {
|
|
1814
1826
|
if (mint.type === "Plutus") {
|
|
1815
1827
|
const scriptSource = mint.scriptSource;
|
|
1816
|
-
this.
|
|
1817
|
-
|
|
1818
|
-
|
|
1828
|
+
if (!this.isRefScriptInfoComplete(scriptSource)) {
|
|
1829
|
+
incompleteScriptSources.push(scriptSource);
|
|
1830
|
+
}
|
|
1831
|
+
} else if (mint.type === "Native") {
|
|
1819
1832
|
const scriptSource = mint.scriptSource;
|
|
1820
|
-
this.
|
|
1833
|
+
if (!this.isSimpleRefScriptInfoComplete(scriptSource)) {
|
|
1834
|
+
incompleteSimpleScriptSources.push(scriptSource);
|
|
1835
|
+
}
|
|
1821
1836
|
}
|
|
1822
1837
|
});
|
|
1838
|
+
withdrawals.forEach((withdrawal) => {
|
|
1839
|
+
if (withdrawal.type === "ScriptWithdrawal") {
|
|
1840
|
+
const scriptSource = withdrawal.scriptSource;
|
|
1841
|
+
if (!this.isRefScriptInfoComplete(scriptSource)) {
|
|
1842
|
+
incompleteScriptSources.push(scriptSource);
|
|
1843
|
+
}
|
|
1844
|
+
} else if (withdrawal.type === "SimpleScriptWithdrawal") {
|
|
1845
|
+
const scriptSource = withdrawal.scriptSource;
|
|
1846
|
+
if (!this.isSimpleRefScriptInfoComplete(scriptSource)) {
|
|
1847
|
+
incompleteSimpleScriptSources.push(scriptSource);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
});
|
|
1851
|
+
votes.forEach((vote) => {
|
|
1852
|
+
if (vote.type === "ScriptVote") {
|
|
1853
|
+
const scriptSource = vote.scriptSource;
|
|
1854
|
+
if (!this.isRefScriptInfoComplete(scriptSource)) {
|
|
1855
|
+
incompleteScriptSources.push(scriptSource);
|
|
1856
|
+
}
|
|
1857
|
+
} else if (vote.type === "SimpleScriptVote") {
|
|
1858
|
+
const scriptSource = vote.simpleScriptSource;
|
|
1859
|
+
if (!this.isSimpleRefScriptInfoComplete(scriptSource)) {
|
|
1860
|
+
incompleteSimpleScriptSources.push(scriptSource);
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
});
|
|
1864
|
+
certificates.forEach((certificate) => {
|
|
1865
|
+
if (certificate.type === "ScriptCertificate") {
|
|
1866
|
+
const scriptSource = certificate.scriptSource;
|
|
1867
|
+
if (!this.isRefScriptInfoComplete(scriptSource)) {
|
|
1868
|
+
incompleteScriptSources.push(scriptSource);
|
|
1869
|
+
}
|
|
1870
|
+
} else if (certificate.type === "SimpleScriptCertificate") {
|
|
1871
|
+
const scriptSource = certificate.simpleScriptSource;
|
|
1872
|
+
if (!this.isSimpleRefScriptInfoComplete(scriptSource)) {
|
|
1873
|
+
incompleteSimpleScriptSources.push(scriptSource);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
});
|
|
1877
|
+
await this.queryAllTxInfo(
|
|
1878
|
+
incompleteTxIns,
|
|
1879
|
+
incompleteScriptSources,
|
|
1880
|
+
incompleteSimpleScriptSources
|
|
1881
|
+
);
|
|
1882
|
+
incompleteTxIns.forEach((txIn) => {
|
|
1883
|
+
this.completeTxInformation(txIn);
|
|
1884
|
+
});
|
|
1885
|
+
incompleteScriptSources.forEach((scriptSource) => {
|
|
1886
|
+
this.completeScriptInfo(scriptSource);
|
|
1887
|
+
});
|
|
1888
|
+
incompleteSimpleScriptSources.forEach((simpleScriptSource) => {
|
|
1889
|
+
this.completeSimpleScriptInfo(simpleScriptSource);
|
|
1890
|
+
});
|
|
1823
1891
|
this.meshTxBuilderBody.inputs.forEach((input) => {
|
|
1824
1892
|
if (input.txIn.scriptSize && input.txIn.scriptSize > 0) {
|
|
1825
1893
|
if (this.meshTxBuilderBody.referenceInputs.find((refTxIn) => {
|
|
@@ -1855,11 +1923,15 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
|
|
|
1855
1923
|
if (this.evaluator) {
|
|
1856
1924
|
const txEvaluation = await this.evaluator.evaluateTx(
|
|
1857
1925
|
txHex,
|
|
1858
|
-
Object.values(this.meshTxBuilderBody.inputsForEvaluation)
|
|
1926
|
+
Object.values(this.meshTxBuilderBody.inputsForEvaluation).concat(
|
|
1927
|
+
this.meshTxBuilderBody.inputs.map((val) => (0, import_common2.txInToUtxo)(val.txIn))
|
|
1928
|
+
),
|
|
1859
1929
|
this.meshTxBuilderBody.chainedTxs
|
|
1860
1930
|
).catch((error) => {
|
|
1861
|
-
throw Error(
|
|
1862
|
-
|
|
1931
|
+
throw new Error(
|
|
1932
|
+
`Tx evaluation failed: ${JSON.stringify(error)}
|
|
1933
|
+
For txHex: ${txHex}`
|
|
1934
|
+
);
|
|
1863
1935
|
});
|
|
1864
1936
|
this.updateRedeemer(this.meshTxBuilderBody, txEvaluation);
|
|
1865
1937
|
txHex = this.serializer.serializeTxBody(
|
|
@@ -1920,9 +1992,9 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
|
|
|
1920
1992
|
this.queriedUTxOs[txHash] = utxos;
|
|
1921
1993
|
}
|
|
1922
1994
|
};
|
|
1923
|
-
queryAllTxInfo = (incompleteTxIns,
|
|
1995
|
+
queryAllTxInfo = (incompleteTxIns, incompleteScriptSources, incompleteSimpleScriptSources) => {
|
|
1924
1996
|
const queryUTxOPromises = [];
|
|
1925
|
-
if ((incompleteTxIns.length > 0 ||
|
|
1997
|
+
if ((incompleteTxIns.length > 0 || incompleteScriptSources.length > 0 || incompleteSimpleScriptSources.length) && !this.fetcher)
|
|
1926
1998
|
throw Error(
|
|
1927
1999
|
"Transaction information is incomplete while no fetcher instance is provided. Provide a `fetcher`."
|
|
1928
2000
|
);
|
|
@@ -1931,21 +2003,11 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
|
|
|
1931
2003
|
if (!this.isInputInfoComplete(currentTxIn)) {
|
|
1932
2004
|
queryUTxOPromises.push(this.getUTxOInfo(currentTxIn.txIn.txHash));
|
|
1933
2005
|
}
|
|
1934
|
-
if (currentTxIn.type === "Script" && currentTxIn.scriptTxIn.scriptSource?.type === "Inline" && !this.isRefScriptInfoComplete(currentTxIn.scriptTxIn.scriptSource)) {
|
|
1935
|
-
queryUTxOPromises.push(
|
|
1936
|
-
this.getUTxOInfo(currentTxIn.scriptTxIn.scriptSource.txHash)
|
|
1937
|
-
);
|
|
1938
|
-
}
|
|
1939
2006
|
}
|
|
1940
|
-
for (let i = 0; i <
|
|
1941
|
-
const
|
|
1942
|
-
if (
|
|
1943
|
-
|
|
1944
|
-
if (scriptSource.type === "Inline") {
|
|
1945
|
-
if (!this.isRefScriptInfoComplete(scriptSource)) {
|
|
1946
|
-
queryUTxOPromises.push(this.getUTxOInfo(scriptSource.txHash));
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
2007
|
+
for (let i = 0; i < incompleteScriptSources.length; i++) {
|
|
2008
|
+
const scriptSource = incompleteScriptSources[i];
|
|
2009
|
+
if (scriptSource.type === "Inline") {
|
|
2010
|
+
queryUTxOPromises.push(this.getUTxOInfo(scriptSource.txHash));
|
|
1949
2011
|
}
|
|
1950
2012
|
}
|
|
1951
2013
|
return Promise.all(queryUTxOPromises);
|
|
@@ -2039,6 +2101,13 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
|
|
|
2039
2101
|
}
|
|
2040
2102
|
return true;
|
|
2041
2103
|
};
|
|
2104
|
+
isSimpleRefScriptInfoComplete = (simpleScriptSource) => {
|
|
2105
|
+
if (simpleScriptSource.type === "Inline") {
|
|
2106
|
+
if (!simpleScriptSource.simpleScriptHash || !simpleScriptSource.scriptSize)
|
|
2107
|
+
return false;
|
|
2108
|
+
}
|
|
2109
|
+
return true;
|
|
2110
|
+
};
|
|
2042
2111
|
};
|
|
2043
2112
|
|
|
2044
2113
|
// src/scripts/forge.script.ts
|
|
@@ -2089,7 +2158,7 @@ var ForgeScript = class {
|
|
|
2089
2158
|
};
|
|
2090
2159
|
|
|
2091
2160
|
// src/transaction/index.ts
|
|
2092
|
-
var
|
|
2161
|
+
var import_common3 = require("@meshsdk/common");
|
|
2093
2162
|
var import_core_cst3 = require("@meshsdk/core-cst");
|
|
2094
2163
|
var Transaction = class {
|
|
2095
2164
|
txBuilder;
|
|
@@ -2213,7 +2282,7 @@ var Transaction = class {
|
|
|
2213
2282
|
* @see {@link https://meshjs.dev/apis/transaction#sendToken}
|
|
2214
2283
|
*/
|
|
2215
2284
|
sendToken(recipient, ticker, amount) {
|
|
2216
|
-
const assets = [{ unit:
|
|
2285
|
+
const assets = [{ unit: import_common3.SUPPORTED_TOKENS[ticker], quantity: amount }];
|
|
2217
2286
|
return this.sendAssets(recipient, assets);
|
|
2218
2287
|
}
|
|
2219
2288
|
/**
|
|
@@ -2290,7 +2359,7 @@ var Transaction = class {
|
|
|
2290
2359
|
const { value, script, datum, redeemer } = options;
|
|
2291
2360
|
const red = redeemer || {
|
|
2292
2361
|
data: { alternative: 0, fields: ["mesh"] },
|
|
2293
|
-
budget:
|
|
2362
|
+
budget: import_common3.DEFAULT_REDEEMER_BUDGET
|
|
2294
2363
|
};
|
|
2295
2364
|
if ("code" in script) {
|
|
2296
2365
|
this.isCollateralNeeded = true;
|
|
@@ -2332,10 +2401,10 @@ var Transaction = class {
|
|
|
2332
2401
|
// TODO: nuke this probably as the input type is too confusing
|
|
2333
2402
|
mintAsset(forgeScript, mint, redeemer) {
|
|
2334
2403
|
const assetQuantity = mint.assetQuantity;
|
|
2335
|
-
let assetNameHex = (0,
|
|
2336
|
-
const referenceAssetNameHex = (0,
|
|
2404
|
+
let assetNameHex = (0, import_common3.stringToHex)(mint.assetName);
|
|
2405
|
+
const referenceAssetNameHex = (0, import_common3.CIP68_100)(assetNameHex);
|
|
2337
2406
|
if (mint.cip68ScriptAddress) {
|
|
2338
|
-
assetNameHex = (0,
|
|
2407
|
+
assetNameHex = (0, import_common3.CIP68_222)(assetNameHex);
|
|
2339
2408
|
}
|
|
2340
2409
|
let policyId = "";
|
|
2341
2410
|
switch (typeof forgeScript) {
|
|
@@ -2407,7 +2476,7 @@ var Transaction = class {
|
|
|
2407
2476
|
this.sendAssets(
|
|
2408
2477
|
{
|
|
2409
2478
|
address: mint.cip68ScriptAddress,
|
|
2410
|
-
datum: { inline: true, value: (0,
|
|
2479
|
+
datum: { inline: true, value: (0, import_common3.metadataToCip68)(mint.metadata) }
|
|
2411
2480
|
},
|
|
2412
2481
|
[
|
|
2413
2482
|
{
|
|
@@ -2446,7 +2515,7 @@ var Transaction = class {
|
|
|
2446
2515
|
burnAsset(forgeScript, asset, redeemer) {
|
|
2447
2516
|
const assetQuantity = "-" + asset.quantity;
|
|
2448
2517
|
const mint = {
|
|
2449
|
-
assetName: (0,
|
|
2518
|
+
assetName: (0, import_common3.hexToString)(asset.unit.slice(import_common3.POLICY_ID_LENGTH)),
|
|
2450
2519
|
assetQuantity
|
|
2451
2520
|
};
|
|
2452
2521
|
try {
|
|
@@ -2546,7 +2615,7 @@ var Transaction = class {
|
|
|
2546
2615
|
delegateStake(rewardAddress, poolId) {
|
|
2547
2616
|
this.txBuilder.delegateStakeCertificate(
|
|
2548
2617
|
rewardAddress,
|
|
2549
|
-
this.txBuilder.serializer.
|
|
2618
|
+
this.txBuilder.serializer.deserializer.cert.deserializePoolId(poolId)
|
|
2550
2619
|
);
|
|
2551
2620
|
return this;
|
|
2552
2621
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -569,7 +569,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
569
569
|
* @param txHash The TxIn object that contains the txHash and txIndex, while missing amount and address information
|
|
570
570
|
*/
|
|
571
571
|
protected getUTxOInfo: (txHash: string) => Promise<void>;
|
|
572
|
-
protected queryAllTxInfo: (incompleteTxIns: TxIn[],
|
|
572
|
+
protected queryAllTxInfo: (incompleteTxIns: TxIn[], incompleteScriptSources: ScriptSource[], incompleteSimpleScriptSources: SimpleScriptSourceInfo[]) => Promise<void[]>;
|
|
573
573
|
protected completeTxInformation: (input: TxIn) => void;
|
|
574
574
|
protected completeInputInfo: (input: TxIn) => void;
|
|
575
575
|
protected completeScriptInfo: (scriptSource: ScriptSource) => void;
|
|
@@ -578,6 +578,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
578
578
|
protected isInputInfoComplete: (txIn: TxIn) => boolean;
|
|
579
579
|
protected isMintComplete: (mint: MintItem) => boolean;
|
|
580
580
|
protected isRefScriptInfoComplete: (scriptSource: ScriptSource) => boolean;
|
|
581
|
+
protected isSimpleRefScriptInfoComplete: (simpleScriptSource: SimpleScriptSourceInfo) => boolean;
|
|
581
582
|
}
|
|
582
583
|
|
|
583
584
|
declare class ForgeScript {
|
package/dist/index.d.ts
CHANGED
|
@@ -569,7 +569,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
569
569
|
* @param txHash The TxIn object that contains the txHash and txIndex, while missing amount and address information
|
|
570
570
|
*/
|
|
571
571
|
protected getUTxOInfo: (txHash: string) => Promise<void>;
|
|
572
|
-
protected queryAllTxInfo: (incompleteTxIns: TxIn[],
|
|
572
|
+
protected queryAllTxInfo: (incompleteTxIns: TxIn[], incompleteScriptSources: ScriptSource[], incompleteSimpleScriptSources: SimpleScriptSourceInfo[]) => Promise<void[]>;
|
|
573
573
|
protected completeTxInformation: (input: TxIn) => void;
|
|
574
574
|
protected completeInputInfo: (input: TxIn) => void;
|
|
575
575
|
protected completeScriptInfo: (scriptSource: ScriptSource) => void;
|
|
@@ -578,6 +578,7 @@ declare class MeshTxBuilder extends MeshTxBuilderCore {
|
|
|
578
578
|
protected isInputInfoComplete: (txIn: TxIn) => boolean;
|
|
579
579
|
protected isMintComplete: (mint: MintItem) => boolean;
|
|
580
580
|
protected isRefScriptInfoComplete: (scriptSource: ScriptSource) => boolean;
|
|
581
|
+
protected isSimpleRefScriptInfoComplete: (simpleScriptSource: SimpleScriptSourceInfo) => boolean;
|
|
581
582
|
}
|
|
582
583
|
|
|
583
584
|
declare class ForgeScript {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// src/mesh-tx-builder/index.ts
|
|
2
|
+
import {
|
|
3
|
+
txInToUtxo
|
|
4
|
+
} from "@meshsdk/common";
|
|
2
5
|
import { CardanoSDKSerializer } from "@meshsdk/core-cst";
|
|
3
6
|
|
|
4
7
|
// src/mesh-tx-builder/tx-builder-core.ts
|
|
@@ -8,7 +11,6 @@ import {
|
|
|
8
11
|
DEFAULT_REDEEMER_BUDGET,
|
|
9
12
|
DREP_DEPOSIT,
|
|
10
13
|
emptyTxBuilderBody,
|
|
11
|
-
txInToUtxo,
|
|
12
14
|
UtxoSelection
|
|
13
15
|
} from "@meshsdk/common";
|
|
14
16
|
|
|
@@ -1436,7 +1438,6 @@ var MeshTxBuilderCore = class {
|
|
|
1436
1438
|
}
|
|
1437
1439
|
}
|
|
1438
1440
|
this.meshTxBuilderBody.inputs.push(this.txInQueueItem);
|
|
1439
|
-
this.inputForEvaluation(txInToUtxo(this.txInQueueItem.txIn));
|
|
1440
1441
|
this.txInQueueItem = void 0;
|
|
1441
1442
|
};
|
|
1442
1443
|
queueMint = () => {
|
|
@@ -1767,25 +1768,93 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
|
|
|
1767
1768
|
for (let collateral of this.meshTxBuilderBody.collaterals) {
|
|
1768
1769
|
collateral.txIn.scriptSize = 0;
|
|
1769
1770
|
}
|
|
1770
|
-
const { inputs, collaterals, mints } = this.meshTxBuilderBody;
|
|
1771
|
+
const { inputs, collaterals, mints, withdrawals, votes, certificates } = this.meshTxBuilderBody;
|
|
1771
1772
|
const incompleteTxIns = [...inputs, ...collaterals].filter(
|
|
1772
1773
|
(txIn) => !this.isInputComplete(txIn)
|
|
1773
1774
|
);
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1775
|
+
let incompleteScriptSources = [];
|
|
1776
|
+
let incompleteSimpleScriptSources = [];
|
|
1777
|
+
inputs.forEach((txIn) => {
|
|
1778
|
+
if (txIn.type === "Script" && txIn.scriptTxIn.scriptSource?.type === "Inline") {
|
|
1779
|
+
if (!this.isRefScriptInfoComplete(txIn.scriptTxIn.scriptSource)) {
|
|
1780
|
+
incompleteScriptSources.push(txIn.scriptTxIn.scriptSource);
|
|
1781
|
+
}
|
|
1782
|
+
} else if (txIn.type === "SimpleScript" && txIn.simpleScriptTxIn?.scriptSource?.type === "Inline") {
|
|
1783
|
+
if (!this.isSimpleRefScriptInfoComplete(
|
|
1784
|
+
txIn.simpleScriptTxIn.scriptSource
|
|
1785
|
+
)) {
|
|
1786
|
+
incompleteSimpleScriptSources.push(
|
|
1787
|
+
txIn.simpleScriptTxIn.scriptSource
|
|
1788
|
+
);
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1778
1791
|
});
|
|
1779
|
-
|
|
1792
|
+
mints.forEach((mint) => {
|
|
1780
1793
|
if (mint.type === "Plutus") {
|
|
1781
1794
|
const scriptSource = mint.scriptSource;
|
|
1782
|
-
this.
|
|
1783
|
-
|
|
1784
|
-
|
|
1795
|
+
if (!this.isRefScriptInfoComplete(scriptSource)) {
|
|
1796
|
+
incompleteScriptSources.push(scriptSource);
|
|
1797
|
+
}
|
|
1798
|
+
} else if (mint.type === "Native") {
|
|
1785
1799
|
const scriptSource = mint.scriptSource;
|
|
1786
|
-
this.
|
|
1800
|
+
if (!this.isSimpleRefScriptInfoComplete(scriptSource)) {
|
|
1801
|
+
incompleteSimpleScriptSources.push(scriptSource);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
});
|
|
1805
|
+
withdrawals.forEach((withdrawal) => {
|
|
1806
|
+
if (withdrawal.type === "ScriptWithdrawal") {
|
|
1807
|
+
const scriptSource = withdrawal.scriptSource;
|
|
1808
|
+
if (!this.isRefScriptInfoComplete(scriptSource)) {
|
|
1809
|
+
incompleteScriptSources.push(scriptSource);
|
|
1810
|
+
}
|
|
1811
|
+
} else if (withdrawal.type === "SimpleScriptWithdrawal") {
|
|
1812
|
+
const scriptSource = withdrawal.scriptSource;
|
|
1813
|
+
if (!this.isSimpleRefScriptInfoComplete(scriptSource)) {
|
|
1814
|
+
incompleteSimpleScriptSources.push(scriptSource);
|
|
1815
|
+
}
|
|
1787
1816
|
}
|
|
1788
1817
|
});
|
|
1818
|
+
votes.forEach((vote) => {
|
|
1819
|
+
if (vote.type === "ScriptVote") {
|
|
1820
|
+
const scriptSource = vote.scriptSource;
|
|
1821
|
+
if (!this.isRefScriptInfoComplete(scriptSource)) {
|
|
1822
|
+
incompleteScriptSources.push(scriptSource);
|
|
1823
|
+
}
|
|
1824
|
+
} else if (vote.type === "SimpleScriptVote") {
|
|
1825
|
+
const scriptSource = vote.simpleScriptSource;
|
|
1826
|
+
if (!this.isSimpleRefScriptInfoComplete(scriptSource)) {
|
|
1827
|
+
incompleteSimpleScriptSources.push(scriptSource);
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
});
|
|
1831
|
+
certificates.forEach((certificate) => {
|
|
1832
|
+
if (certificate.type === "ScriptCertificate") {
|
|
1833
|
+
const scriptSource = certificate.scriptSource;
|
|
1834
|
+
if (!this.isRefScriptInfoComplete(scriptSource)) {
|
|
1835
|
+
incompleteScriptSources.push(scriptSource);
|
|
1836
|
+
}
|
|
1837
|
+
} else if (certificate.type === "SimpleScriptCertificate") {
|
|
1838
|
+
const scriptSource = certificate.simpleScriptSource;
|
|
1839
|
+
if (!this.isSimpleRefScriptInfoComplete(scriptSource)) {
|
|
1840
|
+
incompleteSimpleScriptSources.push(scriptSource);
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
await this.queryAllTxInfo(
|
|
1845
|
+
incompleteTxIns,
|
|
1846
|
+
incompleteScriptSources,
|
|
1847
|
+
incompleteSimpleScriptSources
|
|
1848
|
+
);
|
|
1849
|
+
incompleteTxIns.forEach((txIn) => {
|
|
1850
|
+
this.completeTxInformation(txIn);
|
|
1851
|
+
});
|
|
1852
|
+
incompleteScriptSources.forEach((scriptSource) => {
|
|
1853
|
+
this.completeScriptInfo(scriptSource);
|
|
1854
|
+
});
|
|
1855
|
+
incompleteSimpleScriptSources.forEach((simpleScriptSource) => {
|
|
1856
|
+
this.completeSimpleScriptInfo(simpleScriptSource);
|
|
1857
|
+
});
|
|
1789
1858
|
this.meshTxBuilderBody.inputs.forEach((input) => {
|
|
1790
1859
|
if (input.txIn.scriptSize && input.txIn.scriptSize > 0) {
|
|
1791
1860
|
if (this.meshTxBuilderBody.referenceInputs.find((refTxIn) => {
|
|
@@ -1821,11 +1890,15 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
|
|
|
1821
1890
|
if (this.evaluator) {
|
|
1822
1891
|
const txEvaluation = await this.evaluator.evaluateTx(
|
|
1823
1892
|
txHex,
|
|
1824
|
-
Object.values(this.meshTxBuilderBody.inputsForEvaluation)
|
|
1893
|
+
Object.values(this.meshTxBuilderBody.inputsForEvaluation).concat(
|
|
1894
|
+
this.meshTxBuilderBody.inputs.map((val) => txInToUtxo(val.txIn))
|
|
1895
|
+
),
|
|
1825
1896
|
this.meshTxBuilderBody.chainedTxs
|
|
1826
1897
|
).catch((error) => {
|
|
1827
|
-
throw Error(
|
|
1828
|
-
|
|
1898
|
+
throw new Error(
|
|
1899
|
+
`Tx evaluation failed: ${JSON.stringify(error)}
|
|
1900
|
+
For txHex: ${txHex}`
|
|
1901
|
+
);
|
|
1829
1902
|
});
|
|
1830
1903
|
this.updateRedeemer(this.meshTxBuilderBody, txEvaluation);
|
|
1831
1904
|
txHex = this.serializer.serializeTxBody(
|
|
@@ -1886,9 +1959,9 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
|
|
|
1886
1959
|
this.queriedUTxOs[txHash] = utxos;
|
|
1887
1960
|
}
|
|
1888
1961
|
};
|
|
1889
|
-
queryAllTxInfo = (incompleteTxIns,
|
|
1962
|
+
queryAllTxInfo = (incompleteTxIns, incompleteScriptSources, incompleteSimpleScriptSources) => {
|
|
1890
1963
|
const queryUTxOPromises = [];
|
|
1891
|
-
if ((incompleteTxIns.length > 0 ||
|
|
1964
|
+
if ((incompleteTxIns.length > 0 || incompleteScriptSources.length > 0 || incompleteSimpleScriptSources.length) && !this.fetcher)
|
|
1892
1965
|
throw Error(
|
|
1893
1966
|
"Transaction information is incomplete while no fetcher instance is provided. Provide a `fetcher`."
|
|
1894
1967
|
);
|
|
@@ -1897,21 +1970,11 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
|
|
|
1897
1970
|
if (!this.isInputInfoComplete(currentTxIn)) {
|
|
1898
1971
|
queryUTxOPromises.push(this.getUTxOInfo(currentTxIn.txIn.txHash));
|
|
1899
1972
|
}
|
|
1900
|
-
if (currentTxIn.type === "Script" && currentTxIn.scriptTxIn.scriptSource?.type === "Inline" && !this.isRefScriptInfoComplete(currentTxIn.scriptTxIn.scriptSource)) {
|
|
1901
|
-
queryUTxOPromises.push(
|
|
1902
|
-
this.getUTxOInfo(currentTxIn.scriptTxIn.scriptSource.txHash)
|
|
1903
|
-
);
|
|
1904
|
-
}
|
|
1905
1973
|
}
|
|
1906
|
-
for (let i = 0; i <
|
|
1907
|
-
const
|
|
1908
|
-
if (
|
|
1909
|
-
|
|
1910
|
-
if (scriptSource.type === "Inline") {
|
|
1911
|
-
if (!this.isRefScriptInfoComplete(scriptSource)) {
|
|
1912
|
-
queryUTxOPromises.push(this.getUTxOInfo(scriptSource.txHash));
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
1974
|
+
for (let i = 0; i < incompleteScriptSources.length; i++) {
|
|
1975
|
+
const scriptSource = incompleteScriptSources[i];
|
|
1976
|
+
if (scriptSource.type === "Inline") {
|
|
1977
|
+
queryUTxOPromises.push(this.getUTxOInfo(scriptSource.txHash));
|
|
1915
1978
|
}
|
|
1916
1979
|
}
|
|
1917
1980
|
return Promise.all(queryUTxOPromises);
|
|
@@ -2005,6 +2068,13 @@ var MeshTxBuilder = class extends MeshTxBuilderCore {
|
|
|
2005
2068
|
}
|
|
2006
2069
|
return true;
|
|
2007
2070
|
};
|
|
2071
|
+
isSimpleRefScriptInfoComplete = (simpleScriptSource) => {
|
|
2072
|
+
if (simpleScriptSource.type === "Inline") {
|
|
2073
|
+
if (!simpleScriptSource.simpleScriptHash || !simpleScriptSource.scriptSize)
|
|
2074
|
+
return false;
|
|
2075
|
+
}
|
|
2076
|
+
return true;
|
|
2077
|
+
};
|
|
2008
2078
|
};
|
|
2009
2079
|
|
|
2010
2080
|
// src/scripts/forge.script.ts
|
|
@@ -2535,7 +2605,7 @@ var Transaction = class {
|
|
|
2535
2605
|
delegateStake(rewardAddress, poolId) {
|
|
2536
2606
|
this.txBuilder.delegateStakeCertificate(
|
|
2537
2607
|
rewardAddress,
|
|
2538
|
-
this.txBuilder.serializer.
|
|
2608
|
+
this.txBuilder.serializer.deserializer.cert.deserializePoolId(poolId)
|
|
2539
2609
|
);
|
|
2540
2610
|
return this;
|
|
2541
2611
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/transaction",
|
|
3
|
-
"version": "1.9.0-beta.
|
|
3
|
+
"version": "1.9.0-beta.4",
|
|
4
4
|
"description": "Transactions - https://meshjs.dev/apis/transaction",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"browser": "./dist/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"typescript": "^5.3.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@meshsdk/common": "1.9.0-beta.
|
|
39
|
-
"@meshsdk/core-cst": "1.9.0-beta.
|
|
38
|
+
"@meshsdk/common": "1.9.0-beta.4",
|
|
39
|
+
"@meshsdk/core-cst": "1.9.0-beta.4",
|
|
40
40
|
"json-bigint": "^1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"prettier": "@meshsdk/configs/prettier",
|