@meshsdk/common 1.6.2 → 1.6.3

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.d.ts CHANGED
@@ -173,7 +173,6 @@ type Relay = {
173
173
  type: "MultiHostName";
174
174
  domainName: string;
175
175
  };
176
- declare const relayToObj: (relay: Relay) => object;
177
176
 
178
177
  type PoolParams = {
179
178
  vrfKeyHash: string;
@@ -186,12 +185,10 @@ type PoolParams = {
186
185
  rewardAddress: string;
187
186
  metadata?: PoolMetadata;
188
187
  };
189
- declare const poolParamsToObj: (poolParams: PoolParams) => object;
190
188
  type PoolMetadata = {
191
189
  URL: string;
192
190
  hash: string;
193
191
  };
194
- declare const poolMetadataToObj: (poolMetadata: PoolMetadata) => object;
195
192
 
196
193
  type Protocol = {
197
194
  epoch: number;
@@ -215,6 +212,7 @@ type Protocol = {
215
212
  maxCollateralInputs: number;
216
213
  coinsPerUtxoSize: number;
217
214
  };
215
+ declare const castProtocol: (data: Partial<Record<keyof Protocol, any>>) => Protocol;
218
216
 
219
217
  type Token = keyof typeof SUPPORTED_TOKENS;
220
218
 
@@ -328,127 +326,81 @@ type SimpleScriptSourceInfo = {
328
326
  simpleScriptHash: string;
329
327
  };
330
328
 
331
- type MintItem = {
332
- type: "Plutus" | "Native";
333
- policyId: string;
334
- assetName: string;
335
- amount: string;
329
+ type Certificate = {
330
+ type: "BasicCertificate";
331
+ certType: CertificateType;
332
+ } | {
333
+ type: "ScriptCertificate";
334
+ certType: CertificateType;
336
335
  redeemer?: Redeemer;
337
- scriptSource?: ScriptSource | SimpleScriptSourceInfo;
338
- };
339
-
340
- type Output = {
341
- address: string;
342
- amount: Asset[];
343
- datum?: {
344
- type: "Hash" | "Inline";
345
- data: BuilderData;
346
- };
347
- referenceScript?: PlutusScript;
348
- };
349
-
350
- type RefTxIn = {
351
- txHash: string;
352
- txIndex: number;
353
- };
354
- type TxInParameter = {
355
- txHash: string;
356
- txIndex: number;
357
- amount?: Asset[];
358
- address?: string;
359
- };
360
- type TxIn = PubKeyTxIn | SimpleScriptTxIn | ScriptTxIn;
361
- type PubKeyTxIn = {
362
- type: "PubKey";
363
- txIn: TxInParameter;
364
- };
365
- type SimpleScriptTxIn = {
366
- type: "SimpleScript";
367
- txIn: TxInParameter;
368
- simpleScriptTxIn: SimpleScriptTxInParameter;
369
- };
370
- type SimpleScriptTxInParameter = {
371
- scriptSource?: {
372
- type: "Provided";
373
- script: string;
374
- } | {
375
- type: "Inline";
376
- txInInfo: SimpleScriptSourceInfo;
377
- };
378
- };
379
- type ScriptTxInParameter = {
380
336
  scriptSource?: ScriptSource;
381
- datumSource?: DatumSource;
382
- redeemer?: Redeemer;
383
- };
384
- type ScriptTxIn = {
385
- type: "Script";
386
- txIn: TxInParameter;
387
- scriptTxIn: ScriptTxInParameter;
337
+ } | {
338
+ type: "SimpleScriptCertificate";
339
+ certType: CertificateType;
340
+ simpleScriptSource?: SimpleScriptSourceInfo;
388
341
  };
389
-
390
- type Certificate = {
342
+ type CertificateType = {
391
343
  type: "RegisterPool";
392
344
  poolParams: PoolParams;
393
345
  } | {
394
346
  type: "RegisterStake";
395
- stakeKeyHash: string;
347
+ stakeKeyAddress: string;
396
348
  } | {
397
349
  type: "DelegateStake";
398
- stakeKeyHash: string;
350
+ stakeKeyAddress: string;
399
351
  poolId: string;
400
352
  } | {
401
353
  type: "DeregisterStake";
402
- stakeKeyHash: string;
354
+ stakeKeyAddress: string;
403
355
  } | {
404
356
  type: "RetirePool";
405
357
  poolId: string;
406
358
  epoch: number;
407
359
  } | {
408
360
  type: "VoteDelegation";
409
- stakeKeyHash: string;
361
+ stakeKeyAddress: string;
410
362
  drep: DRep;
411
363
  } | {
412
364
  type: "StakeAndVoteDelegation";
413
- stakeKeyHash: string;
365
+ stakeKeyAddress: string;
414
366
  poolKeyHash: string;
415
367
  drep: DRep;
416
368
  } | {
417
369
  type: "StakeRegistrationAndDelegation";
418
- stakeKeyHash: string;
370
+ stakeKeyAddress: string;
419
371
  poolKeyHash: string;
420
372
  coin: number;
421
373
  } | {
422
374
  type: "VoteRegistrationAndDelegation";
423
- stakeKeyHash: string;
375
+ stakeKeyAddress: string;
424
376
  drep: DRep;
425
377
  coin: number;
426
378
  } | {
427
379
  type: "StakeVoteRegistrationAndDelegation";
428
- stakeKeyHash: string;
380
+ stakeKeyAddress: string;
429
381
  poolKeyHash: string;
430
382
  drep: DRep;
431
383
  coin: number;
432
384
  } | {
433
385
  type: "CommitteeHotAuth";
434
- committeeColdKeyHash: string;
435
- committeeHotKeyHash: string;
386
+ committeeColdKeyAddress: string;
387
+ committeeHotKeyAddress: string;
436
388
  } | {
437
389
  type: "CommitteeColdResign";
438
- committeeColdKeyHash: string;
390
+ committeeColdKeyAddress: string;
439
391
  anchor?: Anchor;
440
392
  } | {
441
393
  type: "DRepRegistration";
442
- votingKeyHash: string;
394
+ votingKeyAddress: string;
443
395
  coin: number;
444
396
  anchor?: Anchor;
445
397
  } | {
446
398
  type: "DRepDeregistration";
447
- votingKeyHash: string;
399
+ votingKeyAddress: string;
448
400
  coin: number;
449
401
  } | {
450
402
  type: "DRepUpdate";
451
- votingKeyHash: string;
403
+ votingKeyAddress: string;
452
404
  anchor: Anchor;
453
405
  };
454
406
  type DRep = {
@@ -464,20 +416,85 @@ type Anchor = {
464
416
  anchorUrl: string;
465
417
  anchorDataHash: string;
466
418
  };
467
- type Withdrawal = {
468
- pubKeyWithdrawal: {
469
- address: string;
470
- coin: string;
419
+
420
+ type MintItem = {
421
+ type: "Plutus" | "Native";
422
+ policyId: string;
423
+ assetName: string;
424
+ amount: string;
425
+ redeemer?: Redeemer;
426
+ scriptSource?: ScriptSource | SimpleScriptSourceInfo;
427
+ };
428
+
429
+ type Output = {
430
+ address: string;
431
+ amount: Asset[];
432
+ datum?: {
433
+ type: "Hash" | "Inline";
434
+ data: BuilderData;
471
435
  };
472
- } | {
473
- plutusScriptWithdrawal: {
474
- address: string;
475
- coin: string;
476
- scriptSource?: ScriptSource;
477
- redeemer?: Redeemer;
436
+ referenceScript?: PlutusScript;
437
+ };
438
+
439
+ type RefTxIn = {
440
+ txHash: string;
441
+ txIndex: number;
442
+ };
443
+ type TxInParameter = {
444
+ txHash: string;
445
+ txIndex: number;
446
+ amount?: Asset[];
447
+ address?: string;
448
+ };
449
+ type TxIn = PubKeyTxIn | SimpleScriptTxIn | ScriptTxIn;
450
+ type PubKeyTxIn = {
451
+ type: "PubKey";
452
+ txIn: TxInParameter;
453
+ };
454
+ type SimpleScriptTxIn = {
455
+ type: "SimpleScript";
456
+ txIn: TxInParameter;
457
+ simpleScriptTxIn: SimpleScriptTxInParameter;
458
+ };
459
+ type SimpleScriptTxInParameter = {
460
+ scriptSource?: {
461
+ type: "Provided";
462
+ script: string;
463
+ } | {
464
+ type: "Inline";
465
+ txInInfo: SimpleScriptSourceInfo;
478
466
  };
479
467
  };
480
- declare const certificateToObj: (certificate: Certificate) => object;
468
+ type ScriptTxInParameter = {
469
+ scriptSource?: ScriptSource;
470
+ datumSource?: DatumSource;
471
+ redeemer?: Redeemer;
472
+ };
473
+ type ScriptTxIn = {
474
+ type: "Script";
475
+ txIn: TxInParameter;
476
+ scriptTxIn: ScriptTxInParameter;
477
+ };
478
+
479
+ type Withdrawal = PubKeyWithdrawal | ScriptWithdrawal | SimpleScriptWithdrawal;
480
+ type PubKeyWithdrawal = {
481
+ type: "PubKeyWithdrawal";
482
+ address: string;
483
+ coin: string;
484
+ };
485
+ type ScriptWithdrawal = {
486
+ type: "ScriptWithdrawal";
487
+ address: string;
488
+ coin: string;
489
+ scriptSource?: ScriptSource;
490
+ redeemer?: Redeemer;
491
+ };
492
+ type SimpleScriptWithdrawal = {
493
+ type: "SimpleScriptWithdrawal";
494
+ address: string;
495
+ coin: string;
496
+ scriptSource?: SimpleScriptSourceInfo;
497
+ };
481
498
 
482
499
  type MeshTxBuilderBody = {
483
500
  inputs: TxIn[];
@@ -641,6 +658,7 @@ interface IMeshTxSerializer {
641
658
  serializeData(data: BuilderData): string;
642
659
  serializeAddress(address: DeserializedAddress, networkId?: 0 | 1): string;
643
660
  serializePoolId(hash: string): string;
661
+ serializeRewardAddress(stakeKeyHash: string, isScriptHash?: boolean, network_id?: 0 | 1): string;
644
662
  }
645
663
  interface IResolver {
646
664
  keys: {
@@ -803,7 +821,7 @@ declare const mMaybeStakingHash: (stakeCredential: string, isScriptCredential?:
803
821
  * @param isScriptCredential The flag to indicate if the credential is a script credential
804
822
  * @returns The Mesh Data public key address object
805
823
  */
806
- declare const mPubKeyAddress: (bytes: string, stakeCredential?: string) => Data;
824
+ declare const mPubKeyAddress: (bytes: string, stakeCredential?: string, isScriptCredential?: boolean) => Data;
807
825
  /**
808
826
  * The utility function to create a Mesh Data script address
809
827
  * @param bytes The validator hash in hex
@@ -811,7 +829,7 @@ declare const mPubKeyAddress: (bytes: string, stakeCredential?: string) => Data;
811
829
  * @param isScriptCredential The flag to indicate if the credential is a script credential
812
830
  * @returns The Mesh Data script address object
813
831
  */
814
- declare const mScriptAddress: (bytes: string, stakeCredential?: string) => Data;
832
+ declare const mScriptAddress: (bytes: string, stakeCredential?: string, isScriptCredential?: boolean) => Data;
815
833
 
816
834
  /**
817
835
  * The Mesh Data boolean
@@ -1231,8 +1249,26 @@ type SlotConfig = {
1231
1249
  };
1232
1250
  declare const SLOT_CONFIG_NETWORK: Record<Network, SlotConfig>;
1233
1251
  declare const slotToBeginUnixTime: (slot: number, slotConfig: SlotConfig) => number;
1252
+ /**
1253
+ * Eqivalent to `slotToBeginUnixTime` but option to provide optional config
1254
+ * @param unixTime Timestamp in milliseconds
1255
+ * @param slotConfig Slot configuration for calculation
1256
+ * @returns Slot number
1257
+ */
1234
1258
  declare const unixTimeToEnclosingSlot: (unixTime: number, slotConfig: SlotConfig) => number;
1259
+ /**
1260
+ * Resolve slot number based on timestamp in milliseconds.
1261
+ * @param network Network: mainnet | preprod | preview.
1262
+ * @param milliseconds Timestamp in milliseconds
1263
+ * @returns Slot number
1264
+ */
1235
1265
  declare const resolveSlotNo: (network: Network, milliseconds?: number) => string;
1266
+ /**
1267
+ * Resolve epoch number based on timestamp in milliseconds.
1268
+ * @param network Network: mainnet | preprod | preview.
1269
+ * @param milliseconds Timestamp in milliseconds
1270
+ * @returns Epoch number
1271
+ */
1236
1272
  declare const resolveEpochNo: (network: Network, milliseconds?: number) => number;
1237
1273
 
1238
1274
  /**
@@ -1372,6 +1408,9 @@ declare class MeshValue {
1372
1408
  toJSON: () => Value;
1373
1409
  }
1374
1410
 
1411
+ declare const AssetFingerprint: typeof CIP14;
1412
+ declare const resolveFingerprint: (policyId: string, assetName: string) => any;
1413
+
1375
1414
  declare class BigNum {
1376
1415
  value: bigint;
1377
1416
  constructor(value?: bigint | number | string);
@@ -1386,7 +1425,4 @@ declare class BigNum {
1386
1425
  toString(): string;
1387
1426
  }
1388
1427
 
1389
- declare const AssetFingerprint: typeof CIP14;
1390
- declare const resolveFingerprint: (policyId: string, assetName: string) => any;
1391
-
1392
- export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type ConStr, type ConStr0, type ConStr1, type ConStr2, type CurrencySymbol, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type FungibleAssetMetadata, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IInitiator, type IListener, type IMeshTxSerializer, type IResolver, type ISigner, type ISubmitter, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MMaybeStakingHash, type MOutputReference, type MPubKeyAddress, type MScriptAddress, type MTuple, type MTxOutRef, type MValue, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type PlutusData, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, 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 SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SlotConfig, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, certificateToObj, conStr, conStr0, conStr1, conStr2, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, hashByteString, hexToBytes, hexToString, integer, isNetwork, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mMaybeStakingHash, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScriptAddress, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, outputReference, parseAssetUnit, plutusBSArrayToString, policyId, poolMetadataToObj, poolParamsToObj, posixTime, pubKeyAddress, pubKeyHash, relayToObj, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, scriptAddress, scriptHash, slotToBeginUnixTime, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value };
1428
+ export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, 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 CurrencySymbol, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type FungibleAssetMetadata, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IInitiator, type IListener, type IMeshTxSerializer, type IResolver, type ISigner, type ISubmitter, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MMaybeStakingHash, type MOutputReference, type MPubKeyAddress, type MScriptAddress, type MTuple, type MTxOutRef, type MValue, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type PlutusData, 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 ScriptWithdrawal, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SimpleScriptWithdrawal, type SlotConfig, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, castProtocol, conStr, conStr0, conStr1, conStr2, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, hashByteString, hexToBytes, hexToString, integer, isNetwork, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mMaybeStakingHash, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScriptAddress, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, outputReference, parseAssetUnit, plutusBSArrayToString, policyId, posixTime, pubKeyAddress, pubKeyHash, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, scriptAddress, scriptHash, slotToBeginUnixTime, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value };