@lucid-evolution/utils 0.1.63 → 0.1.65
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 +17 -3
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -0
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
33
|
CBOREncodingLevel: () => CBOREncodingLevel,
|
|
34
34
|
PROTOCOL_PARAMETERS_DEFAULT: () => PROTOCOL_PARAMETERS_DEFAULT,
|
|
35
35
|
addAssets: () => addAssets,
|
|
@@ -50,6 +50,7 @@ __export(src_exports, {
|
|
|
50
50
|
credentialToRewardAddress: () => credentialToRewardAddress,
|
|
51
51
|
datumJsonToCbor: () => datumJsonToCbor,
|
|
52
52
|
datumToHash: () => datumToHash,
|
|
53
|
+
drepIDToCredential: () => drepIDToCredential,
|
|
53
54
|
fromCMLRedeemerTag: () => fromCMLRedeemerTag,
|
|
54
55
|
fromLabel: () => fromLabel,
|
|
55
56
|
fromScriptRef: () => fromScriptRef,
|
|
@@ -90,7 +91,7 @@ __export(src_exports, {
|
|
|
90
91
|
validatorToScriptHash: () => validatorToScriptHash,
|
|
91
92
|
valueToAssets: () => valueToAssets
|
|
92
93
|
});
|
|
93
|
-
module.exports = __toCommonJS(
|
|
94
|
+
module.exports = __toCommonJS(index_exports);
|
|
94
95
|
|
|
95
96
|
// src/native.ts
|
|
96
97
|
var S = __toESM(require("@effect/schema/Schema"), 1);
|
|
@@ -1238,6 +1239,7 @@ var PROTOCOL_PARAMETERS_DEFAULT = {
|
|
|
1238
1239
|
};
|
|
1239
1240
|
|
|
1240
1241
|
// src/credential.ts
|
|
1242
|
+
var import_core7 = require("@cardano-sdk/core");
|
|
1241
1243
|
function credentialToAddress(network, paymentCredential, stakeCredential) {
|
|
1242
1244
|
if (stakeCredential) {
|
|
1243
1245
|
return CML.BaseAddress.new(
|
|
@@ -1294,6 +1296,17 @@ function stakeCredentialOf(rewardAddress) {
|
|
|
1294
1296
|
}
|
|
1295
1297
|
return stakeCredential;
|
|
1296
1298
|
}
|
|
1299
|
+
var drepIDToCredential = (drepID) => {
|
|
1300
|
+
if (!import_core7.Cardano.DRepID.isValid(drepID)) {
|
|
1301
|
+
throw new Error(`Invalid DRep ID: ${drepID}`);
|
|
1302
|
+
}
|
|
1303
|
+
const drepId = import_core7.Cardano.DRepID(drepID);
|
|
1304
|
+
const drepCred = import_core7.Cardano.DRepID.toCredential(drepId);
|
|
1305
|
+
return {
|
|
1306
|
+
type: drepCred.type == import_core7.Cardano.CredentialType.KeyHash ? "Key" : "Script",
|
|
1307
|
+
hash: drepCred.hash
|
|
1308
|
+
};
|
|
1309
|
+
};
|
|
1297
1310
|
|
|
1298
1311
|
// src/datum.ts
|
|
1299
1312
|
function datumToHash(datum) {
|
|
@@ -1683,6 +1696,7 @@ var fromCMLRedeemerTag = (tag) => {
|
|
|
1683
1696
|
credentialToRewardAddress,
|
|
1684
1697
|
datumJsonToCbor,
|
|
1685
1698
|
datumToHash,
|
|
1699
|
+
drepIDToCredential,
|
|
1686
1700
|
fromCMLRedeemerTag,
|
|
1687
1701
|
fromLabel,
|
|
1688
1702
|
fromScriptRef,
|
package/dist/index.d.cts
CHANGED
|
@@ -78,6 +78,7 @@ declare function scriptHashToCredential(scriptHash: ScriptHash): Credential;
|
|
|
78
78
|
declare function keyHashToCredential(keyHash: KeyHash): Credential;
|
|
79
79
|
declare function paymentCredentialOf(address: Address): Credential;
|
|
80
80
|
declare function stakeCredentialOf(rewardAddress: RewardAddress): Credential;
|
|
81
|
+
declare const drepIDToCredential: (drepID: string) => Credential;
|
|
81
82
|
|
|
82
83
|
declare function datumToHash(datum: Datum): DatumHash;
|
|
83
84
|
|
|
@@ -204,4 +205,4 @@ declare const stringify: (data: any) => string;
|
|
|
204
205
|
declare const toCMLRedeemerTag: (tag: string) => CML.RedeemerTag;
|
|
205
206
|
declare const fromCMLRedeemerTag: (tag: CML.RedeemerTag) => RedeemerTag;
|
|
206
207
|
|
|
207
|
-
export { CBOREncodingLevel, type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, applySingleCborEncoding, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
|
208
|
+
export { CBOREncodingLevel, type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, applySingleCborEncoding, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, drepIDToCredential, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ declare function scriptHashToCredential(scriptHash: ScriptHash): Credential;
|
|
|
78
78
|
declare function keyHashToCredential(keyHash: KeyHash): Credential;
|
|
79
79
|
declare function paymentCredentialOf(address: Address): Credential;
|
|
80
80
|
declare function stakeCredentialOf(rewardAddress: RewardAddress): Credential;
|
|
81
|
+
declare const drepIDToCredential: (drepID: string) => Credential;
|
|
81
82
|
|
|
82
83
|
declare function datumToHash(datum: Datum): DatumHash;
|
|
83
84
|
|
|
@@ -204,4 +205,4 @@ declare const stringify: (data: any) => string;
|
|
|
204
205
|
declare const toCMLRedeemerTag: (tag: string) => CML.RedeemerTag;
|
|
205
206
|
declare const fromCMLRedeemerTag: (tag: CML.RedeemerTag) => RedeemerTag;
|
|
206
207
|
|
|
207
|
-
export { CBOREncodingLevel, type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, applySingleCborEncoding, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
|
208
|
+
export { CBOREncodingLevel, type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, applySingleCborEncoding, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, drepIDToCredential, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
|
package/dist/index.js
CHANGED
|
@@ -1150,6 +1150,7 @@ var PROTOCOL_PARAMETERS_DEFAULT = {
|
|
|
1150
1150
|
};
|
|
1151
1151
|
|
|
1152
1152
|
// src/credential.ts
|
|
1153
|
+
import { Cardano } from "@cardano-sdk/core";
|
|
1153
1154
|
function credentialToAddress(network, paymentCredential, stakeCredential) {
|
|
1154
1155
|
if (stakeCredential) {
|
|
1155
1156
|
return CML.BaseAddress.new(
|
|
@@ -1206,6 +1207,17 @@ function stakeCredentialOf(rewardAddress) {
|
|
|
1206
1207
|
}
|
|
1207
1208
|
return stakeCredential;
|
|
1208
1209
|
}
|
|
1210
|
+
var drepIDToCredential = (drepID) => {
|
|
1211
|
+
if (!Cardano.DRepID.isValid(drepID)) {
|
|
1212
|
+
throw new Error(`Invalid DRep ID: ${drepID}`);
|
|
1213
|
+
}
|
|
1214
|
+
const drepId = Cardano.DRepID(drepID);
|
|
1215
|
+
const drepCred = Cardano.DRepID.toCredential(drepId);
|
|
1216
|
+
return {
|
|
1217
|
+
type: drepCred.type == Cardano.CredentialType.KeyHash ? "Key" : "Script",
|
|
1218
|
+
hash: drepCred.hash
|
|
1219
|
+
};
|
|
1220
|
+
};
|
|
1209
1221
|
|
|
1210
1222
|
// src/datum.ts
|
|
1211
1223
|
function datumToHash(datum) {
|
|
@@ -1598,6 +1610,7 @@ export {
|
|
|
1598
1610
|
credentialToRewardAddress,
|
|
1599
1611
|
datumJsonToCbor,
|
|
1600
1612
|
datumToHash,
|
|
1613
|
+
drepIDToCredential,
|
|
1601
1614
|
fromCMLRedeemerTag,
|
|
1602
1615
|
fromLabel,
|
|
1603
1616
|
fromScriptRef,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucid-evolution/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.65",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,17 +28,18 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@anastasia-labs/cardano-multiplatform-lib-browser": "6.0.2-3",
|
|
30
30
|
"@anastasia-labs/cardano-multiplatform-lib-nodejs": "6.0.2-3",
|
|
31
|
+
"@cardano-sdk/core": "^0.45.1",
|
|
31
32
|
"@effect/schema": "^0.68.16",
|
|
32
33
|
"@harmoniclabs/plutus-data": "^1.2.4",
|
|
33
34
|
"@harmoniclabs/uplc": "^1.2.4",
|
|
34
35
|
"bip39": "^3.1.0",
|
|
35
36
|
"cbor-x": "^1.6.0",
|
|
36
37
|
"effect": "^3.10.4",
|
|
37
|
-
"@lucid-evolution/core-types": "0.1.21",
|
|
38
38
|
"@lucid-evolution/core-utils": "0.1.16",
|
|
39
|
+
"@lucid-evolution/core-types": "0.1.22",
|
|
39
40
|
"@lucid-evolution/crc8": "0.1.8",
|
|
40
|
-
"@lucid-evolution/plutus": "0.1.
|
|
41
|
-
"@lucid-evolution/uplc": "0.2.
|
|
41
|
+
"@lucid-evolution/plutus": "0.1.29",
|
|
42
|
+
"@lucid-evolution/uplc": "0.2.19"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/node": "^20.12.8",
|