@meshsdk/core-cst 1.9.0-beta.54 → 1.9.0-beta.55

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
@@ -3783,6 +3783,7 @@ var BootstrapWitness = import_core.Serialization.BootstrapWitness;
3783
3783
 
3784
3784
  // src/message-signing/check-signature.ts
3785
3785
  var import_crypto = require("@cardano-sdk/crypto");
3786
+ var import_common = require("@meshsdk/common");
3786
3787
 
3787
3788
  // src/message-signing/cose-sign1.ts
3788
3789
  var import_buffer = require("buffer");
@@ -4006,7 +4007,8 @@ var checkSignature = async (data, { key, signature }, address) => {
4006
4007
  if (builder.getPayload() === null) {
4007
4008
  return false;
4008
4009
  }
4009
- if (Buffer.from(data, "hex").compare(builder.getPayload()) !== 0) {
4010
+ const hexData = (0, import_common.isHexString)(data) ? data : (0, import_common.stringToHex)(data);
4011
+ if (Buffer.from(hexData, "hex").compare(builder.getPayload()) !== 0) {
4010
4012
  return false;
4011
4013
  }
4012
4014
  return builder.verifySignature({
@@ -4052,7 +4054,7 @@ var customRandom = (alphabet, defaultSize, getRandom) => {
4052
4054
  var customAlphabet = (alphabet, size = 21) => customRandom(alphabet, size, random);
4053
4055
 
4054
4056
  // src/message-signing/generate-nonce.ts
4055
- var import_common = require("@meshsdk/common");
4057
+ var import_common2 = require("@meshsdk/common");
4056
4058
  var generateNonce = (label = "", length = 32) => {
4057
4059
  if (length <= 0 || length > 2048) {
4058
4060
  throw new Error("Length must be bewteen 1 and 2048");
@@ -4061,13 +4063,15 @@ var generateNonce = (label = "", length = 32) => {
4061
4063
  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
4062
4064
  );
4063
4065
  const payload = randomString(length);
4064
- return (0, import_common.stringToHex)(`${label}${payload}`);
4066
+ return (0, import_common2.stringToHex)(`${label}${payload}`);
4065
4067
  };
4066
4068
 
4067
4069
  // src/message-signing/sign-data.ts
4068
4070
  var import_cbor2 = require("@harmoniclabs/cbor");
4071
+ var import_common3 = require("@meshsdk/common");
4069
4072
  var signData = (data, signer) => {
4070
- const payload = Buffer.from(data, "hex");
4073
+ const hexData = (0, import_common3.isHexString)(data) ? data : (0, import_common3.stringToHex)(data);
4074
+ const payload = Buffer.from(hexData, "hex");
4071
4075
  const publicKey = Buffer.from(signer.key.toPublic().bytes());
4072
4076
  const protectedMap = [];
4073
4077
  protectedMap.push({ k: new import_cbor2.CborUInt(1), v: new import_cbor2.CborNegInt(-8) });
@@ -4097,14 +4101,14 @@ var import_crypto7 = require("@cardano-sdk/crypto");
4097
4101
  var import_util7 = require("@cardano-sdk/util");
4098
4102
  var import_base32_encoding3 = __toESM(require("base32-encoding"), 1);
4099
4103
  var import_bech323 = require("bech32");
4100
- var import_common7 = require("@meshsdk/common");
4104
+ var import_common9 = require("@meshsdk/common");
4101
4105
 
4102
4106
  // src/utils/builder.ts
4103
4107
  var import_crypto3 = require("crypto");
4104
4108
  var import_crypto4 = require("@cardano-sdk/crypto");
4105
4109
  var import_util2 = require("@cardano-sdk/util");
4106
4110
  var import_hash = __toESM(require_hash(), 1);
4107
- var import_common2 = require("@meshsdk/common");
4111
+ var import_common4 = require("@meshsdk/common");
4108
4112
  var buildBaseAddress = (networkId, paymentKeyHash, stakeKeyHash) => {
4109
4113
  return BaseAddress.fromCredentials(
4110
4114
  networkId,
@@ -4161,11 +4165,11 @@ var buildKeys = (privateKeyHex, accountIndex, keyIndex = 0) => {
4161
4165
  Bip32PrivateKeyHex2(privateKeyHex)
4162
4166
  );
4163
4167
  const accountKey = privateKey.derive([
4164
- import_common2.HARDENED_KEY_START + 1852,
4168
+ import_common4.HARDENED_KEY_START + 1852,
4165
4169
  // purpose
4166
- import_common2.HARDENED_KEY_START + 1815,
4170
+ import_common4.HARDENED_KEY_START + 1815,
4167
4171
  // coin type
4168
- import_common2.HARDENED_KEY_START + accountIndex
4172
+ import_common4.HARDENED_KEY_START + accountIndex
4169
4173
  // account index
4170
4174
  ]);
4171
4175
  const paymentKey = accountKey.derive([0, keyIndex]).toRawKey();
@@ -4220,11 +4224,11 @@ var import_crypto6 = require("@cardano-sdk/crypto");
4220
4224
  var import_util5 = require("@cardano-sdk/util");
4221
4225
  var import_base32_encoding = __toESM(require("base32-encoding"), 1);
4222
4226
  var import_bech32 = require("bech32");
4223
- var import_common5 = require("@meshsdk/common");
4227
+ var import_common7 = require("@meshsdk/common");
4224
4228
 
4225
4229
  // src/utils/data.ts
4226
4230
  var import_util3 = require("@cardano-sdk/util");
4227
- var import_common3 = require("@meshsdk/common");
4231
+ var import_common5 = require("@meshsdk/common");
4228
4232
  var toPlutusData = (data) => {
4229
4233
  const toPlutusList = (data2) => {
4230
4234
  const plutusList = new PlutusList();
@@ -4235,7 +4239,7 @@ var toPlutusData = (data) => {
4235
4239
  };
4236
4240
  switch (typeof data) {
4237
4241
  case "string":
4238
- return PlutusData.newBytes((0, import_common3.toBytes)(data));
4242
+ return PlutusData.newBytes((0, import_common5.toBytes)(data));
4239
4243
  case "number":
4240
4244
  return PlutusData.newInteger(BigInt(data));
4241
4245
  case "bigint":
@@ -4435,8 +4439,8 @@ var deserializePlutusData = (plutusData) => PlutusData.fromCbor((0, import_util3
4435
4439
  var import_core2 = require("@cardano-sdk/core");
4436
4440
  var import_crypto5 = require("@cardano-sdk/crypto");
4437
4441
  var import_util4 = require("@cardano-sdk/util");
4438
- var import_common4 = require("@meshsdk/common");
4439
- var deserializeEd25519KeyHash = (ed25519KeyHash) => Ed25519KeyHash2.fromBytes((0, import_common4.toBytes)(ed25519KeyHash));
4442
+ var import_common6 = require("@meshsdk/common");
4443
+ var deserializeEd25519KeyHash = (ed25519KeyHash) => Ed25519KeyHash2.fromBytes((0, import_common6.toBytes)(ed25519KeyHash));
4440
4444
  var deserializePlutusScript = (plutusScript, version) => {
4441
4445
  switch (version) {
4442
4446
  case "V1":
@@ -4682,7 +4686,7 @@ var toNativeScript = (script) => {
4682
4686
  case "sig":
4683
4687
  return NativeScript.newScriptPubkey(
4684
4688
  new import_core3.Serialization.ScriptPubkey(
4685
- import_crypto6.Ed25519KeyHash.fromBytes((0, import_common5.toBytes)(script.keyHash)).hex()
4689
+ import_crypto6.Ed25519KeyHash.fromBytes((0, import_common7.toBytes)(script.keyHash)).hex()
4686
4690
  )
4687
4691
  );
4688
4692
  }
@@ -4854,7 +4858,7 @@ function empty(v) {
4854
4858
 
4855
4859
  // src/utils/address.ts
4856
4860
  var import_util6 = require("@cardano-sdk/util");
4857
- var import_common6 = require("@meshsdk/common");
4861
+ var import_common8 = require("@meshsdk/common");
4858
4862
  var serialzeAddress = (deserializedAddress, networkId = 0) => {
4859
4863
  const {
4860
4864
  pubKeyHash,
@@ -4870,7 +4874,7 @@ var serialzeAddress = (deserializedAddress, networkId = 0) => {
4870
4874
  throw new Error(
4871
4875
  "Error: serializeAddress: Address must contain a payment part"
4872
4876
  );
4873
- const addressObj = isPaymentScript ? (0, import_common6.scriptAddress)(paymentHash, stakeHash, isStakeScript) : (0, import_common6.pubKeyAddress)(paymentHash, stakeHash, isStakeScript);
4877
+ const addressObj = isPaymentScript ? (0, import_common8.scriptAddress)(paymentHash, stakeHash, isStakeScript) : (0, import_common8.pubKeyAddress)(paymentHash, stakeHash, isStakeScript);
4874
4878
  return serializeAddressObj(addressObj, networkId);
4875
4879
  };
4876
4880
  var addrBech32ToPlutusData = (bech325) => {
@@ -5292,11 +5296,11 @@ var resolvePoolId = (hash2) => {
5292
5296
  var resolvePrivateKey = (words) => {
5293
5297
  const buildBip32PrivateKey2 = (entropy2, password = "") => {
5294
5298
  return Bip32PrivateKey2.fromBip39Entropy(
5295
- Buffer.from((0, import_common7.toBytes)(entropy2)),
5296
- (0, import_common7.fromUTF8)(password)
5299
+ Buffer.from((0, import_common9.toBytes)(entropy2)),
5300
+ (0, import_common9.fromUTF8)(password)
5297
5301
  );
5298
5302
  };
5299
- const entropy = (0, import_common7.mnemonicToEntropy)(words.join(" "));
5303
+ const entropy = (0, import_common9.mnemonicToEntropy)(words.join(" "));
5300
5304
  const bip32PrivateKey = buildBip32PrivateKey2(entropy);
5301
5305
  const bytes = import_base32_encoding3.default.encode(bip32PrivateKey.bytes());
5302
5306
  const bech32PrivateKey = import_bech323.bech32.encode("xprv", bytes, 1023);
@@ -5362,7 +5366,7 @@ var import_util9 = require("@cardano-sdk/util");
5362
5366
  var import_cbor3 = require("@harmoniclabs/cbor");
5363
5367
  var import_base32_encoding4 = __toESM(require("base32-encoding"), 1);
5364
5368
  var import_bech324 = require("bech32");
5365
- var import_common8 = require("@meshsdk/common");
5369
+ var import_common10 = require("@meshsdk/common");
5366
5370
 
5367
5371
  // src/utils/certificate.ts
5368
5372
  var import_core5 = require("@cardano-sdk/core");
@@ -5889,7 +5893,7 @@ var CardanoSDKSerializer = class {
5889
5893
  protocolParams;
5890
5894
  constructor(protocolParams) {
5891
5895
  (0, import_core8.setInConwayEra)(true);
5892
- this.protocolParams = protocolParams || import_common8.DEFAULT_PROTOCOL_PARAMETERS;
5896
+ this.protocolParams = protocolParams || import_common10.DEFAULT_PROTOCOL_PARAMETERS;
5893
5897
  }
5894
5898
  serializeRewardAddress(stakeKeyHash, isScriptHash, network_id) {
5895
5899
  return RewardAddress.fromCredentials(network_id ?? 0, {
@@ -6019,11 +6023,11 @@ var CardanoSDKSerializer = class {
6019
6023
  resolvePrivateKey: function(words) {
6020
6024
  const buildBip32PrivateKey2 = (entropy2, password = "") => {
6021
6025
  return Bip32PrivateKey2.fromBip39Entropy(
6022
- import_buffer2.Buffer.from((0, import_common8.toBytes)(entropy2)),
6023
- (0, import_common8.fromUTF8)(password)
6026
+ import_buffer2.Buffer.from((0, import_common10.toBytes)(entropy2)),
6027
+ (0, import_common10.fromUTF8)(password)
6024
6028
  );
6025
6029
  };
6026
- const entropy = (0, import_common8.mnemonicToEntropy)(words.join(" "));
6030
+ const entropy = (0, import_common10.mnemonicToEntropy)(words.join(" "));
6027
6031
  const bip32PrivateKey = buildBip32PrivateKey2(entropy);
6028
6032
  const bytes = import_base32_encoding4.default.encode(bip32PrivateKey.bytes());
6029
6033
  const bech32PrivateKey = import_bech324.bech32.encode("xprv", bytes, 1023);
@@ -6229,7 +6233,7 @@ var CardanoSDKSerializerCore = class {
6229
6233
  protocolParams;
6230
6234
  refScriptSize;
6231
6235
  constructor(protocolParams) {
6232
- this.protocolParams = protocolParams || import_common8.DEFAULT_PROTOCOL_PARAMETERS;
6236
+ this.protocolParams = protocolParams || import_common10.DEFAULT_PROTOCOL_PARAMETERS;
6233
6237
  this.txBody = new TransactionBody(
6234
6238
  import_core8.Serialization.CborSet.fromCore([], TransactionInput.fromCore),
6235
6239
  [],
@@ -6969,13 +6973,13 @@ var CardanoSDKSerializerCore = class {
6969
6973
  datums.setValues(datumsList);
6970
6974
  this.txWitnessSet.setPlutusData(datums);
6971
6975
  let costModelV1 = import_core8.Serialization.CostModel.newPlutusV1(
6972
- import_common8.DEFAULT_V1_COST_MODEL_LIST
6976
+ import_common10.DEFAULT_V1_COST_MODEL_LIST
6973
6977
  );
6974
6978
  let costModelV2 = import_core8.Serialization.CostModel.newPlutusV2(
6975
- import_common8.DEFAULT_V2_COST_MODEL_LIST
6979
+ import_common10.DEFAULT_V2_COST_MODEL_LIST
6976
6980
  );
6977
6981
  let costModelV3 = import_core8.Serialization.CostModel.newPlutusV3(
6978
- import_common8.DEFAULT_V3_COST_MODEL_LIST
6982
+ import_common10.DEFAULT_V3_COST_MODEL_LIST
6979
6983
  );
6980
6984
  let costModels = new import_core8.Serialization.Costmdls();
6981
6985
  if (this.usedLanguages[PlutusLanguageVersion.V1]) {
package/dist/index.js CHANGED
@@ -3592,6 +3592,7 @@ var BootstrapWitness = Serialization.BootstrapWitness;
3592
3592
 
3593
3593
  // src/message-signing/check-signature.ts
3594
3594
  import { ready } from "@cardano-sdk/crypto";
3595
+ import { isHexString, stringToHex } from "@meshsdk/common";
3595
3596
 
3596
3597
  // src/message-signing/cose-sign1.ts
3597
3598
  var import_json_bigint = __toESM(require_json_bigint(), 1);
@@ -3826,7 +3827,8 @@ var checkSignature = async (data, { key, signature }, address) => {
3826
3827
  if (builder.getPayload() === null) {
3827
3828
  return false;
3828
3829
  }
3829
- if (Buffer.from(data, "hex").compare(builder.getPayload()) !== 0) {
3830
+ const hexData = isHexString(data) ? data : stringToHex(data);
3831
+ if (Buffer.from(hexData, "hex").compare(builder.getPayload()) !== 0) {
3830
3832
  return false;
3831
3833
  }
3832
3834
  return builder.verifySignature({
@@ -3872,7 +3874,7 @@ var customRandom = (alphabet, defaultSize, getRandom) => {
3872
3874
  var customAlphabet = (alphabet, size = 21) => customRandom(alphabet, size, random);
3873
3875
 
3874
3876
  // src/message-signing/generate-nonce.ts
3875
- import { stringToHex } from "@meshsdk/common";
3877
+ import { stringToHex as stringToHex2 } from "@meshsdk/common";
3876
3878
  var generateNonce = (label = "", length = 32) => {
3877
3879
  if (length <= 0 || length > 2048) {
3878
3880
  throw new Error("Length must be bewteen 1 and 2048");
@@ -3881,7 +3883,7 @@ var generateNonce = (label = "", length = 32) => {
3881
3883
  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
3882
3884
  );
3883
3885
  const payload = randomString(length);
3884
- return stringToHex(`${label}${payload}`);
3886
+ return stringToHex2(`${label}${payload}`);
3885
3887
  };
3886
3888
 
3887
3889
  // src/message-signing/sign-data.ts
@@ -3892,8 +3894,10 @@ import {
3892
3894
  CborText as CborText2,
3893
3895
  CborUInt as CborUInt2
3894
3896
  } from "@harmoniclabs/cbor";
3897
+ import { stringToHex as stringToHex3, isHexString as isHexString2 } from "@meshsdk/common";
3895
3898
  var signData = (data, signer) => {
3896
- const payload = Buffer.from(data, "hex");
3899
+ const hexData = isHexString2(data) ? data : stringToHex3(data);
3900
+ const payload = Buffer.from(hexData, "hex");
3897
3901
  const publicKey = Buffer.from(signer.key.toPublic().bytes());
3898
3902
  const protectedMap = [];
3899
3903
  protectedMap.push({ k: new CborUInt2(1), v: new CborNegInt2(-8) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/core-cst",
3
- "version": "1.9.0-beta.54",
3
+ "version": "1.9.0-beta.55",
4
4
  "description": "Types and utilities functions between Mesh and cardano-js-sdk",
5
5
  "main": "./dist/index.cjs",
6
6
  "browser": "./dist/index.js",
@@ -44,7 +44,7 @@
44
44
  "@harmoniclabs/plutus-data": "1.2.4",
45
45
  "@harmoniclabs/uplc": "1.2.4",
46
46
  "@harmoniclabs/pair": "^1.0.0",
47
- "@meshsdk/common": "1.9.0-beta.54",
47
+ "@meshsdk/common": "1.9.0-beta.55",
48
48
  "@types/base32-encoding": "^1.0.2",
49
49
  "base32-encoding": "^1.0.0",
50
50
  "bech32": "^2.0.0",