@meshsdk/common 1.9.0-beta.23 → 1.9.0-beta.25

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
@@ -81,6 +81,7 @@ __export(index_exports, {
81
81
  hexToString: () => hexToString,
82
82
  integer: () => integer,
83
83
  isNetwork: () => isNetwork,
84
+ jsonProofToPlutusData: () => jsonProofToPlutusData,
84
85
  keepRelevant: () => keepRelevant,
85
86
  largestFirst: () => largestFirst,
86
87
  largestFirstMultiAsset: () => largestFirstMultiAsset,
@@ -99,12 +100,14 @@ __export(index_exports, {
99
100
  mOutputReference: () => mOutputReference,
100
101
  mPlutusBSArrayToString: () => mPlutusBSArrayToString,
101
102
  mPubKeyAddress: () => mPubKeyAddress,
103
+ mScript: () => mScript,
102
104
  mScriptAddress: () => mScriptAddress,
103
105
  mSome: () => mSome,
104
106
  mStringToPlutusBSArray: () => mStringToPlutusBSArray,
105
107
  mTuple: () => mTuple,
106
108
  mTxOutRef: () => mTxOutRef,
107
109
  mValue: () => mValue,
110
+ mVerificationKey: () => mVerificationKey,
108
111
  maybeStakingHash: () => maybeStakingHash,
109
112
  mergeAssets: () => mergeAssets,
110
113
  metadataStandardKeys: () => metadataStandardKeys,
@@ -113,6 +116,7 @@ __export(index_exports, {
113
116
  none: () => none,
114
117
  option: () => option,
115
118
  outputReference: () => outputReference,
119
+ pairs: () => pairs,
116
120
  parseAssetUnit: () => parseAssetUnit,
117
121
  plutusBSArrayToString: () => plutusBSArrayToString,
118
122
  policyId: () => policyId,
@@ -125,6 +129,7 @@ __export(index_exports, {
125
129
  resolveSlotNo: () => resolveSlotNo,
126
130
  resolveTxFees: () => resolveTxFees,
127
131
  royaltiesStandardKeys: () => royaltiesStandardKeys,
132
+ script: () => script,
128
133
  scriptAddress: () => scriptAddress,
129
134
  scriptHash: () => scriptHash,
130
135
  slotToBeginUnixTime: () => slotToBeginUnixTime,
@@ -139,7 +144,8 @@ __export(index_exports, {
139
144
  txOutRef: () => txOutRef,
140
145
  unixTimeToEnclosingSlot: () => unixTimeToEnclosingSlot,
141
146
  validityRangeToObj: () => validityRangeToObj,
142
- value: () => value
147
+ value: () => value,
148
+ verificationKey: () => verificationKey
143
149
  });
144
150
  module.exports = __toCommonJS(index_exports);
145
151
 
@@ -1092,14 +1098,16 @@ var mSome = (value2) => mConStr0([value2]);
1092
1098
  var mNone = () => mConStr1([]);
1093
1099
 
1094
1100
  // src/data/mesh/credentials.ts
1101
+ var mVerificationKey = (bytes) => mConStr0([bytes]);
1102
+ var mScript = (bytes) => mConStr1([bytes]);
1095
1103
  var mMaybeStakingHash = (stakeCredential, isStakeScriptCredential = false) => {
1096
1104
  if (stakeCredential === "") {
1097
1105
  return mConStr1([]);
1098
1106
  }
1099
1107
  if (isStakeScriptCredential) {
1100
- return mConStr0([mConStr0([mConStr1([stakeCredential])])]);
1108
+ return mConStr0([mConStr0([mScript(stakeCredential)])]);
1101
1109
  }
1102
- return mConStr0([mConStr0([mConStr0([stakeCredential])])]);
1110
+ return mConStr0([mConStr0([mVerificationKey(stakeCredential)])]);
1103
1111
  };
1104
1112
  var mPubKeyAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => mConStr0([
1105
1113
  { alternative: 0, fields: [bytes] },
@@ -1109,7 +1117,7 @@ var mScriptAddress = (bytes, stakeCredential, isStakeScriptCredential = false) =
1109
1117
  { alternative: 1, fields: [bytes] },
1110
1118
  mMaybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1111
1119
  ]);
1112
- var mCredential = (hash, isScriptCredential = false) => isScriptCredential ? mConStr1([hash]) : mConStr0([hash]);
1120
+ var mCredential = (hash, isScriptCredential = false) => isScriptCredential ? mScript(hash) : mVerificationKey(hash);
1113
1121
 
1114
1122
  // src/data/mesh/primitives.ts
1115
1123
  var mBool = (b) => b ? mConStr1([]) : mConStr0([]);
@@ -1197,11 +1205,25 @@ var assocMap = (mapItems, validation = true) => ({
1197
1205
  return { k, v };
1198
1206
  })
1199
1207
  });
1208
+ var pairs = (mapItems, validation = true) => ({
1209
+ map: mapItems.map(([k, v]) => {
1210
+ if (validation) {
1211
+ if (typeof k !== "object" || typeof v !== "object") {
1212
+ throw new Error(
1213
+ `Map item of JSON Cardano data type must be an object - ${k}, ${v}`
1214
+ );
1215
+ }
1216
+ }
1217
+ return { k, v };
1218
+ })
1219
+ });
1200
1220
 
1201
1221
  // src/data/json/aliases.ts
1202
1222
  var hashByteString = (bytes) => {
1203
1223
  if (bytes.length !== 56) {
1204
- throw new Error(`Invalid hash for [${bytes}] - should be 56 bytes long`);
1224
+ throw new Error(
1225
+ `Invalid hash for [${bytes}] - should be 28 bytes (56 hex length) long`
1226
+ );
1205
1227
  }
1206
1228
  return byteString(bytes);
1207
1229
  };
@@ -1210,7 +1232,7 @@ var pubKeyHash = (bytes) => hashByteString(bytes);
1210
1232
  var policyId = (bytes) => {
1211
1233
  if (bytes.length !== POLICY_ID_LENGTH && bytes !== "") {
1212
1234
  throw new Error(
1213
- `Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH} bytes long or empty string for lovelace`
1235
+ `Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH / 2} bytes (${POLICY_ID_LENGTH} hex length) long or empty string for lovelace`
1214
1236
  );
1215
1237
  }
1216
1238
  return byteString(bytes);
@@ -1253,28 +1275,56 @@ var some = (value2) => conStr0([value2]);
1253
1275
  var none = () => conStr1([]);
1254
1276
 
1255
1277
  // src/data/json/credentials.ts
1278
+ var verificationKey = (bytes) => conStr0([pubKeyHash(bytes)]);
1279
+ var script = (bytes) => conStr1([scriptHash(bytes)]);
1256
1280
  var maybeStakingHash = (stakeCredential, isStakeScriptCredential = false) => {
1257
1281
  if (stakeCredential === "") {
1258
1282
  return conStr1([]);
1259
1283
  }
1260
1284
  if (isStakeScriptCredential) {
1261
- return conStr0([
1262
- conStr0([conStr1([scriptHash(stakeCredential)])])
1263
- ]);
1285
+ return conStr0([conStr0([script(stakeCredential)])]);
1264
1286
  }
1265
- return conStr0([
1266
- conStr0([conStr0([pubKeyHash(stakeCredential)])])
1267
- ]);
1287
+ return conStr0([conStr0([verificationKey(stakeCredential)])]);
1268
1288
  };
1269
1289
  var pubKeyAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => conStr0([
1270
1290
  conStr0([pubKeyHash(bytes)]),
1271
1291
  maybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1272
1292
  ]);
1273
1293
  var scriptAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => conStr0([
1274
- conStr1([scriptHash(bytes)]),
1294
+ script(bytes),
1275
1295
  maybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1276
1296
  ]);
1277
- var credential = (hash, isScriptCredential = false) => isScriptCredential ? conStr1([scriptHash(hash)]) : conStr0([pubKeyHash(hash)]);
1297
+ var credential = (hash, isScriptCredential = false) => isScriptCredential ? script(hash) : verificationKey(hash);
1298
+
1299
+ // src/data/json/mpf.ts
1300
+ var jsonProofToPlutusData = (proof) => {
1301
+ const proofSteps = [];
1302
+ const proofJson = proof;
1303
+ proofJson.forEach((proof2) => {
1304
+ const skip = integer(proof2.skip);
1305
+ switch (proof2.type) {
1306
+ case "branch":
1307
+ proofSteps.push(
1308
+ conStr0([skip, byteString(proof2.neighbors.toString("hex"))])
1309
+ );
1310
+ break;
1311
+ case "fork":
1312
+ const { prefix, nibble, root } = proof2.neighbor;
1313
+ const neighbor = conStr0([
1314
+ integer(nibble),
1315
+ byteString(prefix.toString("hex")),
1316
+ byteString(root.toString("hex"))
1317
+ ]);
1318
+ proofSteps.push(conStr1([skip, neighbor]));
1319
+ break;
1320
+ case "leaf":
1321
+ const { key, value: value2 } = proof2.neighbor;
1322
+ proofSteps.push(conStr2([skip, byteString(key), byteString(value2)]));
1323
+ break;
1324
+ }
1325
+ });
1326
+ return proofSteps;
1327
+ };
1278
1328
 
1279
1329
  // src/data/parser.ts
1280
1330
  var bytesToHex = (bytes) => Buffer.from(bytes).toString("hex");
@@ -1723,7 +1773,7 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1723
1773
  const selectedInputs = /* @__PURE__ */ new Set();
1724
1774
  const onlyLovelace = /* @__PURE__ */ new Set();
1725
1775
  const singletons = /* @__PURE__ */ new Set();
1726
- const pairs = /* @__PURE__ */ new Set();
1776
+ const pairs2 = /* @__PURE__ */ new Set();
1727
1777
  const rest = /* @__PURE__ */ new Set();
1728
1778
  const collaterals = /* @__PURE__ */ new Set();
1729
1779
  for (let i = 0; i < inputs.length; i++) {
@@ -1742,7 +1792,7 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1742
1792
  break;
1743
1793
  }
1744
1794
  case 3: {
1745
- pairs.add(i);
1795
+ pairs2.add(i);
1746
1796
  break;
1747
1797
  }
1748
1798
  default: {
@@ -1775,10 +1825,10 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1775
1825
  if (!assetRequired || Number(assetRequired) <= 0) break;
1776
1826
  addUtxoWithAssetAmount(inputIndex, assetUnit, singletons);
1777
1827
  }
1778
- for (const inputIndex of pairs) {
1828
+ for (const inputIndex of pairs2) {
1779
1829
  const assetRequired = totalRequiredAssets.get(assetUnit);
1780
1830
  if (!assetRequired || Number(assetRequired) <= 0) break;
1781
- addUtxoWithAssetAmount(inputIndex, assetUnit, pairs);
1831
+ addUtxoWithAssetAmount(inputIndex, assetUnit, pairs2);
1782
1832
  }
1783
1833
  for (const inputIndex of rest) {
1784
1834
  const assetRequired = totalRequiredAssets.get(assetUnit);
@@ -1796,10 +1846,10 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1796
1846
  if (!assetRequired || Number(assetRequired) <= 0) break;
1797
1847
  addUtxoWithAssetAmount(inputIndex, "lovelace", singletons);
1798
1848
  }
1799
- for (const inputIndex of pairs) {
1849
+ for (const inputIndex of pairs2) {
1800
1850
  const assetRequired = totalRequiredAssets.get("lovelace");
1801
1851
  if (!assetRequired || Number(assetRequired) <= 0) break;
1802
- addUtxoWithAssetAmount(inputIndex, "lovelace", pairs);
1852
+ addUtxoWithAssetAmount(inputIndex, "lovelace", pairs2);
1803
1853
  }
1804
1854
  for (const inputIndex of rest) {
1805
1855
  const assetRequired = totalRequiredAssets.get("lovelace");
@@ -2029,6 +2079,7 @@ var import_bip39 = require("bip39");
2029
2079
  hexToString,
2030
2080
  integer,
2031
2081
  isNetwork,
2082
+ jsonProofToPlutusData,
2032
2083
  keepRelevant,
2033
2084
  largestFirst,
2034
2085
  largestFirstMultiAsset,
@@ -2047,12 +2098,14 @@ var import_bip39 = require("bip39");
2047
2098
  mOutputReference,
2048
2099
  mPlutusBSArrayToString,
2049
2100
  mPubKeyAddress,
2101
+ mScript,
2050
2102
  mScriptAddress,
2051
2103
  mSome,
2052
2104
  mStringToPlutusBSArray,
2053
2105
  mTuple,
2054
2106
  mTxOutRef,
2055
2107
  mValue,
2108
+ mVerificationKey,
2056
2109
  maybeStakingHash,
2057
2110
  mergeAssets,
2058
2111
  metadataStandardKeys,
@@ -2061,6 +2114,7 @@ var import_bip39 = require("bip39");
2061
2114
  none,
2062
2115
  option,
2063
2116
  outputReference,
2117
+ pairs,
2064
2118
  parseAssetUnit,
2065
2119
  plutusBSArrayToString,
2066
2120
  policyId,
@@ -2073,6 +2127,7 @@ var import_bip39 = require("bip39");
2073
2127
  resolveSlotNo,
2074
2128
  resolveTxFees,
2075
2129
  royaltiesStandardKeys,
2130
+ script,
2076
2131
  scriptAddress,
2077
2132
  scriptHash,
2078
2133
  slotToBeginUnixTime,
@@ -2087,5 +2142,6 @@ var import_bip39 = require("bip39");
2087
2142
  txOutRef,
2088
2143
  unixTimeToEnclosingSlot,
2089
2144
  validityRangeToObj,
2090
- value
2145
+ value,
2146
+ verificationKey
2091
2147
  });
package/dist/index.d.cts CHANGED
@@ -731,22 +731,42 @@ declare const mSome: <T extends Data>(value: T) => MSome<T>;
731
731
  */
732
732
  declare const mNone: () => MNone;
733
733
 
734
+ /**
735
+ * The Mesh Data verification key
736
+ */
737
+ type MVerificationKey = MConStr0<[string]>;
738
+ /**
739
+ * The Mesh Data script key
740
+ */
741
+ type MScript = MConStr1<[string]>;
734
742
  /**
735
743
  * The Mesh Data staking credential
736
744
  */
737
- type MMaybeStakingHash = MConStr1<[]> | MConStr0<[MConStr0<[MConStr0<[string]>]>]> | MConStr0<[MConStr0<[MConStr1<[string]>]>]>;
745
+ type MMaybeStakingHash = MConStr1<[]> | MConStr0<[MConStr0<[MVerificationKey]>]> | MConStr0<[MConStr0<[MScript]>]>;
738
746
  /**
739
747
  * The Mesh Data public key address
740
748
  */
741
- type MPubKeyAddress = MConStr0<[MConStr0<[string]>, MMaybeStakingHash]>;
749
+ type MPubKeyAddress = MConStr0<[MVerificationKey, MMaybeStakingHash]>;
742
750
  /**
743
751
  * The Mesh Data script address
744
752
  */
745
- type MScriptAddress = MConStr0<[MConStr1<[string]>, MMaybeStakingHash]>;
753
+ type MScriptAddress = MConStr0<[MScript, MMaybeStakingHash]>;
746
754
  /**
747
755
  * The Mesh Data credential
748
756
  */
749
- type MCredential = MConStr0<[string]> | MConStr1<[string]>;
757
+ type MCredential = MVerificationKey | MScript;
758
+ /**
759
+ * The utility function to create a Mesh Data verification key
760
+ * @param bytes The public key hash in hex
761
+ * @returns The Mesh Data verification key object
762
+ */
763
+ declare const mVerificationKey: (bytes: string) => MVerificationKey;
764
+ /**
765
+ * The utility function to create a Mesh Data script key
766
+ * @param bytes The script hash in hex
767
+ * @returns The Mesh Data script key object
768
+ */
769
+ declare const mScript: (bytes: string) => MScript;
750
770
  /**
751
771
  * The utility function to create a Mesh Data staking hash
752
772
  * @param stakeCredential The staking credential in hex
@@ -893,11 +913,27 @@ type AssocMapItem<K, V> = {
893
913
  v: V;
894
914
  };
895
915
  /**
916
+ * PlutusTx alias
896
917
  * The Plutus Data association map in JSON
897
918
  */
898
919
  type AssocMap<K = any, V = any> = {
899
920
  map: AssocMapItem<K, V>[];
900
921
  };
922
+ /**
923
+ * Aiken alias
924
+ * The Plutus Data association map item in JSON
925
+ */
926
+ type Pair<K, V> = {
927
+ k: K;
928
+ v: V;
929
+ };
930
+ /**
931
+ * Aiken alias
932
+ * The Plutus Data association map in JSON
933
+ */
934
+ type Pairs<K = any, V = any> = {
935
+ map: Pair<K, V>[];
936
+ };
901
937
  /**
902
938
  * The utility function to create a Plutus Data boolean in JSON
903
939
  * @param b boolean value
@@ -948,6 +984,13 @@ declare const plutusBSArrayToString: (bsArray: List<ByteString>) => string;
948
984
  * @returns The Plutus Data association map object
949
985
  */
950
986
  declare const assocMap: <K, V>(mapItems: [K, V][], validation?: boolean) => AssocMap<K, V>;
987
+ /**
988
+ * The utility function to create a Plutus Data Pairs in JSON
989
+ * @param mapItems The items map in array
990
+ * @param validation Default true - If current data construction would perform validation (introducing this flag due to possible performance issue in loop validation)
991
+ * @returns The Plutus Data Pairs object
992
+ */
993
+ declare const pairs: <K, V>(mapItems: [K, V][], validation?: boolean) => Pairs<K, V>;
951
994
 
952
995
  /**
953
996
  * All the type aliases here represent the type name used in smart contracts from PlutusTx or Aiken.
@@ -1056,7 +1099,7 @@ declare const scriptHash: (bytes: string) => ScriptHash;
1056
1099
  * @param bytes The script hash in hex
1057
1100
  * @returns The Plutus Data script hash object
1058
1101
  */
1059
- declare const pubKeyHash: (bytes: string) => ScriptHash;
1102
+ declare const pubKeyHash: (bytes: string) => PubKeyHash;
1060
1103
  /**
1061
1104
  * The utility function to create a Plutus Data policy id in JSON
1062
1105
  * @param bytes The policy id in hex
@@ -1141,22 +1184,42 @@ declare const some: <T>(value: T) => Some<T>;
1141
1184
  */
1142
1185
  declare const none: () => None;
1143
1186
 
1187
+ /**
1188
+ * The Plutus Data verification key in JSON
1189
+ */
1190
+ type VerificationKey = ConStr0<[PubKeyHash]>;
1191
+ /**
1192
+ * The Plutus Data Script key in JSON
1193
+ */
1194
+ type Script = ConStr1<[ScriptHash]>;
1144
1195
  /**
1145
1196
  * The Plutus Data staking credential in JSON
1146
1197
  */
1147
- type MaybeStakingHash = ConStr1<[]> | ConStr0<[ConStr0<[ConStr0<[PubKeyHash]>]>]> | ConStr0<[ConStr0<[ConStr1<[ScriptHash]>]>]>;
1198
+ type MaybeStakingHash = ConStr1<[]> | ConStr0<[ConStr0<[VerificationKey]>]> | ConStr0<[ConStr0<[Script]>]>;
1148
1199
  /**
1149
1200
  * The Plutus Data public key address in JSON
1150
1201
  */
1151
- type PubKeyAddress = ConStr0<[ConStr0<[PubKeyHash]>, MaybeStakingHash]>;
1202
+ type PubKeyAddress = ConStr0<[VerificationKey, MaybeStakingHash]>;
1152
1203
  /**
1153
1204
  * The Plutus Data script address in JSON
1154
1205
  */
1155
- type ScriptAddress = ConStr0<[ConStr1<[ScriptHash]>, MaybeStakingHash]>;
1206
+ type ScriptAddress = ConStr0<[Script, MaybeStakingHash]>;
1156
1207
  /**
1157
1208
  * The Plutus Data credential in JSON
1158
1209
  */
1159
- type Credential = ConStr0<[PubKeyHash]> | ConStr1<[ScriptHash]>;
1210
+ type Credential = VerificationKey | Script;
1211
+ /**
1212
+ * The utility function to create a Plutus Data verification key in JSON
1213
+ * @param bytes The public key hash in hex
1214
+ * @returns The Plutus Data verification key object
1215
+ */
1216
+ declare const verificationKey: (bytes: string) => VerificationKey;
1217
+ /**
1218
+ * The utility function to create a Plutus Data script key in JSON
1219
+ * @param bytes The script hash in hex
1220
+ * @returns The Plutus Data script key object
1221
+ * */
1222
+ declare const script: (bytes: string) => Script;
1160
1223
  /**
1161
1224
  * The utility function to create a Plutus Data staking hash in JSON
1162
1225
  * @param stakeCredential The staking credential in hex
@@ -1188,7 +1251,33 @@ declare const scriptAddress: (bytes: string, stakeCredential?: string, isStakeSc
1188
1251
  */
1189
1252
  declare const credential: (hash: string, isScriptCredential?: boolean) => Credential;
1190
1253
 
1191
- type PlutusData = ConStr | Bool | ByteString | Integer | List | AssocMap | MaybeStakingHash | PubKeyAddress | ScriptAddress | AssetClass | OutputReference | PubKeyHash | POSIXTime | Dict<any> | Tuple<any, any>;
1254
+ type ProofStep = ProofStepBranch | ProofStepFork | ProofStepLeaf;
1255
+ type ProofStepBranch = ConStr0<[
1256
+ Integer,
1257
+ ByteString
1258
+ ]>;
1259
+ type ProofStepFork = ConStr1<[
1260
+ Integer,
1261
+ ForkNeighbor
1262
+ ]>;
1263
+ type ProofStepLeaf = ConStr2<[
1264
+ Integer,
1265
+ ByteString,
1266
+ ByteString
1267
+ ]>;
1268
+ type ForkNeighbor = ConStr0<[
1269
+ Integer,
1270
+ ByteString,
1271
+ ByteString
1272
+ ]>;
1273
+ /**
1274
+ * The utility function to transform a JSON proof from Aiken TS offchain library to Mesh JSON Data type
1275
+ * @param proof The proof object from Aiken TS offchain library
1276
+ * @returns The proof object in Mesh JSON Data type
1277
+ */
1278
+ declare const jsonProofToPlutusData: (proof: object) => ProofStep[];
1279
+
1280
+ type PlutusData = ConStr | Bool | ByteString | Integer | List | AssocMap | Pairs | MaybeStakingHash | PubKeyAddress | ScriptAddress | AssetClass | OutputReference | PubKeyHash | POSIXTime | Dict<any> | Tuple<any, any>;
1192
1281
 
1193
1282
  /**
1194
1283
  * Converting bytes to hex string
@@ -1681,4 +1770,4 @@ declare const hashDrepAnchor: (jsonLD: object) => string;
1681
1770
 
1682
1771
  declare function getFile(url: string): string;
1683
1772
 
1684
- export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, type BasicVote, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type CertificateType, type ConStr, type ConStr0, type ConStr1, type ConStr2, type ConStr3, type Credential, type CurrencySymbol, DEFAULT_FETCHER_OPTIONS, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, DEFAULT_V3_COST_MODEL_LIST, DREP_DEPOSIT, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type FungibleAssetMetadata, type GovernanceProposalInfo, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IFetcherOptions, type IInitiator, type IListener, type IMeshTxSerializer, type IMintingBlueprint, type IResolver, type ISigner, type ISpendingBlueprint, type ISubmitter, type IWallet, type IWithdrawalBlueprint, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MConStr3, type MCredential, type MMaybeStakingHash, type MNone, type MOption, type MOutputReference, type MPubKeyAddress, type MScriptAddress, type MSome, type MTuple, type MTxOutRef, type MValue, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Metadatum, type MetadatumMap, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type None, type Option, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type PlutusData, type PlutusDataType, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type PubKeyWithdrawal, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type ScriptVote, type ScriptWithdrawal, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SimpleScriptVote, type SimpleScriptWithdrawal, type SlotConfig, type Some, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxMetadata, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type Vote, type VoteKind, type VoteType, type Voter, type VotingProcedure, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, castProtocol, conStr, conStr0, conStr1, conStr2, conStr3, credential, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, getFile, hashByteString, hashDrepAnchor, hexToBytes, hexToString, integer, isNetwork, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mConStr3, mCredential, mMaybeStakingHash, mNone, mOption, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScriptAddress, mSome, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, none, option, outputReference, parseAssetUnit, plutusBSArrayToString, policyId, posixTime, pubKeyAddress, pubKeyHash, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, scriptAddress, scriptHash, slotToBeginUnixTime, some, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txInToUtxo, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value };
1773
+ export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, type BasicVote, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type CertificateType, type ConStr, type ConStr0, type ConStr1, type ConStr2, type ConStr3, type Credential, type CurrencySymbol, DEFAULT_FETCHER_OPTIONS, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, DEFAULT_V3_COST_MODEL_LIST, DREP_DEPOSIT, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type ForkNeighbor, type FungibleAssetMetadata, type GovernanceProposalInfo, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IFetcherOptions, type IInitiator, type IListener, type IMeshTxSerializer, type IMintingBlueprint, type IResolver, type ISigner, type ISpendingBlueprint, type ISubmitter, type IWallet, type IWithdrawalBlueprint, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MConStr3, type MCredential, type MMaybeStakingHash, type MNone, type MOption, type MOutputReference, type MPubKeyAddress, type MScript, type MScriptAddress, type MSome, type MTuple, type MTxOutRef, type MValue, type MVerificationKey, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Metadatum, type MetadatumMap, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type None, type Option, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type Pair, type Pairs, type PlutusData, type PlutusDataType, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type ProofStep, type ProofStepBranch, type ProofStepFork, type ProofStepLeaf, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type PubKeyWithdrawal, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type Script, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type ScriptVote, type ScriptWithdrawal, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SimpleScriptVote, type SimpleScriptWithdrawal, type SlotConfig, type Some, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxMetadata, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type VerificationKey, type Vote, type VoteKind, type VoteType, type Voter, type VotingProcedure, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, castProtocol, conStr, conStr0, conStr1, conStr2, conStr3, credential, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, getFile, hashByteString, hashDrepAnchor, hexToBytes, hexToString, integer, isNetwork, jsonProofToPlutusData, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mConStr3, mCredential, mMaybeStakingHash, mNone, mOption, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScript, mScriptAddress, mSome, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, mVerificationKey, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, none, option, outputReference, pairs, parseAssetUnit, plutusBSArrayToString, policyId, posixTime, pubKeyAddress, pubKeyHash, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, script, scriptAddress, scriptHash, slotToBeginUnixTime, some, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txInToUtxo, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value, verificationKey };
package/dist/index.d.ts CHANGED
@@ -731,22 +731,42 @@ declare const mSome: <T extends Data>(value: T) => MSome<T>;
731
731
  */
732
732
  declare const mNone: () => MNone;
733
733
 
734
+ /**
735
+ * The Mesh Data verification key
736
+ */
737
+ type MVerificationKey = MConStr0<[string]>;
738
+ /**
739
+ * The Mesh Data script key
740
+ */
741
+ type MScript = MConStr1<[string]>;
734
742
  /**
735
743
  * The Mesh Data staking credential
736
744
  */
737
- type MMaybeStakingHash = MConStr1<[]> | MConStr0<[MConStr0<[MConStr0<[string]>]>]> | MConStr0<[MConStr0<[MConStr1<[string]>]>]>;
745
+ type MMaybeStakingHash = MConStr1<[]> | MConStr0<[MConStr0<[MVerificationKey]>]> | MConStr0<[MConStr0<[MScript]>]>;
738
746
  /**
739
747
  * The Mesh Data public key address
740
748
  */
741
- type MPubKeyAddress = MConStr0<[MConStr0<[string]>, MMaybeStakingHash]>;
749
+ type MPubKeyAddress = MConStr0<[MVerificationKey, MMaybeStakingHash]>;
742
750
  /**
743
751
  * The Mesh Data script address
744
752
  */
745
- type MScriptAddress = MConStr0<[MConStr1<[string]>, MMaybeStakingHash]>;
753
+ type MScriptAddress = MConStr0<[MScript, MMaybeStakingHash]>;
746
754
  /**
747
755
  * The Mesh Data credential
748
756
  */
749
- type MCredential = MConStr0<[string]> | MConStr1<[string]>;
757
+ type MCredential = MVerificationKey | MScript;
758
+ /**
759
+ * The utility function to create a Mesh Data verification key
760
+ * @param bytes The public key hash in hex
761
+ * @returns The Mesh Data verification key object
762
+ */
763
+ declare const mVerificationKey: (bytes: string) => MVerificationKey;
764
+ /**
765
+ * The utility function to create a Mesh Data script key
766
+ * @param bytes The script hash in hex
767
+ * @returns The Mesh Data script key object
768
+ */
769
+ declare const mScript: (bytes: string) => MScript;
750
770
  /**
751
771
  * The utility function to create a Mesh Data staking hash
752
772
  * @param stakeCredential The staking credential in hex
@@ -893,11 +913,27 @@ type AssocMapItem<K, V> = {
893
913
  v: V;
894
914
  };
895
915
  /**
916
+ * PlutusTx alias
896
917
  * The Plutus Data association map in JSON
897
918
  */
898
919
  type AssocMap<K = any, V = any> = {
899
920
  map: AssocMapItem<K, V>[];
900
921
  };
922
+ /**
923
+ * Aiken alias
924
+ * The Plutus Data association map item in JSON
925
+ */
926
+ type Pair<K, V> = {
927
+ k: K;
928
+ v: V;
929
+ };
930
+ /**
931
+ * Aiken alias
932
+ * The Plutus Data association map in JSON
933
+ */
934
+ type Pairs<K = any, V = any> = {
935
+ map: Pair<K, V>[];
936
+ };
901
937
  /**
902
938
  * The utility function to create a Plutus Data boolean in JSON
903
939
  * @param b boolean value
@@ -948,6 +984,13 @@ declare const plutusBSArrayToString: (bsArray: List<ByteString>) => string;
948
984
  * @returns The Plutus Data association map object
949
985
  */
950
986
  declare const assocMap: <K, V>(mapItems: [K, V][], validation?: boolean) => AssocMap<K, V>;
987
+ /**
988
+ * The utility function to create a Plutus Data Pairs in JSON
989
+ * @param mapItems The items map in array
990
+ * @param validation Default true - If current data construction would perform validation (introducing this flag due to possible performance issue in loop validation)
991
+ * @returns The Plutus Data Pairs object
992
+ */
993
+ declare const pairs: <K, V>(mapItems: [K, V][], validation?: boolean) => Pairs<K, V>;
951
994
 
952
995
  /**
953
996
  * All the type aliases here represent the type name used in smart contracts from PlutusTx or Aiken.
@@ -1056,7 +1099,7 @@ declare const scriptHash: (bytes: string) => ScriptHash;
1056
1099
  * @param bytes The script hash in hex
1057
1100
  * @returns The Plutus Data script hash object
1058
1101
  */
1059
- declare const pubKeyHash: (bytes: string) => ScriptHash;
1102
+ declare const pubKeyHash: (bytes: string) => PubKeyHash;
1060
1103
  /**
1061
1104
  * The utility function to create a Plutus Data policy id in JSON
1062
1105
  * @param bytes The policy id in hex
@@ -1141,22 +1184,42 @@ declare const some: <T>(value: T) => Some<T>;
1141
1184
  */
1142
1185
  declare const none: () => None;
1143
1186
 
1187
+ /**
1188
+ * The Plutus Data verification key in JSON
1189
+ */
1190
+ type VerificationKey = ConStr0<[PubKeyHash]>;
1191
+ /**
1192
+ * The Plutus Data Script key in JSON
1193
+ */
1194
+ type Script = ConStr1<[ScriptHash]>;
1144
1195
  /**
1145
1196
  * The Plutus Data staking credential in JSON
1146
1197
  */
1147
- type MaybeStakingHash = ConStr1<[]> | ConStr0<[ConStr0<[ConStr0<[PubKeyHash]>]>]> | ConStr0<[ConStr0<[ConStr1<[ScriptHash]>]>]>;
1198
+ type MaybeStakingHash = ConStr1<[]> | ConStr0<[ConStr0<[VerificationKey]>]> | ConStr0<[ConStr0<[Script]>]>;
1148
1199
  /**
1149
1200
  * The Plutus Data public key address in JSON
1150
1201
  */
1151
- type PubKeyAddress = ConStr0<[ConStr0<[PubKeyHash]>, MaybeStakingHash]>;
1202
+ type PubKeyAddress = ConStr0<[VerificationKey, MaybeStakingHash]>;
1152
1203
  /**
1153
1204
  * The Plutus Data script address in JSON
1154
1205
  */
1155
- type ScriptAddress = ConStr0<[ConStr1<[ScriptHash]>, MaybeStakingHash]>;
1206
+ type ScriptAddress = ConStr0<[Script, MaybeStakingHash]>;
1156
1207
  /**
1157
1208
  * The Plutus Data credential in JSON
1158
1209
  */
1159
- type Credential = ConStr0<[PubKeyHash]> | ConStr1<[ScriptHash]>;
1210
+ type Credential = VerificationKey | Script;
1211
+ /**
1212
+ * The utility function to create a Plutus Data verification key in JSON
1213
+ * @param bytes The public key hash in hex
1214
+ * @returns The Plutus Data verification key object
1215
+ */
1216
+ declare const verificationKey: (bytes: string) => VerificationKey;
1217
+ /**
1218
+ * The utility function to create a Plutus Data script key in JSON
1219
+ * @param bytes The script hash in hex
1220
+ * @returns The Plutus Data script key object
1221
+ * */
1222
+ declare const script: (bytes: string) => Script;
1160
1223
  /**
1161
1224
  * The utility function to create a Plutus Data staking hash in JSON
1162
1225
  * @param stakeCredential The staking credential in hex
@@ -1188,7 +1251,33 @@ declare const scriptAddress: (bytes: string, stakeCredential?: string, isStakeSc
1188
1251
  */
1189
1252
  declare const credential: (hash: string, isScriptCredential?: boolean) => Credential;
1190
1253
 
1191
- type PlutusData = ConStr | Bool | ByteString | Integer | List | AssocMap | MaybeStakingHash | PubKeyAddress | ScriptAddress | AssetClass | OutputReference | PubKeyHash | POSIXTime | Dict<any> | Tuple<any, any>;
1254
+ type ProofStep = ProofStepBranch | ProofStepFork | ProofStepLeaf;
1255
+ type ProofStepBranch = ConStr0<[
1256
+ Integer,
1257
+ ByteString
1258
+ ]>;
1259
+ type ProofStepFork = ConStr1<[
1260
+ Integer,
1261
+ ForkNeighbor
1262
+ ]>;
1263
+ type ProofStepLeaf = ConStr2<[
1264
+ Integer,
1265
+ ByteString,
1266
+ ByteString
1267
+ ]>;
1268
+ type ForkNeighbor = ConStr0<[
1269
+ Integer,
1270
+ ByteString,
1271
+ ByteString
1272
+ ]>;
1273
+ /**
1274
+ * The utility function to transform a JSON proof from Aiken TS offchain library to Mesh JSON Data type
1275
+ * @param proof The proof object from Aiken TS offchain library
1276
+ * @returns The proof object in Mesh JSON Data type
1277
+ */
1278
+ declare const jsonProofToPlutusData: (proof: object) => ProofStep[];
1279
+
1280
+ type PlutusData = ConStr | Bool | ByteString | Integer | List | AssocMap | Pairs | MaybeStakingHash | PubKeyAddress | ScriptAddress | AssetClass | OutputReference | PubKeyHash | POSIXTime | Dict<any> | Tuple<any, any>;
1192
1281
 
1193
1282
  /**
1194
1283
  * Converting bytes to hex string
@@ -1681,4 +1770,4 @@ declare const hashDrepAnchor: (jsonLD: object) => string;
1681
1770
 
1682
1771
  declare function getFile(url: string): string;
1683
1772
 
1684
- export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, type BasicVote, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type CertificateType, type ConStr, type ConStr0, type ConStr1, type ConStr2, type ConStr3, type Credential, type CurrencySymbol, DEFAULT_FETCHER_OPTIONS, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, DEFAULT_V3_COST_MODEL_LIST, DREP_DEPOSIT, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type FungibleAssetMetadata, type GovernanceProposalInfo, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IFetcherOptions, type IInitiator, type IListener, type IMeshTxSerializer, type IMintingBlueprint, type IResolver, type ISigner, type ISpendingBlueprint, type ISubmitter, type IWallet, type IWithdrawalBlueprint, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MConStr3, type MCredential, type MMaybeStakingHash, type MNone, type MOption, type MOutputReference, type MPubKeyAddress, type MScriptAddress, type MSome, type MTuple, type MTxOutRef, type MValue, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Metadatum, type MetadatumMap, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type None, type Option, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type PlutusData, type PlutusDataType, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type PubKeyWithdrawal, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type ScriptVote, type ScriptWithdrawal, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SimpleScriptVote, type SimpleScriptWithdrawal, type SlotConfig, type Some, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxMetadata, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type Vote, type VoteKind, type VoteType, type Voter, type VotingProcedure, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, castProtocol, conStr, conStr0, conStr1, conStr2, conStr3, credential, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, getFile, hashByteString, hashDrepAnchor, hexToBytes, hexToString, integer, isNetwork, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mConStr3, mCredential, mMaybeStakingHash, mNone, mOption, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScriptAddress, mSome, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, none, option, outputReference, parseAssetUnit, plutusBSArrayToString, policyId, posixTime, pubKeyAddress, pubKeyHash, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, scriptAddress, scriptHash, slotToBeginUnixTime, some, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txInToUtxo, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value };
1773
+ export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, type BasicVote, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type CertificateType, type ConStr, type ConStr0, type ConStr1, type ConStr2, type ConStr3, type Credential, type CurrencySymbol, DEFAULT_FETCHER_OPTIONS, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, DEFAULT_V3_COST_MODEL_LIST, DREP_DEPOSIT, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type ForkNeighbor, type FungibleAssetMetadata, type GovernanceProposalInfo, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IFetcherOptions, type IInitiator, type IListener, type IMeshTxSerializer, type IMintingBlueprint, type IResolver, type ISigner, type ISpendingBlueprint, type ISubmitter, type IWallet, type IWithdrawalBlueprint, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MConStr3, type MCredential, type MMaybeStakingHash, type MNone, type MOption, type MOutputReference, type MPubKeyAddress, type MScript, type MScriptAddress, type MSome, type MTuple, type MTxOutRef, type MValue, type MVerificationKey, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Metadatum, type MetadatumMap, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type None, type Option, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type Pair, type Pairs, type PlutusData, type PlutusDataType, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type ProofStep, type ProofStepBranch, type ProofStepFork, type ProofStepLeaf, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type PubKeyWithdrawal, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type Script, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type ScriptVote, type ScriptWithdrawal, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SimpleScriptVote, type SimpleScriptWithdrawal, type SlotConfig, type Some, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxMetadata, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type VerificationKey, type Vote, type VoteKind, type VoteType, type Voter, type VotingProcedure, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, castProtocol, conStr, conStr0, conStr1, conStr2, conStr3, credential, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, getFile, hashByteString, hashDrepAnchor, hexToBytes, hexToString, integer, isNetwork, jsonProofToPlutusData, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mConStr3, mCredential, mMaybeStakingHash, mNone, mOption, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScript, mScriptAddress, mSome, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, mVerificationKey, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, none, option, outputReference, pairs, parseAssetUnit, plutusBSArrayToString, policyId, posixTime, pubKeyAddress, pubKeyHash, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, script, scriptAddress, scriptHash, slotToBeginUnixTime, some, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txInToUtxo, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value, verificationKey };
package/dist/index.js CHANGED
@@ -947,14 +947,16 @@ var mSome = (value2) => mConStr0([value2]);
947
947
  var mNone = () => mConStr1([]);
948
948
 
949
949
  // src/data/mesh/credentials.ts
950
+ var mVerificationKey = (bytes) => mConStr0([bytes]);
951
+ var mScript = (bytes) => mConStr1([bytes]);
950
952
  var mMaybeStakingHash = (stakeCredential, isStakeScriptCredential = false) => {
951
953
  if (stakeCredential === "") {
952
954
  return mConStr1([]);
953
955
  }
954
956
  if (isStakeScriptCredential) {
955
- return mConStr0([mConStr0([mConStr1([stakeCredential])])]);
957
+ return mConStr0([mConStr0([mScript(stakeCredential)])]);
956
958
  }
957
- return mConStr0([mConStr0([mConStr0([stakeCredential])])]);
959
+ return mConStr0([mConStr0([mVerificationKey(stakeCredential)])]);
958
960
  };
959
961
  var mPubKeyAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => mConStr0([
960
962
  { alternative: 0, fields: [bytes] },
@@ -964,7 +966,7 @@ var mScriptAddress = (bytes, stakeCredential, isStakeScriptCredential = false) =
964
966
  { alternative: 1, fields: [bytes] },
965
967
  mMaybeStakingHash(stakeCredential || "", isStakeScriptCredential)
966
968
  ]);
967
- var mCredential = (hash, isScriptCredential = false) => isScriptCredential ? mConStr1([hash]) : mConStr0([hash]);
969
+ var mCredential = (hash, isScriptCredential = false) => isScriptCredential ? mScript(hash) : mVerificationKey(hash);
968
970
 
969
971
  // src/data/mesh/primitives.ts
970
972
  var mBool = (b) => b ? mConStr1([]) : mConStr0([]);
@@ -1052,11 +1054,25 @@ var assocMap = (mapItems, validation = true) => ({
1052
1054
  return { k, v };
1053
1055
  })
1054
1056
  });
1057
+ var pairs = (mapItems, validation = true) => ({
1058
+ map: mapItems.map(([k, v]) => {
1059
+ if (validation) {
1060
+ if (typeof k !== "object" || typeof v !== "object") {
1061
+ throw new Error(
1062
+ `Map item of JSON Cardano data type must be an object - ${k}, ${v}`
1063
+ );
1064
+ }
1065
+ }
1066
+ return { k, v };
1067
+ })
1068
+ });
1055
1069
 
1056
1070
  // src/data/json/aliases.ts
1057
1071
  var hashByteString = (bytes) => {
1058
1072
  if (bytes.length !== 56) {
1059
- throw new Error(`Invalid hash for [${bytes}] - should be 56 bytes long`);
1073
+ throw new Error(
1074
+ `Invalid hash for [${bytes}] - should be 28 bytes (56 hex length) long`
1075
+ );
1060
1076
  }
1061
1077
  return byteString(bytes);
1062
1078
  };
@@ -1065,7 +1081,7 @@ var pubKeyHash = (bytes) => hashByteString(bytes);
1065
1081
  var policyId = (bytes) => {
1066
1082
  if (bytes.length !== POLICY_ID_LENGTH && bytes !== "") {
1067
1083
  throw new Error(
1068
- `Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH} bytes long or empty string for lovelace`
1084
+ `Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH / 2} bytes (${POLICY_ID_LENGTH} hex length) long or empty string for lovelace`
1069
1085
  );
1070
1086
  }
1071
1087
  return byteString(bytes);
@@ -1108,28 +1124,56 @@ var some = (value2) => conStr0([value2]);
1108
1124
  var none = () => conStr1([]);
1109
1125
 
1110
1126
  // src/data/json/credentials.ts
1127
+ var verificationKey = (bytes) => conStr0([pubKeyHash(bytes)]);
1128
+ var script = (bytes) => conStr1([scriptHash(bytes)]);
1111
1129
  var maybeStakingHash = (stakeCredential, isStakeScriptCredential = false) => {
1112
1130
  if (stakeCredential === "") {
1113
1131
  return conStr1([]);
1114
1132
  }
1115
1133
  if (isStakeScriptCredential) {
1116
- return conStr0([
1117
- conStr0([conStr1([scriptHash(stakeCredential)])])
1118
- ]);
1134
+ return conStr0([conStr0([script(stakeCredential)])]);
1119
1135
  }
1120
- return conStr0([
1121
- conStr0([conStr0([pubKeyHash(stakeCredential)])])
1122
- ]);
1136
+ return conStr0([conStr0([verificationKey(stakeCredential)])]);
1123
1137
  };
1124
1138
  var pubKeyAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => conStr0([
1125
1139
  conStr0([pubKeyHash(bytes)]),
1126
1140
  maybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1127
1141
  ]);
1128
1142
  var scriptAddress = (bytes, stakeCredential, isStakeScriptCredential = false) => conStr0([
1129
- conStr1([scriptHash(bytes)]),
1143
+ script(bytes),
1130
1144
  maybeStakingHash(stakeCredential || "", isStakeScriptCredential)
1131
1145
  ]);
1132
- var credential = (hash, isScriptCredential = false) => isScriptCredential ? conStr1([scriptHash(hash)]) : conStr0([pubKeyHash(hash)]);
1146
+ var credential = (hash, isScriptCredential = false) => isScriptCredential ? script(hash) : verificationKey(hash);
1147
+
1148
+ // src/data/json/mpf.ts
1149
+ var jsonProofToPlutusData = (proof) => {
1150
+ const proofSteps = [];
1151
+ const proofJson = proof;
1152
+ proofJson.forEach((proof2) => {
1153
+ const skip = integer(proof2.skip);
1154
+ switch (proof2.type) {
1155
+ case "branch":
1156
+ proofSteps.push(
1157
+ conStr0([skip, byteString(proof2.neighbors.toString("hex"))])
1158
+ );
1159
+ break;
1160
+ case "fork":
1161
+ const { prefix, nibble, root } = proof2.neighbor;
1162
+ const neighbor = conStr0([
1163
+ integer(nibble),
1164
+ byteString(prefix.toString("hex")),
1165
+ byteString(root.toString("hex"))
1166
+ ]);
1167
+ proofSteps.push(conStr1([skip, neighbor]));
1168
+ break;
1169
+ case "leaf":
1170
+ const { key, value: value2 } = proof2.neighbor;
1171
+ proofSteps.push(conStr2([skip, byteString(key), byteString(value2)]));
1172
+ break;
1173
+ }
1174
+ });
1175
+ return proofSteps;
1176
+ };
1133
1177
 
1134
1178
  // src/data/parser.ts
1135
1179
  var bytesToHex = (bytes) => Buffer.from(bytes).toString("hex");
@@ -1578,7 +1622,7 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1578
1622
  const selectedInputs = /* @__PURE__ */ new Set();
1579
1623
  const onlyLovelace = /* @__PURE__ */ new Set();
1580
1624
  const singletons = /* @__PURE__ */ new Set();
1581
- const pairs = /* @__PURE__ */ new Set();
1625
+ const pairs2 = /* @__PURE__ */ new Set();
1582
1626
  const rest = /* @__PURE__ */ new Set();
1583
1627
  const collaterals = /* @__PURE__ */ new Set();
1584
1628
  for (let i = 0; i < inputs.length; i++) {
@@ -1597,7 +1641,7 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1597
1641
  break;
1598
1642
  }
1599
1643
  case 3: {
1600
- pairs.add(i);
1644
+ pairs2.add(i);
1601
1645
  break;
1602
1646
  }
1603
1647
  default: {
@@ -1630,10 +1674,10 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1630
1674
  if (!assetRequired || Number(assetRequired) <= 0) break;
1631
1675
  addUtxoWithAssetAmount(inputIndex, assetUnit, singletons);
1632
1676
  }
1633
- for (const inputIndex of pairs) {
1677
+ for (const inputIndex of pairs2) {
1634
1678
  const assetRequired = totalRequiredAssets.get(assetUnit);
1635
1679
  if (!assetRequired || Number(assetRequired) <= 0) break;
1636
- addUtxoWithAssetAmount(inputIndex, assetUnit, pairs);
1680
+ addUtxoWithAssetAmount(inputIndex, assetUnit, pairs2);
1637
1681
  }
1638
1682
  for (const inputIndex of rest) {
1639
1683
  const assetRequired = totalRequiredAssets.get(assetUnit);
@@ -1651,10 +1695,10 @@ var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
1651
1695
  if (!assetRequired || Number(assetRequired) <= 0) break;
1652
1696
  addUtxoWithAssetAmount(inputIndex, "lovelace", singletons);
1653
1697
  }
1654
- for (const inputIndex of pairs) {
1698
+ for (const inputIndex of pairs2) {
1655
1699
  const assetRequired = totalRequiredAssets.get("lovelace");
1656
1700
  if (!assetRequired || Number(assetRequired) <= 0) break;
1657
- addUtxoWithAssetAmount(inputIndex, "lovelace", pairs);
1701
+ addUtxoWithAssetAmount(inputIndex, "lovelace", pairs2);
1658
1702
  }
1659
1703
  for (const inputIndex of rest) {
1660
1704
  const assetRequired = totalRequiredAssets.get("lovelace");
@@ -1883,6 +1927,7 @@ export {
1883
1927
  hexToString,
1884
1928
  integer,
1885
1929
  isNetwork,
1930
+ jsonProofToPlutusData,
1886
1931
  keepRelevant,
1887
1932
  largestFirst,
1888
1933
  largestFirstMultiAsset,
@@ -1901,12 +1946,14 @@ export {
1901
1946
  mOutputReference,
1902
1947
  mPlutusBSArrayToString,
1903
1948
  mPubKeyAddress,
1949
+ mScript,
1904
1950
  mScriptAddress,
1905
1951
  mSome,
1906
1952
  mStringToPlutusBSArray,
1907
1953
  mTuple,
1908
1954
  mTxOutRef,
1909
1955
  mValue,
1956
+ mVerificationKey,
1910
1957
  maybeStakingHash,
1911
1958
  mergeAssets,
1912
1959
  metadataStandardKeys,
@@ -1915,6 +1962,7 @@ export {
1915
1962
  none,
1916
1963
  option,
1917
1964
  outputReference,
1965
+ pairs,
1918
1966
  parseAssetUnit,
1919
1967
  plutusBSArrayToString,
1920
1968
  policyId,
@@ -1927,6 +1975,7 @@ export {
1927
1975
  resolveSlotNo,
1928
1976
  resolveTxFees,
1929
1977
  royaltiesStandardKeys,
1978
+ script,
1930
1979
  scriptAddress,
1931
1980
  scriptHash,
1932
1981
  slotToBeginUnixTime,
@@ -1941,5 +1990,6 @@ export {
1941
1990
  txOutRef,
1942
1991
  unixTimeToEnclosingSlot,
1943
1992
  validityRangeToObj,
1944
- value
1993
+ value,
1994
+ verificationKey
1945
1995
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/common",
3
- "version": "1.9.0-beta.23",
3
+ "version": "1.9.0-beta.25",
4
4
  "description": "Contains constants, types and interfaces used across the SDK and different serialization libraries",
5
5
  "main": "./dist/index.cjs",
6
6
  "browser": "./dist/index.js",