@lucid-evolution/utils 0.0.1

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.
@@ -0,0 +1,78 @@
1
+ import { Native, Script, Network, Credential, RewardAddress, CertificateValidator, WithdrawalValidator, AddressDetails, CostModels, ProtocolParameters, Address, ScriptHash, KeyHash, Datum, DatumHash, PrivateKey, PublicKey, SpendingValidator, Validator, MintingPolicy, PolicyId, NativeScript, UnixTime, Slot, UTxO, OutRef, TxOutput, Assets, Unit } from '@lucid-evolution/core-types';
2
+ import * as CML from '@dcspark/cardano-multiplatform-lib-nodejs';
3
+ export { applyDoubleCborEncoding } from 'lucid-cardano';
4
+
5
+ declare const toNativeScript: (native: Native) => CML.NativeScript;
6
+ declare const nativeJSFromJson: (native: Native) => Script;
7
+
8
+ declare function addressFromHexOrBech32(address: string): CML.Address;
9
+ declare function credentialToRewardAddress(network: Network, stakeCredential: Credential): RewardAddress;
10
+ declare function validatorToRewardAddress(network: Network, validator: CertificateValidator | WithdrawalValidator): RewardAddress;
11
+ /** Address can be in Bech32 or Hex. */
12
+ declare function getAddressDetails(address: string): AddressDetails;
13
+
14
+ declare function createCostModels(costModels: CostModels): CML.CostModels;
15
+ declare const PROTOCOL_PARAMETERS_DEFAULT: ProtocolParameters;
16
+
17
+ declare function credentialToAddress(network: Network, paymentCredential: Credential, stakeCredential?: Credential): Address;
18
+ declare function scriptHashToCredential(scriptHash: ScriptHash): Credential;
19
+ declare function keyHashToCredential(keyHash: KeyHash): Credential;
20
+ declare function paymentCredentialOf(address: Address): Credential;
21
+ declare function stakeCredentialOf(rewardAddress: RewardAddress): Credential;
22
+
23
+ declare function datumToHash(datum: Datum): DatumHash;
24
+
25
+ declare function generatePrivateKey(): PrivateKey;
26
+ declare function generateSeedPhrase(): string;
27
+ declare function toPublicKey(privateKey: PrivateKey): PublicKey;
28
+
29
+ declare function toLabel(num: number): string;
30
+ declare function fromLabel(label: string): number | null;
31
+
32
+ declare function networkToId(network: Network): number;
33
+
34
+ declare function validatorToAddress(network: Network, validator: SpendingValidator, stakeCredential?: Credential): Address;
35
+ declare function validatorToScriptHash(validator: Validator): ScriptHash;
36
+ declare function toScriptRef(script: Script): CML.Script;
37
+ declare function fromScriptRef(scriptRef: CML.Script): Script;
38
+ declare function mintingPolicyToId(mintingPolicy: MintingPolicy): PolicyId;
39
+ declare function nativeFromJson(nativeScript: Native): Script;
40
+ /**
41
+ * Convert a native script from Json to the Hex representation.
42
+ * It follows this Json format: https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/simple-scripts.md
43
+ */
44
+ declare function nativeScriptFromJson(nativeScript: NativeScript): Script;
45
+
46
+ declare function unixTimeToSlot(network: Network, unixTime: UnixTime): Slot;
47
+ declare function slotToUnixTime(network: Network, slot: Slot): UnixTime;
48
+
49
+ declare const utxoToTransactionOutput: (utxo: UTxO) => CML.TransactionOutput;
50
+ declare const utxoToTransactionInput: (utxo: UTxO) => CML.TransactionInput;
51
+ declare function utxoToCore(utxo: UTxO): CML.TransactionUnspentOutput;
52
+ declare function utxosToCores(utxos: UTxO[]): CML.TransactionUnspentOutput[];
53
+ declare function coreToUtxo(coreUtxo: CML.TransactionUnspentOutput): UTxO;
54
+ declare function coresToUtxos(utxos: Array<CML.TransactionUnspentOutput>): UTxO[];
55
+ declare function coreToOutRef(input: CML.TransactionInput): OutRef;
56
+ declare function coresToOutRefs(inputs: Array<CML.TransactionInput>): OutRef[];
57
+ declare function coreToTxOutput(output: CML.TransactionOutput): TxOutput;
58
+ declare function coresToTxOutputs(outputs: Array<CML.TransactionOutput>): TxOutput[];
59
+
60
+ declare function valueToAssets(value: CML.Value): Assets;
61
+ declare function assetsToValue(assets: Assets): CML.Value;
62
+ /**
63
+ * Splits unit into policy id, asset name (entire asset name), name (asset name without label) and label if applicable.
64
+ * name will be returned in Hex.
65
+ */
66
+ declare function fromUnit(unit: Unit): {
67
+ policyId: PolicyId;
68
+ assetName: string | null;
69
+ name: string | null;
70
+ label: number | null;
71
+ };
72
+ /**
73
+ * @param name Hex encoded
74
+ */
75
+ declare function toUnit(policyId: PolicyId, name?: string | null, label?: number | null): Unit;
76
+ declare function addAssets(...assets: Assets[]): Assets;
77
+
78
+ export { PROTOCOL_PARAMETERS_DEFAULT, addAssets, addressFromHexOrBech32, assetsToValue, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumToHash, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, keyHashToCredential, mintingPolicyToId, nativeFromJson, nativeJSFromJson, nativeScriptFromJson, networkToId, paymentCredentialOf, scriptHashToCredential, slotToUnixTime, stakeCredentialOf, toLabel, toNativeScript, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
@@ -0,0 +1,78 @@
1
+ import { Native, Script, Network, Credential, RewardAddress, CertificateValidator, WithdrawalValidator, AddressDetails, CostModels, ProtocolParameters, Address, ScriptHash, KeyHash, Datum, DatumHash, PrivateKey, PublicKey, SpendingValidator, Validator, MintingPolicy, PolicyId, NativeScript, UnixTime, Slot, UTxO, OutRef, TxOutput, Assets, Unit } from '@lucid-evolution/core-types';
2
+ import * as CML from '@dcspark/cardano-multiplatform-lib-nodejs';
3
+ export { applyDoubleCborEncoding } from 'lucid-cardano';
4
+
5
+ declare const toNativeScript: (native: Native) => CML.NativeScript;
6
+ declare const nativeJSFromJson: (native: Native) => Script;
7
+
8
+ declare function addressFromHexOrBech32(address: string): CML.Address;
9
+ declare function credentialToRewardAddress(network: Network, stakeCredential: Credential): RewardAddress;
10
+ declare function validatorToRewardAddress(network: Network, validator: CertificateValidator | WithdrawalValidator): RewardAddress;
11
+ /** Address can be in Bech32 or Hex. */
12
+ declare function getAddressDetails(address: string): AddressDetails;
13
+
14
+ declare function createCostModels(costModels: CostModels): CML.CostModels;
15
+ declare const PROTOCOL_PARAMETERS_DEFAULT: ProtocolParameters;
16
+
17
+ declare function credentialToAddress(network: Network, paymentCredential: Credential, stakeCredential?: Credential): Address;
18
+ declare function scriptHashToCredential(scriptHash: ScriptHash): Credential;
19
+ declare function keyHashToCredential(keyHash: KeyHash): Credential;
20
+ declare function paymentCredentialOf(address: Address): Credential;
21
+ declare function stakeCredentialOf(rewardAddress: RewardAddress): Credential;
22
+
23
+ declare function datumToHash(datum: Datum): DatumHash;
24
+
25
+ declare function generatePrivateKey(): PrivateKey;
26
+ declare function generateSeedPhrase(): string;
27
+ declare function toPublicKey(privateKey: PrivateKey): PublicKey;
28
+
29
+ declare function toLabel(num: number): string;
30
+ declare function fromLabel(label: string): number | null;
31
+
32
+ declare function networkToId(network: Network): number;
33
+
34
+ declare function validatorToAddress(network: Network, validator: SpendingValidator, stakeCredential?: Credential): Address;
35
+ declare function validatorToScriptHash(validator: Validator): ScriptHash;
36
+ declare function toScriptRef(script: Script): CML.Script;
37
+ declare function fromScriptRef(scriptRef: CML.Script): Script;
38
+ declare function mintingPolicyToId(mintingPolicy: MintingPolicy): PolicyId;
39
+ declare function nativeFromJson(nativeScript: Native): Script;
40
+ /**
41
+ * Convert a native script from Json to the Hex representation.
42
+ * It follows this Json format: https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/simple-scripts.md
43
+ */
44
+ declare function nativeScriptFromJson(nativeScript: NativeScript): Script;
45
+
46
+ declare function unixTimeToSlot(network: Network, unixTime: UnixTime): Slot;
47
+ declare function slotToUnixTime(network: Network, slot: Slot): UnixTime;
48
+
49
+ declare const utxoToTransactionOutput: (utxo: UTxO) => CML.TransactionOutput;
50
+ declare const utxoToTransactionInput: (utxo: UTxO) => CML.TransactionInput;
51
+ declare function utxoToCore(utxo: UTxO): CML.TransactionUnspentOutput;
52
+ declare function utxosToCores(utxos: UTxO[]): CML.TransactionUnspentOutput[];
53
+ declare function coreToUtxo(coreUtxo: CML.TransactionUnspentOutput): UTxO;
54
+ declare function coresToUtxos(utxos: Array<CML.TransactionUnspentOutput>): UTxO[];
55
+ declare function coreToOutRef(input: CML.TransactionInput): OutRef;
56
+ declare function coresToOutRefs(inputs: Array<CML.TransactionInput>): OutRef[];
57
+ declare function coreToTxOutput(output: CML.TransactionOutput): TxOutput;
58
+ declare function coresToTxOutputs(outputs: Array<CML.TransactionOutput>): TxOutput[];
59
+
60
+ declare function valueToAssets(value: CML.Value): Assets;
61
+ declare function assetsToValue(assets: Assets): CML.Value;
62
+ /**
63
+ * Splits unit into policy id, asset name (entire asset name), name (asset name without label) and label if applicable.
64
+ * name will be returned in Hex.
65
+ */
66
+ declare function fromUnit(unit: Unit): {
67
+ policyId: PolicyId;
68
+ assetName: string | null;
69
+ name: string | null;
70
+ label: number | null;
71
+ };
72
+ /**
73
+ * @param name Hex encoded
74
+ */
75
+ declare function toUnit(policyId: PolicyId, name?: string | null, label?: number | null): Unit;
76
+ declare function addAssets(...assets: Assets[]): Assets;
77
+
78
+ export { PROTOCOL_PARAMETERS_DEFAULT, addAssets, addressFromHexOrBech32, assetsToValue, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumToHash, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, keyHashToCredential, mintingPolicyToId, nativeFromJson, nativeJSFromJson, nativeScriptFromJson, networkToId, paymentCredentialOf, scriptHashToCredential, slotToUnixTime, stakeCredentialOf, toLabel, toNativeScript, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };