@meshsdk/common 1.9.0-beta.10 → 1.9.0-beta.100

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 CHANGED
@@ -34,12 +34,14 @@ __export(index_exports, {
34
34
  BigNum: () => BigNum,
35
35
  CIP68_100: () => CIP68_100,
36
36
  CIP68_222: () => CIP68_222,
37
+ DEFAULT_FETCHER_OPTIONS: () => DEFAULT_FETCHER_OPTIONS,
37
38
  DEFAULT_PROTOCOL_PARAMETERS: () => DEFAULT_PROTOCOL_PARAMETERS,
38
39
  DEFAULT_REDEEMER_BUDGET: () => DEFAULT_REDEEMER_BUDGET,
39
40
  DEFAULT_V1_COST_MODEL_LIST: () => DEFAULT_V1_COST_MODEL_LIST,
40
41
  DEFAULT_V2_COST_MODEL_LIST: () => DEFAULT_V2_COST_MODEL_LIST,
41
42
  DEFAULT_V3_COST_MODEL_LIST: () => DEFAULT_V3_COST_MODEL_LIST,
42
43
  DREP_DEPOSIT: () => DREP_DEPOSIT,
44
+ GovernanceActionKind: () => GovernanceActionKind,
43
45
  HARDENED_KEY_START: () => HARDENED_KEY_START,
44
46
  LANGUAGE_VERSIONS: () => LANGUAGE_VERSIONS,
45
47
  MeshValue: () => MeshValue,
@@ -51,7 +53,9 @@ __export(index_exports, {
51
53
  SUPPORTED_OGMIOS_LINKS: () => SUPPORTED_OGMIOS_LINKS,
52
54
  SUPPORTED_TOKENS: () => SUPPORTED_TOKENS,
53
55
  SUPPORTED_WALLETS: () => SUPPORTED_WALLETS,
56
+ TxTester: () => TxTester,
54
57
  UtxoSelection: () => UtxoSelection,
58
+ VOTING_PROPOSAL_DEPOSIT: () => VOTING_PROPOSAL_DEPOSIT,
55
59
  assetClass: () => assetClass,
56
60
  assetName: () => assetName,
57
61
  assocMap: () => assocMap,
@@ -60,11 +64,13 @@ __export(index_exports, {
60
64
  byteString: () => byteString,
61
65
  bytesToHex: () => bytesToHex,
62
66
  castProtocol: () => castProtocol,
67
+ cloneTxBuilderBody: () => cloneTxBuilderBody,
63
68
  conStr: () => conStr,
64
69
  conStr0: () => conStr0,
65
70
  conStr1: () => conStr1,
66
71
  conStr2: () => conStr2,
67
72
  conStr3: () => conStr3,
73
+ credential: () => credential,
68
74
  currencySymbol: () => currencySymbol,
69
75
  dict: () => dict,
70
76
  emptyTxBuilderBody: () => emptyTxBuilderBody,
@@ -78,8 +84,11 @@ __export(index_exports, {
78
84
  hexToBytes: () => hexToBytes,
79
85
  hexToString: () => hexToString,
80
86
  integer: () => integer,
87
+ isHexString: () => isHexString,
81
88
  isNetwork: () => isNetwork,
89
+ jsonProofToPlutusData: () => jsonProofToPlutusData,
82
90
  keepRelevant: () => keepRelevant,
91
+ keySignedLogic: () => keySignedLogic,
83
92
  largestFirst: () => largestFirst,
84
93
  largestFirstMultiAsset: () => largestFirstMultiAsset,
85
94
  list: () => list,
@@ -90,18 +99,21 @@ __export(index_exports, {
90
99
  mConStr1: () => mConStr1,
91
100
  mConStr2: () => mConStr2,
92
101
  mConStr3: () => mConStr3,
102
+ mCredential: () => mCredential,
93
103
  mMaybeStakingHash: () => mMaybeStakingHash,
94
104
  mNone: () => mNone,
95
105
  mOption: () => mOption,
96
106
  mOutputReference: () => mOutputReference,
97
107
  mPlutusBSArrayToString: () => mPlutusBSArrayToString,
98
108
  mPubKeyAddress: () => mPubKeyAddress,
109
+ mScript: () => mScript,
99
110
  mScriptAddress: () => mScriptAddress,
100
111
  mSome: () => mSome,
101
112
  mStringToPlutusBSArray: () => mStringToPlutusBSArray,
102
113
  mTuple: () => mTuple,
103
114
  mTxOutRef: () => mTxOutRef,
104
115
  mValue: () => mValue,
116
+ mVerificationKey: () => mVerificationKey,
105
117
  maybeStakingHash: () => maybeStakingHash,
106
118
  mergeAssets: () => mergeAssets,
107
119
  metadataStandardKeys: () => metadataStandardKeys,
@@ -110,6 +122,7 @@ __export(index_exports, {
110
122
  none: () => none,
111
123
  option: () => option,
112
124
  outputReference: () => outputReference,
125
+ pairs: () => pairs,
113
126
  parseAssetUnit: () => parseAssetUnit,
114
127
  plutusBSArrayToString: () => plutusBSArrayToString,
115
128
  policyId: () => policyId,
@@ -122,6 +135,7 @@ __export(index_exports, {
122
135
  resolveSlotNo: () => resolveSlotNo,
123
136
  resolveTxFees: () => resolveTxFees,
124
137
  royaltiesStandardKeys: () => royaltiesStandardKeys,
138
+ script: () => script,
125
139
  scriptAddress: () => scriptAddress,
126
140
  scriptHash: () => scriptHash,
127
141
  slotToBeginUnixTime: () => slotToBeginUnixTime,
@@ -130,13 +144,16 @@ __export(index_exports, {
130
144
  stringToHex: () => stringToHex,
131
145
  toBytes: () => toBytes,
132
146
  toUTF8: () => toUTF8,
147
+ tokenMintedLogic: () => tokenMintedLogic,
133
148
  tokenName: () => tokenName,
134
149
  tuple: () => tuple,
135
150
  txInToUtxo: () => txInToUtxo,
136
151
  txOutRef: () => txOutRef,
137
152
  unixTimeToEnclosingSlot: () => unixTimeToEnclosingSlot,
153
+ validityRangeFromObj: () => validityRangeFromObj,
138
154
  validityRangeToObj: () => validityRangeToObj,
139
- value: () => value
155
+ value: () => value,
156
+ verificationKey: () => verificationKey
140
157
  });
141
158
  module.exports = __toCommonJS(index_exports);
142
159
 
@@ -165,6 +182,7 @@ var DEFAULT_PROTOCOL_PARAMETERS = {
165
182
  minFeeRefScriptCostPerByte: 15
166
183
  };
167
184
  var DREP_DEPOSIT = "500000000";
185
+ var VOTING_PROPOSAL_DEPOSIT = "100000000000";
168
186
  var resolveTxFees = (txSize, minFeeA = DEFAULT_PROTOCOL_PARAMETERS.minFeeA, minFeeB = DEFAULT_PROTOCOL_PARAMETERS.minFeeB) => {
169
187
  const fees = BigInt(minFeeA) * BigInt(txSize) + BigInt(minFeeB);
170
188
  return fees.toString();
@@ -909,6 +927,12 @@ var CIP68_222 = (tokenNameHex) => {
909
927
  return `000de140${tokenNameHex}`;
910
928
  };
911
929
 
930
+ // src/interfaces/fetcher.ts
931
+ var DEFAULT_FETCHER_OPTIONS = {
932
+ maxPage: 20,
933
+ order: "desc"
934
+ };
935
+
912
936
  // src/types/asset.ts
913
937
  var mergeAssets = (assets) => {
914
938
  const merged = [];
@@ -996,6 +1020,7 @@ var txInToUtxo = (txIn) => {
996
1020
  var emptyTxBuilderBody = () => ({
997
1021
  inputs: [],
998
1022
  outputs: [],
1023
+ fee: "0",
999
1024
  extraInputs: [],
1000
1025
  collaterals: [],
1001
1026
  requiredSignatures: [],
@@ -1003,26 +1028,53 @@ var emptyTxBuilderBody = () => ({
1003
1028
  mints: [],
1004
1029
  changeAddress: "",
1005
1030
  metadata: /* @__PURE__ */ new Map(),
1031
+ scriptMetadata: [],
1006
1032
  validityRange: {},
1007
1033
  certificates: [],
1008
1034
  withdrawals: [],
1009
1035
  votes: [],
1036
+ proposals: [],
1010
1037
  signingKey: [],
1011
- selectionConfig: {
1012
- threshold: "0",
1013
- strategy: "experimental",
1014
- includeTxFees: true
1015
- },
1016
1038
  chainedTxs: [],
1017
1039
  inputsForEvaluation: {},
1018
- network: "mainnet"
1040
+ network: "mainnet",
1041
+ expectedNumberKeyWitnesses: 0,
1042
+ expectedByronAddressWitnesses: []
1019
1043
  });
1044
+ function cloneTxBuilderBody(body) {
1045
+ const { extraInputs, ...otherProps } = body;
1046
+ const cloned = structuredClone(otherProps);
1047
+ cloned.extraInputs = extraInputs;
1048
+ return cloned;
1049
+ }
1020
1050
  var validityRangeToObj = (validityRange) => {
1021
1051
  return {
1022
1052
  invalidBefore: validityRange.invalidBefore ?? null,
1023
1053
  invalidHereafter: validityRange.invalidHereafter ?? null
1024
1054
  };
1025
1055
  };
1056
+ var validityRangeFromObj = (obj) => {
1057
+ const validityRange = {};
1058
+ if (obj.invalidBefore !== null && obj.invalidBefore !== void 0) {
1059
+ validityRange.invalidBefore = Number(obj.invalidBefore);
1060
+ }
1061
+ if (obj.invalidHereafter !== null && obj.invalidHereafter !== void 0) {
1062
+ validityRange.invalidHereafter = Number(obj.invalidHereafter);
1063
+ }
1064
+ return validityRange;
1065
+ };
1066
+
1067
+ // src/types/governance.ts
1068
+ var GovernanceActionKind = /* @__PURE__ */ ((GovernanceActionKind2) => {
1069
+ GovernanceActionKind2["ParameterChangeAction"] = "ParameterChangeAction";
1070
+ GovernanceActionKind2["HardForkInitiationAction"] = "HardForkInitiationAction";
1071
+ GovernanceActionKind2["TreasuryWithdrawalsAction"] = "TreasuryWithdrawalsAction";
1072
+ GovernanceActionKind2["NoConfidenceAction"] = "NoConfidenceAction";
1073
+ GovernanceActionKind2["UpdateCommitteeAction"] = "UpdateCommitteeAction";
1074
+ GovernanceActionKind2["NewConstitutionAction"] = "NewConstitutionAction";
1075
+ GovernanceActionKind2["InfoAction"] = "InfoAction";
1076
+ return GovernanceActionKind2;
1077
+ })(GovernanceActionKind || {});
1026
1078
 
1027
1079
  // src/data/mesh/constructors.ts
1028
1080
  var mConStr = (alternative, fields) => ({
@@ -1072,7 +1124,7 @@ var mTxOutRef = (txHash, index) => {
1072
1124
  }
1073
1125
  return mConStr0([mConStr0([txHash]), index]);
1074
1126
  };
1075
- var mTuple = (key, value2) => [key, value2];
1127
+ var mTuple = (...args) => args;
1076
1128
  var mOption = (value2) => {
1077
1129
  if (value2) {
1078
1130
  return mSome(value2);
@@ -1083,14 +1135,16 @@ var mSome = (value2) => mConStr0([value2]);
1083
1135
  var mNone = () => mConStr1([]);
1084
1136
 
1085
1137
  // src/data/mesh/credentials.ts
1138
+ var mVerificationKey = (bytes) => mConStr0([bytes]);
1139
+ var mScript = (bytes) => mConStr1([bytes]);
1086
1140
  var mMaybeStakingHash = (stakeCredential, isStakeScriptCredential = false) => {
1087
1141
  if (stakeCredential === "") {
1088
1142
  return mConStr1([]);
1089
1143
  }
1090
1144
  if (isStakeScriptCredential) {
1091
- return mConStr0([mConStr0([mConStr1([stakeCredential])])]);
1145
+ return mConStr0([mConStr0([mScript(stakeCredential)])]);
1092
1146
  }
1093
- return mConStr0([mConStr0([mConStr0([stakeCredential])])]);
1147
+ return mConStr0([mConStr0([mVerificationKey(stakeCredential)])]);
1094
1148
  };
1095
1149
  var mPubKeyAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => mConStr0([
1096
1150
  { alternative: 0, fields: [bytes] },
@@ -1100,6 +1154,7 @@ var mScriptAddress = (bytes, stakeCredential, isStakeScriptCredential = false) =
1100
1154
  { alternative: 1, fields: [bytes] },
1101
1155
  mMaybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1102
1156
  ]);
1157
+ var mCredential = (hash, isScriptCredential = false) => isScriptCredential ? mScript(hash) : mVerificationKey(hash);
1103
1158
 
1104
1159
  // src/data/mesh/primitives.ts
1105
1160
  var mBool = (b) => b ? mConStr1([]) : mConStr0([]);
@@ -1187,11 +1242,25 @@ var assocMap = (mapItems, validation = true) => ({
1187
1242
  return { k, v };
1188
1243
  })
1189
1244
  });
1245
+ var pairs = (mapItems, validation = true) => ({
1246
+ map: mapItems.map(([k, v]) => {
1247
+ if (validation) {
1248
+ if (typeof k !== "object" || typeof v !== "object") {
1249
+ throw new Error(
1250
+ `Map item of JSON Cardano data type must be an object - ${k}, ${v}`
1251
+ );
1252
+ }
1253
+ }
1254
+ return { k, v };
1255
+ })
1256
+ });
1190
1257
 
1191
1258
  // src/data/json/aliases.ts
1192
1259
  var hashByteString = (bytes) => {
1193
1260
  if (bytes.length !== 56) {
1194
- throw new Error(`Invalid hash for [${bytes}] - should be 56 bytes long`);
1261
+ throw new Error(
1262
+ `Invalid hash for [${bytes}] - should be 28 bytes (56 hex length) long`
1263
+ );
1195
1264
  }
1196
1265
  return byteString(bytes);
1197
1266
  };
@@ -1200,7 +1269,7 @@ var pubKeyHash = (bytes) => hashByteString(bytes);
1200
1269
  var policyId = (bytes) => {
1201
1270
  if (bytes.length !== POLICY_ID_LENGTH && bytes !== "") {
1202
1271
  throw new Error(
1203
- `Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH} bytes long or empty string for lovelace`
1272
+ `Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH / 2} bytes (${POLICY_ID_LENGTH} hex length) long or empty string for lovelace`
1204
1273
  );
1205
1274
  }
1206
1275
  return byteString(bytes);
@@ -1232,7 +1301,9 @@ var posixTime = (int) => ({ int });
1232
1301
  var dict = (itemsMap) => ({
1233
1302
  map: itemsMap.map(([k, v]) => ({ k, v }))
1234
1303
  });
1235
- var tuple = (key, value2) => ({ list: [key, value2] });
1304
+ var tuple = (...args) => ({
1305
+ list: args
1306
+ });
1236
1307
  var option = (value2) => {
1237
1308
  if (!value2) {
1238
1309
  return none();
@@ -1243,32 +1314,62 @@ var some = (value2) => conStr0([value2]);
1243
1314
  var none = () => conStr1([]);
1244
1315
 
1245
1316
  // src/data/json/credentials.ts
1317
+ var verificationKey = (bytes) => conStr0([pubKeyHash(bytes)]);
1318
+ var script = (bytes) => conStr1([scriptHash(bytes)]);
1246
1319
  var maybeStakingHash = (stakeCredential, isStakeScriptCredential = false) => {
1247
1320
  if (stakeCredential === "") {
1248
1321
  return conStr1([]);
1249
1322
  }
1250
1323
  if (isStakeScriptCredential) {
1251
- return conStr0([
1252
- conStr0([conStr1([scriptHash(stakeCredential)])])
1253
- ]);
1324
+ return conStr0([conStr0([script(stakeCredential)])]);
1254
1325
  }
1255
- return conStr0([
1256
- conStr0([conStr0([pubKeyHash(stakeCredential)])])
1257
- ]);
1326
+ return conStr0([conStr0([verificationKey(stakeCredential)])]);
1258
1327
  };
1259
1328
  var pubKeyAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => conStr0([
1260
1329
  conStr0([pubKeyHash(bytes)]),
1261
1330
  maybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1262
1331
  ]);
1263
1332
  var scriptAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => conStr0([
1264
- conStr1([scriptHash(bytes)]),
1333
+ script(bytes),
1265
1334
  maybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1266
1335
  ]);
1336
+ var credential = (hash, isScriptCredential = false) => isScriptCredential ? script(hash) : verificationKey(hash);
1337
+
1338
+ // src/data/json/mpf.ts
1339
+ var jsonProofToPlutusData = (proof) => {
1340
+ const proofSteps = [];
1341
+ const proofJson = proof;
1342
+ proofJson.forEach((proof2) => {
1343
+ const skip = integer(proof2.skip);
1344
+ switch (proof2.type) {
1345
+ case "branch":
1346
+ proofSteps.push(
1347
+ conStr0([skip, byteString(proof2.neighbors.toString("hex"))])
1348
+ );
1349
+ break;
1350
+ case "fork":
1351
+ const { prefix, nibble, root } = proof2.neighbor;
1352
+ const neighbor = conStr0([
1353
+ integer(nibble),
1354
+ byteString(prefix.toString("hex")),
1355
+ byteString(root.toString("hex"))
1356
+ ]);
1357
+ proofSteps.push(conStr1([skip, neighbor]));
1358
+ break;
1359
+ case "leaf":
1360
+ const { key, value: value2 } = proof2.neighbor;
1361
+ proofSteps.push(conStr2([skip, byteString(key), byteString(value2)]));
1362
+ break;
1363
+ }
1364
+ });
1365
+ return proofSteps;
1366
+ };
1267
1367
 
1268
1368
  // src/data/parser.ts
1269
1369
  var bytesToHex = (bytes) => Buffer.from(bytes).toString("hex");
1270
1370
  var hexToBytes = (hex) => Buffer.from(hex, "hex");
1271
1371
  var stringToHex = (str) => Buffer.from(str, "utf8").toString("hex");
1372
+ var isHexString = (hex) => /^[0-9A-F]*$/i.test(hex);
1272
1373
  var hexToString = (hex) => Buffer.from(hex, "hex").toString("utf8");
1273
1374
  var toBytes = (hex) => {
1274
1375
  if (hex.length % 2 === 0 && /^[0-9A-F]*$/i.test(hex))
@@ -1449,8 +1550,8 @@ var BigNum = class _BigNum {
1449
1550
  // src/utils/data-hash.ts
1450
1551
  var import_blakejs = require("blakejs");
1451
1552
  var hashDrepAnchor = (jsonLD) => {
1452
- const jsonHash = (0, import_blakejs.blake2bHex)(JSON.stringify(jsonLD, null, 2), void 0, 32);
1453
- return jsonHash;
1553
+ const jsonHash = (0, import_blakejs.blake2b)(JSON.stringify(jsonLD, null, 2), void 0, 32);
1554
+ return Buffer.from(jsonHash).toString("hex");
1454
1555
  };
1455
1556
 
1456
1557
  // src/utils/file.ts
@@ -1462,6 +1563,7 @@ function getFile(url) {
1462
1563
  }
1463
1564
 
1464
1565
  // src/data/value.ts
1566
+ var compareByteOrder = (a, b) => a < b ? -1 : a > b ? 1 : 0;
1465
1567
  var value = (assets) => {
1466
1568
  return MeshValue.fromAssets(assets).toJSON();
1467
1569
  };
@@ -1473,6 +1575,26 @@ var MeshValue = class _MeshValue {
1473
1575
  constructor(value2 = {}) {
1474
1576
  this.value = value2;
1475
1577
  }
1578
+ /**
1579
+ * Sort a Value (JSON representation) by policy ID then token name
1580
+ * @param plutusValue The Value to sort
1581
+ * @returns Sorted Value
1582
+ */
1583
+ static sortValue = (plutusValue) => {
1584
+ const sortedPolicies = [...plutusValue.map].sort(
1585
+ (a, b) => compareByteOrder(a.k.bytes, b.k.bytes)
1586
+ );
1587
+ const sortedMap = sortedPolicies.map((policyEntry) => {
1588
+ const sortedTokens = [...policyEntry.v.map].sort(
1589
+ (a, b) => compareByteOrder(a.k.bytes, b.k.bytes)
1590
+ );
1591
+ return {
1592
+ k: policyEntry.k,
1593
+ v: { map: sortedTokens }
1594
+ };
1595
+ });
1596
+ return { map: sortedMap };
1597
+ };
1476
1598
  /**
1477
1599
  * Converting assets into MeshValue
1478
1600
  * @param assets The assets to convert
@@ -1563,6 +1685,23 @@ var MeshValue = class _MeshValue {
1563
1685
  get = (unit) => {
1564
1686
  return this.value[unit] ? BigInt(this.value[unit]) : BigInt(0);
1565
1687
  };
1688
+ /**
1689
+ * Get all assets that belong to a specific policy ID
1690
+ * @param policyId The policy ID to filter by
1691
+ * @returns Array of assets that match the policy ID
1692
+ */
1693
+ getPolicyAssets = (policyId2) => {
1694
+ const assets = [];
1695
+ Object.entries(this.value).forEach(([unit, quantity]) => {
1696
+ if (unit.startsWith(policyId2)) {
1697
+ assets.push({
1698
+ unit,
1699
+ quantity: quantity.toString()
1700
+ });
1701
+ }
1702
+ });
1703
+ return assets;
1704
+ };
1566
1705
  /**
1567
1706
  * Get all asset units
1568
1707
  * @returns The asset units
@@ -1610,6 +1749,26 @@ var MeshValue = class _MeshValue {
1610
1749
  }
1611
1750
  return BigInt(this.value[unit]) <= BigInt(other.value[unit]);
1612
1751
  };
1752
+ /**
1753
+ * Check if the value is equal to another value
1754
+ * @param other - The value to compare against
1755
+ * @returns boolean
1756
+ */
1757
+ eq = (other) => {
1758
+ return Object.keys(this.value).every((key) => this.eqUnit(key, other));
1759
+ };
1760
+ /**
1761
+ * Check if the specific unit of value is equal to that unit of another value
1762
+ * @param unit - The unit to compare
1763
+ * @param other - The value to compare against
1764
+ * @returns boolean
1765
+ */
1766
+ eqUnit = (unit, other) => {
1767
+ if (this.value[unit] === void 0 || other.value[unit] === void 0) {
1768
+ return false;
1769
+ }
1770
+ return BigInt(this.value[unit]) === BigInt(other.value[unit]);
1771
+ };
1613
1772
  /**
1614
1773
  * Check if the value is empty
1615
1774
  * @returns boolean
@@ -1644,17 +1803,18 @@ var MeshValue = class _MeshValue {
1644
1803
  };
1645
1804
  /**
1646
1805
  * Convert the MeshValue object into Cardano data Value in Mesh Data type
1806
+ * Entries are sorted by byte ordering of policy ID, then token name
1647
1807
  */
1648
1808
  toData = () => {
1649
- const valueMap = /* @__PURE__ */ new Map();
1809
+ const unsortedMap = /* @__PURE__ */ new Map();
1650
1810
  this.toAssets().forEach((asset) => {
1651
1811
  const sanitizedName = asset.unit.replace("lovelace", "");
1652
1812
  const policy = sanitizedName.slice(0, 56) || "";
1653
1813
  const token = sanitizedName.slice(56) || "";
1654
- if (!valueMap.has(policy)) {
1655
- valueMap.set(policy, /* @__PURE__ */ new Map());
1814
+ if (!unsortedMap.has(policy)) {
1815
+ unsortedMap.set(policy, /* @__PURE__ */ new Map());
1656
1816
  }
1657
- const tokenMap = valueMap.get(policy);
1817
+ const tokenMap = unsortedMap.get(policy);
1658
1818
  const quantity = tokenMap?.get(token);
1659
1819
  if (!quantity) {
1660
1820
  tokenMap.set(token, BigInt(asset.quantity));
@@ -1662,10 +1822,24 @@ var MeshValue = class _MeshValue {
1662
1822
  tokenMap.set(token, quantity + BigInt(asset.quantity));
1663
1823
  }
1664
1824
  });
1825
+ const sortedPolicies = Array.from(unsortedMap.keys()).sort(compareByteOrder);
1826
+ const valueMap = /* @__PURE__ */ new Map();
1827
+ sortedPolicies.forEach((policy) => {
1828
+ const unsortedTokenMap = unsortedMap.get(policy);
1829
+ const sortedTokens = Array.from(unsortedTokenMap.keys()).sort(
1830
+ compareByteOrder
1831
+ );
1832
+ const sortedTokenMap = /* @__PURE__ */ new Map();
1833
+ sortedTokens.forEach((token) => {
1834
+ sortedTokenMap.set(token, unsortedTokenMap.get(token));
1835
+ });
1836
+ valueMap.set(policy, sortedTokenMap);
1837
+ });
1665
1838
  return valueMap;
1666
1839
  };
1667
1840
  /**
1668
1841
  * Convert the MeshValue object into a JSON representation of Cardano data Value
1842
+ * Entries are sorted by byte ordering of policy ID, then token name
1669
1843
  * @returns Cardano data Value in JSON
1670
1844
  */
1671
1845
  toJSON = () => {
@@ -1684,11 +1858,16 @@ var MeshValue = class _MeshValue {
1684
1858
  valueMap[policy][token] += Number(asset.quantity);
1685
1859
  }
1686
1860
  });
1687
- Object.keys(valueMap).forEach((policy) => {
1861
+ const sortedPolicies = Object.keys(valueMap).sort(compareByteOrder);
1862
+ sortedPolicies.forEach((policy) => {
1688
1863
  const policyByte = currencySymbol(policy);
1689
- const tokens = Object.keys(valueMap[policy]).map(
1690
- (name) => [tokenName(name), integer(valueMap[policy][name])]
1864
+ const sortedTokenNames = Object.keys(valueMap[policy]).sort(
1865
+ compareByteOrder
1691
1866
  );
1867
+ const tokens = sortedTokenNames.map((name) => [
1868
+ tokenName(name),
1869
+ integer(valueMap[policy][name])
1870
+ ]);
1692
1871
  const policyMap = assocMap(tokens);
1693
1872
  valueMapToParse.push([policyByte, policyMap]);
1694
1873
  });
@@ -1712,7 +1891,7 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1712
1891
  const selectedInputs = /* @__PURE__ */ new Set();
1713
1892
  const onlyLovelace = /* @__PURE__ */ new Set();
1714
1893
  const singletons = /* @__PURE__ */ new Set();
1715
- const pairs = /* @__PURE__ */ new Set();
1894
+ const pairs2 = /* @__PURE__ */ new Set();
1716
1895
  const rest = /* @__PURE__ */ new Set();
1717
1896
  const collaterals = /* @__PURE__ */ new Set();
1718
1897
  for (let i = 0; i < inputs.length; i++) {
@@ -1731,7 +1910,7 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1731
1910
  break;
1732
1911
  }
1733
1912
  case 3: {
1734
- pairs.add(i);
1913
+ pairs2.add(i);
1735
1914
  break;
1736
1915
  }
1737
1916
  default: {
@@ -1764,10 +1943,10 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1764
1943
  if (!assetRequired || Number(assetRequired) <= 0) break;
1765
1944
  addUtxoWithAssetAmount(inputIndex, assetUnit, singletons);
1766
1945
  }
1767
- for (const inputIndex of pairs) {
1946
+ for (const inputIndex of pairs2) {
1768
1947
  const assetRequired = totalRequiredAssets.get(assetUnit);
1769
1948
  if (!assetRequired || Number(assetRequired) <= 0) break;
1770
- addUtxoWithAssetAmount(inputIndex, assetUnit, pairs);
1949
+ addUtxoWithAssetAmount(inputIndex, assetUnit, pairs2);
1771
1950
  }
1772
1951
  for (const inputIndex of rest) {
1773
1952
  const assetRequired = totalRequiredAssets.get(assetUnit);
@@ -1785,10 +1964,10 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1785
1964
  if (!assetRequired || Number(assetRequired) <= 0) break;
1786
1965
  addUtxoWithAssetAmount(inputIndex, "lovelace", singletons);
1787
1966
  }
1788
- for (const inputIndex of pairs) {
1967
+ for (const inputIndex of pairs2) {
1789
1968
  const assetRequired = totalRequiredAssets.get("lovelace");
1790
1969
  if (!assetRequired || Number(assetRequired) <= 0) break;
1791
- addUtxoWithAssetAmount(inputIndex, "lovelace", pairs);
1970
+ addUtxoWithAssetAmount(inputIndex, "lovelace", pairs2);
1792
1971
  }
1793
1972
  for (const inputIndex of rest) {
1794
1973
  const assetRequired = totalRequiredAssets.get("lovelace");
@@ -1963,6 +2142,473 @@ var UtxoSelection = class {
1963
2142
  }
1964
2143
  };
1965
2144
 
2145
+ // src/tx-tester/index.ts
2146
+ var TxTester = class {
2147
+ txBody;
2148
+ inputsEvaluating;
2149
+ outputsEvaluating;
2150
+ traces;
2151
+ /**
2152
+ * Create a new TxTester instance
2153
+ * @param txBody The transaction builder body
2154
+ */
2155
+ constructor(txBody) {
2156
+ this.txBody = { ...txBody };
2157
+ this.inputsEvaluating = [];
2158
+ this.outputsEvaluating = [];
2159
+ this.traces = [];
2160
+ }
2161
+ /**
2162
+ * Add a trace to the TxTester
2163
+ * @param funcName The function name where the error occurred
2164
+ * @param message The error message
2165
+ */
2166
+ addTrace(funcName, message) {
2167
+ const msg = `[Error - ${funcName}]: ${message}`;
2168
+ this.traces.push(msg);
2169
+ }
2170
+ /**
2171
+ * Check if the transaction evaluation was successful
2172
+ * @returns true if there are no errors, false otherwise
2173
+ */
2174
+ success() {
2175
+ return this.traces.length === 0;
2176
+ }
2177
+ /**
2178
+ * Get the error messages if any
2179
+ * @returns A string representation of the errors or "No errors" if there are none
2180
+ */
2181
+ errors() {
2182
+ if (this.traces.length > 0) {
2183
+ return `${this.traces}`;
2184
+ } else {
2185
+ return "No errors";
2186
+ }
2187
+ }
2188
+ /**
2189
+ * Checks if the transaction is valid after a specified timestamp.
2190
+ * @param requiredTimestamp The timestamp after which the transaction should be valid
2191
+ * @returns The TxTester instance for chaining
2192
+ */
2193
+ validAfter = (requiredTimestamp) => {
2194
+ const invalidBefore = this.txBody.validityRange?.invalidHereafter ? this.txBody.validityRange.invalidHereafter : 9999999999999;
2195
+ const isValidAfter = this.txBody.validityRange?.invalidBefore ? this.txBody.validityRange.invalidBefore < requiredTimestamp : true;
2196
+ if (!isValidAfter) {
2197
+ this.addTrace(
2198
+ "validAfter",
2199
+ `tx invalid before ${invalidBefore}, with requiredTimestamp ${requiredTimestamp}`
2200
+ );
2201
+ }
2202
+ return this;
2203
+ };
2204
+ /**
2205
+ * Checks if the transaction is valid before a specified timestamp.
2206
+ * @param requiredTimestamp The timestamp before which the transaction should be valid
2207
+ * @returns The TxTester instance for chaining
2208
+ */
2209
+ validBefore = (requiredTimestamp) => {
2210
+ const invalidHereafter = this.txBody.validityRange?.invalidBefore ? this.txBody.validityRange.invalidBefore : 0;
2211
+ const isValidBefore = this.txBody.validityRange?.invalidHereafter ? this.txBody.validityRange.invalidHereafter > requiredTimestamp : true;
2212
+ if (!isValidBefore) {
2213
+ this.addTrace(
2214
+ "validBefore",
2215
+ `tx invalid after ${invalidHereafter}, with requiredTimestamp ${requiredTimestamp}`
2216
+ );
2217
+ }
2218
+ return this;
2219
+ };
2220
+ // Extra Signatories Methods
2221
+ /**
2222
+ * Checks if a specific key is signed in the transaction.
2223
+ * @param keyHash The key hash to check
2224
+ * @returns The TxTester instance for chaining
2225
+ */
2226
+ keySigned = (keyHash) => {
2227
+ const isKeySigned = keySignedLogic(this.txBody.requiredSignatures, keyHash);
2228
+ if (!isKeySigned) {
2229
+ this.addTrace("keySigned", `tx does not have key ${keyHash} signed`);
2230
+ }
2231
+ return this;
2232
+ };
2233
+ /**
2234
+ * Checks if any one of the specified keys is signed in the transaction.
2235
+ * @param keyHashes The array of key hashes to check
2236
+ * @returns The TxTester instance for chaining
2237
+ */
2238
+ oneOfKeysSigned = (keyHashes) => {
2239
+ const isOneOfKeysSigned = keyHashes.some(
2240
+ (keyHash) => keySignedLogic(this.txBody.requiredSignatures, keyHash)
2241
+ );
2242
+ if (!isOneOfKeysSigned) {
2243
+ this.addTrace(
2244
+ "oneOfKeysSigned",
2245
+ `tx does not have any of the keys signed: ${keyHashes.join(", ")}`
2246
+ );
2247
+ }
2248
+ return this;
2249
+ };
2250
+ /**
2251
+ * Checks if all specified keys are signed in the transaction.
2252
+ * @param keyHashes The array of key hashes to check
2253
+ * @returns The TxTester instance for chaining
2254
+ */
2255
+ allKeysSigned = (keyHashes) => {
2256
+ const missingKeys = [];
2257
+ const isAllKeysSigned = keyHashes.every((keyHash) => {
2258
+ const isKeySigned = keySignedLogic(
2259
+ this.txBody.requiredSignatures,
2260
+ keyHash
2261
+ );
2262
+ if (!isKeySigned) {
2263
+ missingKeys.push(keyHash);
2264
+ }
2265
+ return isKeySigned;
2266
+ });
2267
+ if (!isAllKeysSigned) {
2268
+ this.addTrace(
2269
+ "allKeysSigned",
2270
+ `tx does not have all keys signed: ${missingKeys.join(", ")}`
2271
+ );
2272
+ }
2273
+ return this;
2274
+ };
2275
+ /**
2276
+ * Checks if a specific token is minted in the transaction.
2277
+ * @param policyId The policy ID of the token
2278
+ * @param assetName The asset name of the token
2279
+ * @param quantity The quantity of the token
2280
+ * @returns The TxTester instance for chaining
2281
+ */
2282
+ tokenMinted = (policyId2, assetName2, quantity) => {
2283
+ const isTokenMinted = tokenMintedLogic(
2284
+ this.txBody.mints,
2285
+ policyId2,
2286
+ assetName2,
2287
+ quantity
2288
+ );
2289
+ if (!isTokenMinted) {
2290
+ this.addTrace(
2291
+ "tokenMinted",
2292
+ `Token with policy_id: ${policyId2}, asset_name: ${assetName2}, quantity: ${quantity} not found in mints.`
2293
+ );
2294
+ }
2295
+ return this;
2296
+ };
2297
+ /**
2298
+ * Checks if a specific token is minted in the transaction and that it is the only mint.
2299
+ * @param policyId The policy ID of the token
2300
+ * @param assetName The asset name of the token
2301
+ * @param quantity The quantity of the token
2302
+ * @returns The TxTester instance for chaining
2303
+ */
2304
+ onlyTokenMinted = (policyId2, assetName2, quantity) => {
2305
+ const isTokenMinted = tokenMintedLogic(
2306
+ this.txBody.mints,
2307
+ policyId2,
2308
+ assetName2,
2309
+ quantity
2310
+ );
2311
+ const isOnlyOneMint = this.txBody.mints?.length === 1;
2312
+ if (!isTokenMinted) {
2313
+ this.addTrace(
2314
+ "onlyTokenMinted",
2315
+ `Token with policy_id: ${policyId2}, asset_name: ${assetName2}, quantity: ${quantity} not found in mints`
2316
+ );
2317
+ }
2318
+ if (!isOnlyOneMint) {
2319
+ this.addTrace(
2320
+ "onlyTokenMinted",
2321
+ `Expected only one mint, but found ${this.txBody.mints?.length || 0} mints.`
2322
+ );
2323
+ }
2324
+ return this;
2325
+ };
2326
+ /**
2327
+ * Checks if a specific token is minted in the transaction, ensuring that it is the only mint for the given policy ID.
2328
+ * @param policyId The policy ID of the token
2329
+ * @param assetName The asset name of the token
2330
+ * @param quantity The quantity of the token
2331
+ * @returns The TxTester instance for chaining
2332
+ */
2333
+ policyOnlyMintedToken = (policyId2, assetName2, quantity) => {
2334
+ const filteredMints = this.txBody.mints?.filter((token) => {
2335
+ return token.policyId === policyId2;
2336
+ }) || [];
2337
+ const isTokenMinted = tokenMintedLogic(
2338
+ this.txBody.mints,
2339
+ policyId2,
2340
+ assetName2,
2341
+ quantity
2342
+ );
2343
+ const isOnlyOneMint = filteredMints.length === 1;
2344
+ if (!isOnlyOneMint) {
2345
+ this.addTrace(
2346
+ "policyOnlyMintedToken",
2347
+ `Expected only one mint for policy_id: ${policyId2}, but found ${filteredMints.length} mints.`
2348
+ );
2349
+ }
2350
+ if (!isTokenMinted) {
2351
+ this.addTrace(
2352
+ "policyOnlyMintedToken",
2353
+ `Token with policy_id: ${policyId2}, asset_name: ${assetName2}, quantity: ${quantity} not found in mints.`
2354
+ );
2355
+ }
2356
+ return this;
2357
+ };
2358
+ /**
2359
+ * Checks if a specific policy ID is burned in the transaction, ensuring that it is the only minting (i.e. burning item).
2360
+ * @param policyId The policy ID to check
2361
+ * @returns true if the policy is the only burn, false otherwise
2362
+ */
2363
+ checkPolicyOnlyBurn = (policyId2) => {
2364
+ const filteredMints = this.txBody.mints?.filter((token) => {
2365
+ return token.policyId === policyId2 && token.mintValue.findIndex((m) => BigInt(m.amount) > 0) >= 0;
2366
+ }) || [];
2367
+ return filteredMints.length === 0;
2368
+ };
2369
+ /**
2370
+ * Not apply filter to inputs
2371
+ * @returns The TxTester instance for chaining
2372
+ */
2373
+ allInputs = () => {
2374
+ this.inputsEvaluating = this.txBody.inputs?.slice() || [];
2375
+ return this;
2376
+ };
2377
+ /**
2378
+ * Filter inputs by address
2379
+ * @param address The address to filter by
2380
+ * @returns The TxTester instance for chaining
2381
+ */
2382
+ inputsAt = (address) => {
2383
+ this.inputsEvaluating = this.txBody.inputs?.filter(
2384
+ (input) => txInToUtxo(input.txIn).output.address === address
2385
+ ) || [];
2386
+ return this;
2387
+ };
2388
+ /**
2389
+ * Filter inputs by unit
2390
+ * @param unit The unit to filter by
2391
+ * @returns The TxTester instance for chaining
2392
+ */
2393
+ inputsWith = (unit) => {
2394
+ this.inputsEvaluating = this.txBody.inputs?.filter((input) => {
2395
+ const inputValue = MeshValue.fromAssets(
2396
+ txInToUtxo(input.txIn).output.amount
2397
+ );
2398
+ const quantity = inputValue.get(unit);
2399
+ return quantity > 0;
2400
+ }) || [];
2401
+ return this;
2402
+ };
2403
+ /**
2404
+ * Filter inputs by policy ID
2405
+ * @param policyId The policy ID to filter by
2406
+ * @returns The TxTester instance for chaining
2407
+ */
2408
+ inputsWithPolicy = (policyId2) => {
2409
+ this.inputsEvaluating = this.txBody.inputs?.filter((input) => {
2410
+ const inputValue = MeshValue.fromAssets(
2411
+ txInToUtxo(input.txIn).output.amount
2412
+ );
2413
+ const assets = inputValue.getPolicyAssets(policyId2);
2414
+ return assets.length > 0;
2415
+ }) || [];
2416
+ return this;
2417
+ };
2418
+ /**
2419
+ * Filter inputs by address and policy ID
2420
+ * @param address The address to filter by
2421
+ * @param policyId The policy ID to filter by
2422
+ * @returns The TxTester instance for chaining
2423
+ */
2424
+ inputsAtWithPolicy = (address, policyId2) => {
2425
+ this.inputsEvaluating = this.txBody.inputs?.filter((input) => {
2426
+ const utxo = txInToUtxo(input.txIn);
2427
+ const inputValue = MeshValue.fromAssets(utxo.output.amount);
2428
+ const assets = inputValue.getPolicyAssets(policyId2);
2429
+ return utxo.output.address === address && assets.length > 0;
2430
+ }) || [];
2431
+ return this;
2432
+ };
2433
+ /**
2434
+ * Filter inputs by address and unit
2435
+ * @param address The address to filter by
2436
+ * @param unit The unit to filter by
2437
+ * @returns The TxTester instance for chaining
2438
+ */
2439
+ inputsAtWith = (address, unit) => {
2440
+ this.inputsEvaluating = this.txBody.inputs?.filter((input) => {
2441
+ const utxo = txInToUtxo(input.txIn);
2442
+ const inputValue = MeshValue.fromAssets(utxo.output.amount);
2443
+ const quantity = inputValue.get(unit);
2444
+ return utxo.output.address === address && quantity > 0;
2445
+ }) || [];
2446
+ return this;
2447
+ };
2448
+ /**
2449
+ * Check if inputs contain the expected value.
2450
+ * *Reminder - It must be called after filtering methods for inputs*
2451
+ * @param expectedValue The expected value
2452
+ * @returns The TxTester instance for chaining
2453
+ */
2454
+ inputsValue = (expectedValue) => {
2455
+ let value2 = new MeshValue();
2456
+ this.inputsEvaluating.forEach((input) => {
2457
+ const utxo = txInToUtxo(input.txIn);
2458
+ value2.addAssets(utxo.output.amount);
2459
+ });
2460
+ const isValueCorrect = value2.eq(expectedValue);
2461
+ if (!isValueCorrect) {
2462
+ this.addTrace(
2463
+ "inputsValue",
2464
+ `inputs ${JSON.stringify(this.inputsEvaluating)} have value ${JSON.stringify(value2)}, expect ${JSON.stringify(expectedValue)}`
2465
+ );
2466
+ }
2467
+ return this;
2468
+ };
2469
+ // /**
2470
+ // * Check if inputs contain a specific inline datum.
2471
+ // * *Reminder - It must be called after filtering methods for inputs*
2472
+ // * @param datumCbor The datum CBOR to check
2473
+ // * @returns The TxTester instance for chaining
2474
+ // */
2475
+ // inputsInlineDatumExist = (datumCbor: string): this => {
2476
+ // const inputsWithInlineDatum = this.inputsEvaluating.filter((input) => {
2477
+ // const utxo = txInToUtxo(input.txIn);
2478
+ // return utxo.output.plutusData === datumCbor;
2479
+ // });
2480
+ // if (inputsWithInlineDatum.length === 0) {
2481
+ // this.addTrace(
2482
+ // "inputsInlineDatumExist",
2483
+ // `No inputs with inline datum matching: ${datumCbor}`,
2484
+ // );
2485
+ // }
2486
+ // return this;
2487
+ // };
2488
+ /**
2489
+ * Not apply filter to outputs
2490
+ * @returns The TxTester instance for chaining
2491
+ */
2492
+ allOutputs = () => {
2493
+ this.outputsEvaluating = this.txBody.outputs?.slice() || [];
2494
+ return this;
2495
+ };
2496
+ /**
2497
+ * Filter outputs by address
2498
+ * @param address The address to filter by
2499
+ * @returns The TxTester instance for chaining
2500
+ */
2501
+ outputsAt = (address) => {
2502
+ this.outputsEvaluating = this.txBody.outputs?.filter((output) => output.address === address) || [];
2503
+ return this;
2504
+ };
2505
+ /**
2506
+ * Filter outputs by unit
2507
+ * @param unit The unit to filter by
2508
+ * @returns The TxTester instance for chaining
2509
+ */
2510
+ outputsWith = (unit) => {
2511
+ this.outputsEvaluating = this.txBody.outputs?.filter((output) => {
2512
+ const outputValue = MeshValue.fromAssets(output.amount);
2513
+ const quantity = outputValue.get(unit);
2514
+ return quantity > 0;
2515
+ }) || [];
2516
+ return this;
2517
+ };
2518
+ /**
2519
+ * Filter outputs by policy ID
2520
+ * @param policyId The policy ID to filter by
2521
+ * @returns The TxTester instance for chaining
2522
+ */
2523
+ outputsWithPolicy = (policyId2) => {
2524
+ this.outputsEvaluating = this.txBody.outputs?.filter((output) => {
2525
+ const outputValue = MeshValue.fromAssets(output.amount);
2526
+ const assets = outputValue.getPolicyAssets(policyId2);
2527
+ return assets.length > 0;
2528
+ }) || [];
2529
+ return this;
2530
+ };
2531
+ /**
2532
+ * Filter outputs by address and policy ID
2533
+ * @param address The address to filter by
2534
+ * @param policyId The policy ID to filter by
2535
+ * @returns The TxTester instance for chaining
2536
+ */
2537
+ outputsAtWithPolicy = (address, policyId2) => {
2538
+ this.outputsEvaluating = this.txBody.outputs?.filter((output) => {
2539
+ const outputValue = MeshValue.fromAssets(output.amount);
2540
+ const assets = outputValue.getPolicyAssets(policyId2);
2541
+ return output.address === address && assets.length > 0;
2542
+ }) || [];
2543
+ return this;
2544
+ };
2545
+ /**
2546
+ * Filter outputs by address and unit
2547
+ * @param address The address to filter by
2548
+ * @param unit The unit to filter by
2549
+ * @returns The TxTester instance for chaining
2550
+ */
2551
+ outputsAtWith = (address, unit) => {
2552
+ this.outputsEvaluating = this.txBody.outputs?.filter((output) => {
2553
+ const outputValue = MeshValue.fromAssets(output.amount);
2554
+ const quantity = outputValue.get(unit);
2555
+ return output.address === address && quantity > 0;
2556
+ }) || [];
2557
+ return this;
2558
+ };
2559
+ /**
2560
+ * Check if outputs contain the expected value.
2561
+ * *Reminder - It must be called after filtering methods for outputs*
2562
+ * @param expectedValue The expected value
2563
+ * @returns The TxTester instance for chaining
2564
+ */
2565
+ outputsValue = (expectedValue) => {
2566
+ let value2 = new MeshValue();
2567
+ this.outputsEvaluating.forEach((output) => {
2568
+ value2.addAssets(output.amount);
2569
+ });
2570
+ const isValueCorrect = value2.eq(expectedValue);
2571
+ if (!isValueCorrect) {
2572
+ this.addTrace(
2573
+ "outputsValue",
2574
+ `tx outputs ${JSON.stringify(this.outputsEvaluating)} have value ${JSON.stringify(value2)}, expected ${JSON.stringify(expectedValue)}`
2575
+ );
2576
+ }
2577
+ return this;
2578
+ };
2579
+ /**
2580
+ * Check if outputs contain a specific inline datum.
2581
+ * *Reminder - It must be called after filtering methods for outputs*
2582
+ * @param datumCbor The datum CBOR to check
2583
+ * @returns The TxTester instance for chaining
2584
+ */
2585
+ outputsInlineDatumExist = (datumCbor) => {
2586
+ const outputsWithInlineDatum = this.outputsEvaluating.filter((output) => {
2587
+ if (output.datum && output.datum.type === "Inline") {
2588
+ return output.datum.data.content === datumCbor;
2589
+ }
2590
+ return false;
2591
+ });
2592
+ if (outputsWithInlineDatum.length === 0) {
2593
+ this.addTrace(
2594
+ "outputs_inline_datum_exist",
2595
+ `No outputs with inline datum matching: ${datumCbor}`
2596
+ );
2597
+ }
2598
+ return this;
2599
+ };
2600
+ };
2601
+ function keySignedLogic(requiredSignatures, keyHash) {
2602
+ return requiredSignatures?.some((signatory) => signatory === keyHash) || false;
2603
+ }
2604
+ function tokenMintedLogic(mints, policyId2, assetName2, quantity) {
2605
+ return mints?.some((token) => {
2606
+ return token.policyId === policyId2 && token.mintValue.findIndex(
2607
+ (m) => m.assetName === assetName2 && BigInt(m.amount) === BigInt(quantity)
2608
+ ) >= 0;
2609
+ }) || false;
2610
+ }
2611
+
1966
2612
  // src/index.ts
1967
2613
  var import_bip39 = require("bip39");
1968
2614
  // Annotate the CommonJS export names for ESM import in node:
@@ -1971,12 +2617,14 @@ var import_bip39 = require("bip39");
1971
2617
  BigNum,
1972
2618
  CIP68_100,
1973
2619
  CIP68_222,
2620
+ DEFAULT_FETCHER_OPTIONS,
1974
2621
  DEFAULT_PROTOCOL_PARAMETERS,
1975
2622
  DEFAULT_REDEEMER_BUDGET,
1976
2623
  DEFAULT_V1_COST_MODEL_LIST,
1977
2624
  DEFAULT_V2_COST_MODEL_LIST,
1978
2625
  DEFAULT_V3_COST_MODEL_LIST,
1979
2626
  DREP_DEPOSIT,
2627
+ GovernanceActionKind,
1980
2628
  HARDENED_KEY_START,
1981
2629
  LANGUAGE_VERSIONS,
1982
2630
  MeshValue,
@@ -1988,7 +2636,9 @@ var import_bip39 = require("bip39");
1988
2636
  SUPPORTED_OGMIOS_LINKS,
1989
2637
  SUPPORTED_TOKENS,
1990
2638
  SUPPORTED_WALLETS,
2639
+ TxTester,
1991
2640
  UtxoSelection,
2641
+ VOTING_PROPOSAL_DEPOSIT,
1992
2642
  assetClass,
1993
2643
  assetName,
1994
2644
  assocMap,
@@ -1997,11 +2647,13 @@ var import_bip39 = require("bip39");
1997
2647
  byteString,
1998
2648
  bytesToHex,
1999
2649
  castProtocol,
2650
+ cloneTxBuilderBody,
2000
2651
  conStr,
2001
2652
  conStr0,
2002
2653
  conStr1,
2003
2654
  conStr2,
2004
2655
  conStr3,
2656
+ credential,
2005
2657
  currencySymbol,
2006
2658
  dict,
2007
2659
  emptyTxBuilderBody,
@@ -2015,8 +2667,11 @@ var import_bip39 = require("bip39");
2015
2667
  hexToBytes,
2016
2668
  hexToString,
2017
2669
  integer,
2670
+ isHexString,
2018
2671
  isNetwork,
2672
+ jsonProofToPlutusData,
2019
2673
  keepRelevant,
2674
+ keySignedLogic,
2020
2675
  largestFirst,
2021
2676
  largestFirstMultiAsset,
2022
2677
  list,
@@ -2027,18 +2682,21 @@ var import_bip39 = require("bip39");
2027
2682
  mConStr1,
2028
2683
  mConStr2,
2029
2684
  mConStr3,
2685
+ mCredential,
2030
2686
  mMaybeStakingHash,
2031
2687
  mNone,
2032
2688
  mOption,
2033
2689
  mOutputReference,
2034
2690
  mPlutusBSArrayToString,
2035
2691
  mPubKeyAddress,
2692
+ mScript,
2036
2693
  mScriptAddress,
2037
2694
  mSome,
2038
2695
  mStringToPlutusBSArray,
2039
2696
  mTuple,
2040
2697
  mTxOutRef,
2041
2698
  mValue,
2699
+ mVerificationKey,
2042
2700
  maybeStakingHash,
2043
2701
  mergeAssets,
2044
2702
  metadataStandardKeys,
@@ -2047,6 +2705,7 @@ var import_bip39 = require("bip39");
2047
2705
  none,
2048
2706
  option,
2049
2707
  outputReference,
2708
+ pairs,
2050
2709
  parseAssetUnit,
2051
2710
  plutusBSArrayToString,
2052
2711
  policyId,
@@ -2059,6 +2718,7 @@ var import_bip39 = require("bip39");
2059
2718
  resolveSlotNo,
2060
2719
  resolveTxFees,
2061
2720
  royaltiesStandardKeys,
2721
+ script,
2062
2722
  scriptAddress,
2063
2723
  scriptHash,
2064
2724
  slotToBeginUnixTime,
@@ -2067,11 +2727,14 @@ var import_bip39 = require("bip39");
2067
2727
  stringToHex,
2068
2728
  toBytes,
2069
2729
  toUTF8,
2730
+ tokenMintedLogic,
2070
2731
  tokenName,
2071
2732
  tuple,
2072
2733
  txInToUtxo,
2073
2734
  txOutRef,
2074
2735
  unixTimeToEnclosingSlot,
2736
+ validityRangeFromObj,
2075
2737
  validityRangeToObj,
2076
- value
2738
+ value,
2739
+ verificationKey
2077
2740
  });