@meshsdk/core-cst 1.5.28
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/README.md +5 -0
- package/dist/index.d.mts +303 -0
- package/dist/index.d.ts +303 -0
- package/dist/index.js +1481 -0
- package/dist/index.mjs +1324 -0
- package/package.json +44 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1324 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { Cardano as Cardano4, Serialization as Serialization5 } from "@cardano-sdk/core";
|
|
3
|
+
|
|
4
|
+
// src/stricahq/index.ts
|
|
5
|
+
import {
|
|
6
|
+
Bip32PrivateKey,
|
|
7
|
+
Bip32PublicKey,
|
|
8
|
+
PublicKey,
|
|
9
|
+
PrivateKey as StricahqPrivateKey
|
|
10
|
+
} from "@stricahq/bip32ed25519";
|
|
11
|
+
import hash from "hash.js";
|
|
12
|
+
var PrivateKey = class extends StricahqPrivateKey {
|
|
13
|
+
constructor(privKey, extended = true) {
|
|
14
|
+
if (!extended) {
|
|
15
|
+
let extendedSecret = hash.sha512().update(privKey).digest();
|
|
16
|
+
if (extendedSecret[0] && extendedSecret[31]) {
|
|
17
|
+
extendedSecret[0] &= 248;
|
|
18
|
+
extendedSecret[31] &= 63;
|
|
19
|
+
extendedSecret[31] |= 64;
|
|
20
|
+
}
|
|
21
|
+
privKey = Buffer.from(extendedSecret);
|
|
22
|
+
}
|
|
23
|
+
super(privKey);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/types/cardano-sdk.ts
|
|
28
|
+
import { Cardano, Serialization } from "@cardano-sdk/core";
|
|
29
|
+
import * as Crypto from "@cardano-sdk/crypto";
|
|
30
|
+
import { typedHex } from "@cardano-sdk/util";
|
|
31
|
+
var Slot = Cardano.Slot;
|
|
32
|
+
var Value = Serialization.Value;
|
|
33
|
+
var Transaction = Serialization.Transaction;
|
|
34
|
+
var TransactionId = Cardano.TransactionId;
|
|
35
|
+
var TransactionBody = Serialization.TransactionBody;
|
|
36
|
+
var TransactionWitnessSet = Serialization.TransactionWitnessSet;
|
|
37
|
+
var TransactionUnspentOutput = Serialization.TransactionUnspentOutput;
|
|
38
|
+
var TransactionInput = Serialization.TransactionInput;
|
|
39
|
+
var TransactionOutput = Serialization.TransactionOutput;
|
|
40
|
+
var PlutusData = Serialization.PlutusData;
|
|
41
|
+
var PlutusList = Serialization.PlutusList;
|
|
42
|
+
var PlutusMap = Serialization.PlutusMap;
|
|
43
|
+
var Redeemers = Serialization.Redeemers;
|
|
44
|
+
var Redeemer = Serialization.Redeemer;
|
|
45
|
+
var RedeemerPurpose = Cardano.RedeemerPurpose;
|
|
46
|
+
var RedeemerTag = Serialization.RedeemerTag;
|
|
47
|
+
var Script = Serialization.Script;
|
|
48
|
+
var PolicyId = Cardano.PolicyId;
|
|
49
|
+
var AssetName = Cardano.AssetName;
|
|
50
|
+
var AssetId = Cardano.AssetId;
|
|
51
|
+
var ScriptHash = Crypto.Hash28ByteBase16;
|
|
52
|
+
var Address = Cardano.Address;
|
|
53
|
+
var RewardAddress = Cardano.RewardAddress;
|
|
54
|
+
var AddressType = Cardano.AddressType;
|
|
55
|
+
var BaseAddress = Cardano.BaseAddress;
|
|
56
|
+
var EnterpriseAddress = Cardano.EnterpriseAddress;
|
|
57
|
+
var PaymentAddress = Cardano.PaymentAddress;
|
|
58
|
+
var AssetFingerprint = Cardano.AssetFingerprint;
|
|
59
|
+
var Credential = Serialization.Credential;
|
|
60
|
+
var Ed25519PublicKeyHex2 = Crypto.Ed25519PublicKeyHex;
|
|
61
|
+
var Ed25519PrivateNormalKeyHex = (value) => typedHex(value, 64);
|
|
62
|
+
var Ed25519PrivateExtendedKeyHex = (value) => typedHex(value, 128);
|
|
63
|
+
var Ed25519KeyHash2 = Crypto.Ed25519KeyHash;
|
|
64
|
+
var Ed25519KeyHashHex2 = Crypto.Ed25519KeyHashHex;
|
|
65
|
+
var Hash28ByteBase162 = Crypto.Hash28ByteBase16;
|
|
66
|
+
var Hash32ByteBase162 = Crypto.Hash32ByteBase16;
|
|
67
|
+
var CredentialType = Cardano.CredentialType;
|
|
68
|
+
var Certificate = Serialization.Certificate;
|
|
69
|
+
var PoolId = Cardano.PoolId;
|
|
70
|
+
var StakeRegistration = Serialization.StakeRegistration;
|
|
71
|
+
var StakeDelegation = Serialization.StakeDelegation;
|
|
72
|
+
var CertificateType = Cardano.CertificateType;
|
|
73
|
+
var VkeyWitness = Serialization.VkeyWitness;
|
|
74
|
+
var Ed25519SignatureHex2 = Crypto.Ed25519SignatureHex;
|
|
75
|
+
var Ed25519PublicKey2 = Crypto.Ed25519PublicKey;
|
|
76
|
+
var Ed25519Signature2 = Crypto.Ed25519Signature;
|
|
77
|
+
var Bip32PrivateKey3 = Crypto.Bip32PrivateKey;
|
|
78
|
+
var Bip32PrivateKeyHex2 = Crypto.Bip32PrivateKeyHex;
|
|
79
|
+
var PlutusLanguageVersion = Cardano.PlutusLanguageVersion;
|
|
80
|
+
var NativeScript = Serialization.NativeScript;
|
|
81
|
+
var PlutusV1Script = Serialization.PlutusV1Script;
|
|
82
|
+
var PlutusV2Script = Serialization.PlutusV2Script;
|
|
83
|
+
var PlutusV3Script = Serialization.PlutusV3Script;
|
|
84
|
+
var Costmdls = Serialization.Costmdls;
|
|
85
|
+
var CostModel = Serialization.CostModel;
|
|
86
|
+
var CborWriter = Serialization.CborWriter;
|
|
87
|
+
var ConstrPlutusData = Serialization.ConstrPlutusData;
|
|
88
|
+
var RewardAccount = Cardano.RewardAccount;
|
|
89
|
+
var Hash = Serialization.Hash;
|
|
90
|
+
var DatumHash = Crypto.Hash32ByteBase16;
|
|
91
|
+
var Datum = Serialization.Datum;
|
|
92
|
+
var ExUnits = Serialization.ExUnits;
|
|
93
|
+
var NetworkId = Cardano.NetworkId;
|
|
94
|
+
var DatumKind = Serialization.DatumKind;
|
|
95
|
+
var CborSet = Serialization.CborSet;
|
|
96
|
+
var RequireAllOf = Cardano.NativeScriptKind.RequireAllOf;
|
|
97
|
+
var RequireAnyOf = Cardano.NativeScriptKind.RequireAnyOf;
|
|
98
|
+
var RequireNOf = Cardano.NativeScriptKind.RequireNOf;
|
|
99
|
+
var RequireSignature = Cardano.NativeScriptKind.RequireSignature;
|
|
100
|
+
var RequireTimeAfter = Cardano.NativeScriptKind.RequireTimeAfter;
|
|
101
|
+
var RequireTimeBefore = Cardano.NativeScriptKind.RequireTimeBefore;
|
|
102
|
+
var VrfVkBech32 = Cardano.VrfVkBech32;
|
|
103
|
+
var ScriptPubkey = Serialization.ScriptPubkey;
|
|
104
|
+
|
|
105
|
+
// src/cip8/index.ts
|
|
106
|
+
var signData = (data, privateKey) => {
|
|
107
|
+
const payload = Buffer.from(data);
|
|
108
|
+
const signature = privateKey.sign(payload);
|
|
109
|
+
return {
|
|
110
|
+
key: privateKey.toPublicKey().toBytes().toString("hex"),
|
|
111
|
+
signature: signature.toString("hex")
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
var checkSignature = (data, { key, signature }) => {
|
|
115
|
+
const publicKey = new PublicKey(Buffer.from(key, "hex"));
|
|
116
|
+
return publicKey.verify(Buffer.from(signature, "hex"), Buffer.from(data));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/resolvers/index.ts
|
|
120
|
+
import { Cardano as Cardano2 } from "@cardano-sdk/core";
|
|
121
|
+
import { blake2b } from "@cardano-sdk/crypto";
|
|
122
|
+
import { HexBlob as HexBlob3 } from "@cardano-sdk/util";
|
|
123
|
+
|
|
124
|
+
// src/utils/builder.ts
|
|
125
|
+
import { pbkdf2Sync } from "pbkdf2";
|
|
126
|
+
import { HARDENED_KEY_START } from "@meshsdk/common";
|
|
127
|
+
var buildBaseAddress = (networkId, paymentKeyHash, stakeKeyHash) => {
|
|
128
|
+
return BaseAddress.fromCredentials(
|
|
129
|
+
networkId,
|
|
130
|
+
{
|
|
131
|
+
hash: paymentKeyHash,
|
|
132
|
+
type: CredentialType.KeyHash
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
hash: stakeKeyHash,
|
|
136
|
+
type: CredentialType.KeyHash
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
var buildEnterpriseAddress = (networkId, paymentKeyHash) => {
|
|
141
|
+
return EnterpriseAddress.fromCredentials(networkId, {
|
|
142
|
+
hash: paymentKeyHash,
|
|
143
|
+
type: CredentialType.KeyHash
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
var buildBip32PrivateKey = (entropy, password = "") => {
|
|
147
|
+
const PBKDF2_ITERATIONS = 4096;
|
|
148
|
+
const PBKDF2_KEY_SIZE = 96;
|
|
149
|
+
const PBKDF2_DIGEST_ALGORITHM = "sha512";
|
|
150
|
+
const clampScalar = (scalar) => {
|
|
151
|
+
if (scalar[0] !== void 0) {
|
|
152
|
+
scalar[0] &= 248;
|
|
153
|
+
}
|
|
154
|
+
if (scalar[31] !== void 0) {
|
|
155
|
+
scalar[31] &= 31;
|
|
156
|
+
scalar[31] |= 64;
|
|
157
|
+
}
|
|
158
|
+
return scalar;
|
|
159
|
+
};
|
|
160
|
+
const _entropy = Buffer.from(entropy, "hex");
|
|
161
|
+
const xprv = pbkdf2Sync(
|
|
162
|
+
password,
|
|
163
|
+
_entropy,
|
|
164
|
+
PBKDF2_ITERATIONS,
|
|
165
|
+
PBKDF2_KEY_SIZE,
|
|
166
|
+
PBKDF2_DIGEST_ALGORITHM
|
|
167
|
+
);
|
|
168
|
+
return Bip32PrivateKey3.fromBytes(clampScalar(xprv));
|
|
169
|
+
};
|
|
170
|
+
var buildRewardAddress = (networkId, stakeKeyHash) => {
|
|
171
|
+
const cred = {
|
|
172
|
+
type: CredentialType.KeyHash,
|
|
173
|
+
hash: stakeKeyHash
|
|
174
|
+
};
|
|
175
|
+
return RewardAddress.fromCredentials(networkId, cred);
|
|
176
|
+
};
|
|
177
|
+
var buildKeys = (entropy, accountIndex, keyIndex = 0) => {
|
|
178
|
+
if (typeof entropy === "string") {
|
|
179
|
+
const rootKey = new Bip32PrivateKey(Buffer.from(entropy, "hex"));
|
|
180
|
+
const accountKey = rootKey.derive(HARDENED_KEY_START + 1852).derive(HARDENED_KEY_START + 1815).derive(HARDENED_KEY_START + accountIndex);
|
|
181
|
+
const paymentKey = accountKey.derive(0).derive(keyIndex).toPrivateKey();
|
|
182
|
+
const stakeKey = accountKey.derive(2).derive(0).toPrivateKey();
|
|
183
|
+
return { paymentKey, stakeKey };
|
|
184
|
+
} else {
|
|
185
|
+
const paymentKey = new PrivateKey(Buffer.from(entropy[0], "hex"), false);
|
|
186
|
+
const stakeKey = new PrivateKey(Buffer.from(entropy[1], "hex"), false);
|
|
187
|
+
return { paymentKey, stakeKey };
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
var buildScriptPubkey = (keyHash) => {
|
|
191
|
+
const scriptPubkey = new ScriptPubkey(Ed25519KeyHashHex2(keyHash.hex()));
|
|
192
|
+
return NativeScript.newScriptPubkey(scriptPubkey);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// src/utils/converter.ts
|
|
196
|
+
import { Serialization as Serialization2 } from "@cardano-sdk/core";
|
|
197
|
+
import { Ed25519KeyHash as Ed25519KeyHash4 } from "@cardano-sdk/crypto";
|
|
198
|
+
import { HexBlob as HexBlob2 } from "@cardano-sdk/util";
|
|
199
|
+
import {
|
|
200
|
+
toBytes as toBytes2
|
|
201
|
+
} from "@meshsdk/common";
|
|
202
|
+
|
|
203
|
+
// src/utils/deserializer.ts
|
|
204
|
+
import { TxCBOR } from "@cardano-sdk/core";
|
|
205
|
+
import { Ed25519KeyHashHex as Ed25519KeyHashHex3 } from "@cardano-sdk/crypto";
|
|
206
|
+
import { HexBlob } from "@cardano-sdk/util";
|
|
207
|
+
import { toBytes } from "@meshsdk/common";
|
|
208
|
+
var deserializeAddress = (address) => {
|
|
209
|
+
const _address = Address.fromString(address);
|
|
210
|
+
if (_address === null) throw new Error("Invalid address");
|
|
211
|
+
return _address;
|
|
212
|
+
};
|
|
213
|
+
var deserializeEd25519KeyHash = (ed25519KeyHash) => Ed25519KeyHash2.fromBytes(toBytes(ed25519KeyHash));
|
|
214
|
+
var deserializeDataHash = (dataHash) => DatumHash.fromHexBlob(HexBlob(dataHash));
|
|
215
|
+
var deserializePlutusData = (plutusData) => PlutusData.fromCbor(HexBlob(plutusData));
|
|
216
|
+
var deserializePlutusScript = (plutusScript, version) => {
|
|
217
|
+
switch (version) {
|
|
218
|
+
case "V1":
|
|
219
|
+
return PlutusV1Script.fromCbor(HexBlob(plutusScript));
|
|
220
|
+
case "V2":
|
|
221
|
+
return PlutusV2Script.fromCbor(HexBlob(plutusScript));
|
|
222
|
+
case "V3":
|
|
223
|
+
return PlutusV3Script.fromCbor(HexBlob(plutusScript));
|
|
224
|
+
default:
|
|
225
|
+
throw new Error("Invalid Plutus script version");
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
var deserializeNativeScript = (nativeScript) => NativeScript.fromCbor(HexBlob(nativeScript));
|
|
229
|
+
var deserializeScriptHash = (scriptHash) => ScriptHash.fromEd25519KeyHashHex(Ed25519KeyHashHex3(scriptHash));
|
|
230
|
+
var deserializeScriptRef = (scriptRef) => Script.fromCbor(HexBlob(scriptRef));
|
|
231
|
+
var deserializeTxUnspentOutput = (txUnspentOutput) => TransactionUnspentOutput.fromCbor(HexBlob(txUnspentOutput));
|
|
232
|
+
var deserializeValue = (value) => Value.fromCbor(HexBlob(value));
|
|
233
|
+
var deserializeTx = (tx) => Transaction.fromCbor(TxCBOR(tx));
|
|
234
|
+
var deserializeTxHash = (txHash) => TransactionId.fromHexBlob(HexBlob(txHash));
|
|
235
|
+
|
|
236
|
+
// src/utils/converter.ts
|
|
237
|
+
var toAddress = (bech32) => Address.fromBech32(bech32);
|
|
238
|
+
var toBaseAddress = (bech32) => {
|
|
239
|
+
return BaseAddress.fromAddress(toAddress(bech32));
|
|
240
|
+
};
|
|
241
|
+
var toEnterpriseAddress = (bech32) => {
|
|
242
|
+
return EnterpriseAddress.fromAddress(toAddress(bech32));
|
|
243
|
+
};
|
|
244
|
+
var toRewardAddress = (bech32) => RewardAddress.fromAddress(toAddress(bech32));
|
|
245
|
+
var fromTxUnspentOutput = (txUnspentOutput) => {
|
|
246
|
+
const dataHash = txUnspentOutput.output().datum() ? txUnspentOutput.output().datum()?.toCbor().toString() : void 0;
|
|
247
|
+
const scriptRef = txUnspentOutput.output().scriptRef() ? txUnspentOutput.output().scriptRef()?.toCbor().toString() : void 0;
|
|
248
|
+
const plutusData = txUnspentOutput.output().datum()?.asInlineData() ? txUnspentOutput.output().datum()?.asInlineData()?.toCbor().toString() : void 0;
|
|
249
|
+
return {
|
|
250
|
+
input: {
|
|
251
|
+
outputIndex: Number(txUnspentOutput.input().index()),
|
|
252
|
+
txHash: txUnspentOutput.input().transactionId()
|
|
253
|
+
},
|
|
254
|
+
output: {
|
|
255
|
+
address: txUnspentOutput.output().address().toBech32(),
|
|
256
|
+
amount: fromValue(txUnspentOutput.output().amount()),
|
|
257
|
+
dataHash,
|
|
258
|
+
// todo not sure if correct
|
|
259
|
+
plutusData,
|
|
260
|
+
// todo not sure if correct
|
|
261
|
+
scriptRef
|
|
262
|
+
// todo not sure if correct
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
var toTxUnspentOutput = (utxo) => {
|
|
267
|
+
const txInput = new TransactionInput(
|
|
268
|
+
deserializeTxHash(utxo.input.txHash),
|
|
269
|
+
BigInt(utxo.input.outputIndex)
|
|
270
|
+
);
|
|
271
|
+
const txOutput = new TransactionOutput(
|
|
272
|
+
toAddress(utxo.output.address),
|
|
273
|
+
toValue(utxo.output.amount)
|
|
274
|
+
);
|
|
275
|
+
if (utxo.output.dataHash !== void 0) {
|
|
276
|
+
txOutput.setDatum(
|
|
277
|
+
Datum.fromCore(deserializeDataHash(utxo.output.dataHash))
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
if (utxo.output.plutusData !== void 0) {
|
|
281
|
+
const plutusData = deserializePlutusData(utxo.output.plutusData);
|
|
282
|
+
const datum = new Serialization2.Datum(void 0, plutusData);
|
|
283
|
+
txOutput.setDatum(datum);
|
|
284
|
+
}
|
|
285
|
+
if (utxo.output.scriptRef !== void 0) {
|
|
286
|
+
txOutput.setScriptRef(deserializeScriptRef(utxo.output.scriptRef));
|
|
287
|
+
}
|
|
288
|
+
return new TransactionUnspentOutput(txInput, txOutput);
|
|
289
|
+
};
|
|
290
|
+
var addressToBech32 = (address) => {
|
|
291
|
+
return address.toBech32();
|
|
292
|
+
};
|
|
293
|
+
var fromValue = (value) => {
|
|
294
|
+
const assets = [
|
|
295
|
+
{ unit: "lovelace", quantity: value.coin().toString() }
|
|
296
|
+
];
|
|
297
|
+
const multiAsset = value.multiasset();
|
|
298
|
+
if (multiAsset !== void 0) {
|
|
299
|
+
const _assets = Array.from(multiAsset.keys());
|
|
300
|
+
for (let i = 0; i < _assets.length; i += 1) {
|
|
301
|
+
const assetId = _assets[i];
|
|
302
|
+
if (assetId !== void 0) {
|
|
303
|
+
const assetQuantity = multiAsset.get(assetId);
|
|
304
|
+
if (assetQuantity !== void 0) {
|
|
305
|
+
assets.push({
|
|
306
|
+
unit: assetId,
|
|
307
|
+
quantity: assetQuantity.toString()
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return assets;
|
|
314
|
+
};
|
|
315
|
+
var toScriptRef = (script) => {
|
|
316
|
+
if ("code" in script) {
|
|
317
|
+
const plutusScript = deserializePlutusScript(script.code, script.version);
|
|
318
|
+
if (plutusScript instanceof PlutusV1Script)
|
|
319
|
+
return Script.newPlutusV1Script(plutusScript);
|
|
320
|
+
if (plutusScript instanceof PlutusV2Script)
|
|
321
|
+
return Script.newPlutusV2Script(plutusScript);
|
|
322
|
+
if (plutusScript instanceof PlutusV3Script)
|
|
323
|
+
return Script.newPlutusV3Script(plutusScript);
|
|
324
|
+
}
|
|
325
|
+
return Script.newNativeScript(toNativeScript(script));
|
|
326
|
+
};
|
|
327
|
+
var fromScriptRef = (scriptRef) => {
|
|
328
|
+
const script = Script.fromCbor(HexBlob2(scriptRef));
|
|
329
|
+
const plutusScriptCodeV3 = script.asPlutusV3()?.toCbor().toString();
|
|
330
|
+
if (plutusScriptCodeV3) {
|
|
331
|
+
return {
|
|
332
|
+
code: plutusScriptCodeV3,
|
|
333
|
+
version: "V3"
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
const plutusScriptCodeV2 = script.asPlutusV2()?.toCbor().toString();
|
|
337
|
+
if (plutusScriptCodeV2) {
|
|
338
|
+
return {
|
|
339
|
+
code: plutusScriptCodeV2,
|
|
340
|
+
version: "V2"
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
const plutusScriptCodeV1 = script.asPlutusV1()?.toCbor().toString();
|
|
344
|
+
if (plutusScriptCodeV1) {
|
|
345
|
+
return {
|
|
346
|
+
code: plutusScriptCodeV1,
|
|
347
|
+
version: "V1"
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
const nativeScript = script.asNative();
|
|
351
|
+
if (!nativeScript) {
|
|
352
|
+
throw new Error("Invalid script");
|
|
353
|
+
}
|
|
354
|
+
return fromNativeScript(nativeScript);
|
|
355
|
+
};
|
|
356
|
+
var fromNativeScript = (script) => {
|
|
357
|
+
const fromNativeScripts = (scripts) => {
|
|
358
|
+
const nativeScripts = new Array();
|
|
359
|
+
for (let index = 0; index < scripts.length; index += 1) {
|
|
360
|
+
const script2 = scripts[index];
|
|
361
|
+
if (script2) {
|
|
362
|
+
nativeScripts.push(fromNativeScript(script2));
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return nativeScripts;
|
|
366
|
+
};
|
|
367
|
+
switch (script.kind()) {
|
|
368
|
+
case RequireAllOf: {
|
|
369
|
+
const scriptAll = script.asScriptAll();
|
|
370
|
+
return {
|
|
371
|
+
type: "all",
|
|
372
|
+
scripts: fromNativeScripts(scriptAll.nativeScripts())
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
case RequireAnyOf: {
|
|
376
|
+
const scriptAny = script.asScriptAny();
|
|
377
|
+
return {
|
|
378
|
+
type: "any",
|
|
379
|
+
scripts: fromNativeScripts(scriptAny.nativeScripts())
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
case RequireNOf: {
|
|
383
|
+
const scriptNOfK = script.asScriptNOfK();
|
|
384
|
+
return {
|
|
385
|
+
type: "atLeast",
|
|
386
|
+
required: scriptNOfK.required(),
|
|
387
|
+
scripts: fromNativeScripts(scriptNOfK.nativeScripts())
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
case RequireTimeAfter: {
|
|
391
|
+
const timelockStart = script.asTimelockStart();
|
|
392
|
+
return {
|
|
393
|
+
type: "after",
|
|
394
|
+
slot: timelockStart.slot().toString()
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
case RequireTimeBefore: {
|
|
398
|
+
const timelockExpiry = script.asTimelockExpiry();
|
|
399
|
+
return {
|
|
400
|
+
type: "before",
|
|
401
|
+
slot: timelockExpiry.slot().toString()
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
case RequireSignature: {
|
|
405
|
+
const scriptPubkey = script.asScriptPubkey();
|
|
406
|
+
return {
|
|
407
|
+
type: "sig",
|
|
408
|
+
keyHash: scriptPubkey.keyHash().toString()
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
default:
|
|
412
|
+
throw new Error(`Script Kind: ${script.kind()}, is not supported`);
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
var toNativeScript = (script) => {
|
|
416
|
+
const toNativeScripts = (scripts) => {
|
|
417
|
+
const nativeScripts = [];
|
|
418
|
+
scripts.forEach((script2) => {
|
|
419
|
+
nativeScripts.push(toNativeScript(script2));
|
|
420
|
+
});
|
|
421
|
+
return nativeScripts;
|
|
422
|
+
};
|
|
423
|
+
switch (script.type) {
|
|
424
|
+
case "all":
|
|
425
|
+
return NativeScript.newScriptAll(
|
|
426
|
+
new Serialization2.ScriptAll(toNativeScripts(script.scripts))
|
|
427
|
+
);
|
|
428
|
+
case "any":
|
|
429
|
+
return NativeScript.newScriptAny(
|
|
430
|
+
new Serialization2.ScriptAny(toNativeScripts(script.scripts))
|
|
431
|
+
);
|
|
432
|
+
case "atLeast":
|
|
433
|
+
return NativeScript.newScriptNOfK(
|
|
434
|
+
new Serialization2.ScriptNOfK(
|
|
435
|
+
toNativeScripts(script.scripts),
|
|
436
|
+
script.required
|
|
437
|
+
)
|
|
438
|
+
);
|
|
439
|
+
case "after":
|
|
440
|
+
return NativeScript.newTimelockStart(
|
|
441
|
+
new Serialization2.TimelockStart(Slot(parseInt(script.slot)))
|
|
442
|
+
);
|
|
443
|
+
case "before":
|
|
444
|
+
return NativeScript.newTimelockExpiry(
|
|
445
|
+
new Serialization2.TimelockExpiry(Slot(parseInt(script.slot)))
|
|
446
|
+
);
|
|
447
|
+
case "sig":
|
|
448
|
+
return NativeScript.newScriptPubkey(
|
|
449
|
+
new Serialization2.ScriptPubkey(
|
|
450
|
+
Ed25519KeyHash4.fromBytes(toBytes2(script.keyHash)).hex()
|
|
451
|
+
)
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
var toPlutusData = (data) => {
|
|
456
|
+
const toPlutusList = (data2) => {
|
|
457
|
+
const plutusList = new PlutusList();
|
|
458
|
+
data2.forEach((element) => {
|
|
459
|
+
plutusList.add(toPlutusData(element));
|
|
460
|
+
});
|
|
461
|
+
return plutusList;
|
|
462
|
+
};
|
|
463
|
+
switch (typeof data) {
|
|
464
|
+
case "string":
|
|
465
|
+
return PlutusData.newBytes(toBytes2(data));
|
|
466
|
+
case "number":
|
|
467
|
+
return PlutusData.newInteger(BigInt(data));
|
|
468
|
+
case "bigint":
|
|
469
|
+
return PlutusData.newInteger(BigInt(data));
|
|
470
|
+
case "object":
|
|
471
|
+
if (data instanceof Array) {
|
|
472
|
+
const plutusList = toPlutusList(data);
|
|
473
|
+
return PlutusData.newList(plutusList);
|
|
474
|
+
} else if (data instanceof Map) {
|
|
475
|
+
const plutusMap = new PlutusMap();
|
|
476
|
+
data.forEach((value, key) => {
|
|
477
|
+
plutusMap.insert(toPlutusData(key), toPlutusData(value));
|
|
478
|
+
});
|
|
479
|
+
return PlutusData.newMap(plutusMap);
|
|
480
|
+
} else {
|
|
481
|
+
return PlutusData.newConstrPlutusData(
|
|
482
|
+
new ConstrPlutusData(
|
|
483
|
+
BigInt(data.alternative),
|
|
484
|
+
toPlutusList(data.fields)
|
|
485
|
+
)
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
var toValue = (assets) => {
|
|
491
|
+
const multiAsset = /* @__PURE__ */ new Map();
|
|
492
|
+
assets.filter((asset) => asset.unit !== "lovelace").forEach((asset) => {
|
|
493
|
+
multiAsset.set(AssetId(asset.unit), BigInt(asset.quantity));
|
|
494
|
+
});
|
|
495
|
+
const lovelace = assets.find((asset) => asset.unit === "lovelace");
|
|
496
|
+
const value = new Value(BigInt(lovelace ? lovelace.quantity : 0));
|
|
497
|
+
if (assets.length > 1 || !lovelace) {
|
|
498
|
+
value.setMultiasset(multiAsset);
|
|
499
|
+
}
|
|
500
|
+
return value;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
// src/utils/value.ts
|
|
504
|
+
function mergeValue(a, b) {
|
|
505
|
+
const ma = a.multiasset() ?? /* @__PURE__ */ new Map();
|
|
506
|
+
b.multiasset()?.forEach((v, k) => {
|
|
507
|
+
const newVal = (ma.get(k) ?? 0n) + v;
|
|
508
|
+
if (newVal == 0n) {
|
|
509
|
+
ma.delete(k);
|
|
510
|
+
} else {
|
|
511
|
+
ma.set(k, newVal);
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
return new Value(
|
|
515
|
+
BigInt(a.coin()) + BigInt(b.coin()),
|
|
516
|
+
ma.size > 0 ? ma : void 0
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
function negateValue(v) {
|
|
520
|
+
const entries = v.multiasset()?.entries();
|
|
521
|
+
const tokenMap = /* @__PURE__ */ new Map();
|
|
522
|
+
if (entries) {
|
|
523
|
+
for (const entry of entries) {
|
|
524
|
+
tokenMap.set(entry[0], -entry[1]);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return new Value(-v.coin(), tokenMap);
|
|
528
|
+
}
|
|
529
|
+
function subValue(a, b) {
|
|
530
|
+
return mergeValue(a, negateValue(b));
|
|
531
|
+
}
|
|
532
|
+
function negatives(v) {
|
|
533
|
+
const entries = v.multiasset()?.entries();
|
|
534
|
+
const coin = v.coin() < 0n ? v.coin() : 0n;
|
|
535
|
+
const tokenMap = /* @__PURE__ */ new Map();
|
|
536
|
+
if (entries) {
|
|
537
|
+
for (const entry of entries) {
|
|
538
|
+
if (entry[1] < 0n) {
|
|
539
|
+
tokenMap.set(entry[0], entry[1]);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return new Value(coin, tokenMap);
|
|
544
|
+
}
|
|
545
|
+
function assetTypes(v) {
|
|
546
|
+
let count = v.coin() == 0n ? 0 : 1;
|
|
547
|
+
const entries = v.multiasset();
|
|
548
|
+
if (entries) {
|
|
549
|
+
entries.forEach(() => {
|
|
550
|
+
count += 1;
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
return count;
|
|
554
|
+
}
|
|
555
|
+
function empty(v) {
|
|
556
|
+
return assetTypes(v) == 0;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// src/utils/encoding.ts
|
|
560
|
+
var hexToBytes = (hex) => Buffer.from(hex, "hex");
|
|
561
|
+
|
|
562
|
+
// src/resolvers/index.ts
|
|
563
|
+
var resolveDataHash = (data) => {
|
|
564
|
+
const plutusData = toPlutusData(data);
|
|
565
|
+
return plutusData.hash().toString();
|
|
566
|
+
};
|
|
567
|
+
var resolveNativeScriptAddress = (script, networkId = 0) => {
|
|
568
|
+
const nativeScript = toNativeScript(script);
|
|
569
|
+
const enterpriseAddress = EnterpriseAddress.fromCredentials(networkId, {
|
|
570
|
+
hash: nativeScript.hash(),
|
|
571
|
+
type: Cardano2.CredentialType.ScriptHash
|
|
572
|
+
});
|
|
573
|
+
return enterpriseAddress.toAddress().toBech32();
|
|
574
|
+
};
|
|
575
|
+
var resolveNativeScriptHash = (script) => {
|
|
576
|
+
return toNativeScript(script).hash().toString();
|
|
577
|
+
};
|
|
578
|
+
var resolvePaymentKeyHash = (bech32) => {
|
|
579
|
+
try {
|
|
580
|
+
const paymentKeyHash = [
|
|
581
|
+
toBaseAddress(bech32)?.getPaymentCredential().hash,
|
|
582
|
+
toEnterpriseAddress(bech32)?.getPaymentCredential().hash
|
|
583
|
+
].find((kh) => kh !== void 0);
|
|
584
|
+
if (paymentKeyHash !== void 0) return paymentKeyHash.toString();
|
|
585
|
+
throw new Error(
|
|
586
|
+
`Couldn't resolve payment key hash from address: ${bech32}`
|
|
587
|
+
);
|
|
588
|
+
} catch (error) {
|
|
589
|
+
throw new Error(
|
|
590
|
+
`An error occurred during resolvePaymentKeyHash: ${error}.`
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
var resolvePlutusScriptAddress = (script, networkId = 0) => {
|
|
595
|
+
const plutusScript = deserializePlutusScript(script.code, script.version);
|
|
596
|
+
const enterpriseAddress = EnterpriseAddress.fromCredentials(networkId, {
|
|
597
|
+
hash: plutusScript.hash(),
|
|
598
|
+
type: Cardano2.CredentialType.ScriptHash
|
|
599
|
+
});
|
|
600
|
+
return enterpriseAddress.toAddress().toBech32();
|
|
601
|
+
};
|
|
602
|
+
var resolvePlutusScriptHash = (bech32) => {
|
|
603
|
+
try {
|
|
604
|
+
const enterpriseAddress = toEnterpriseAddress(bech32);
|
|
605
|
+
const scriptHash = enterpriseAddress?.getPaymentCredential().hash;
|
|
606
|
+
if (scriptHash !== void 0) return scriptHash.toString();
|
|
607
|
+
throw new Error(`Couldn't resolve script hash from address: ${bech32}`);
|
|
608
|
+
} catch (error) {
|
|
609
|
+
throw new Error(`An error occurred during resolveScriptHash: ${error}.`);
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
var resolvePoolId = (hash2) => {
|
|
613
|
+
return Ed25519KeyHashHex2(hash2).toString();
|
|
614
|
+
};
|
|
615
|
+
var resolvePrivateKey = (words) => {
|
|
616
|
+
return "not implemented";
|
|
617
|
+
};
|
|
618
|
+
var resolveScriptRef = (script) => {
|
|
619
|
+
return toScriptRef(script).toCbor().toString();
|
|
620
|
+
};
|
|
621
|
+
var resolveRewardAddress = (bech32) => {
|
|
622
|
+
try {
|
|
623
|
+
const address = toAddress(bech32);
|
|
624
|
+
const baseAddress = toBaseAddress(bech32);
|
|
625
|
+
const stakeKeyHash = baseAddress?.getStakeCredential().hash;
|
|
626
|
+
if (stakeKeyHash !== void 0)
|
|
627
|
+
return buildRewardAddress(address.getNetworkId(), stakeKeyHash).toAddress().toBech32();
|
|
628
|
+
throw new Error(`Couldn't resolve reward address from address: ${bech32}`);
|
|
629
|
+
} catch (error) {
|
|
630
|
+
throw new Error(`An error occurred during resolveRewardAddress: ${error}.`);
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
var resolveStakeKeyHash = (bech32) => {
|
|
634
|
+
try {
|
|
635
|
+
const stakeKeyHash = [
|
|
636
|
+
toBaseAddress(bech32)?.getStakeCredential().hash,
|
|
637
|
+
toRewardAddress(bech32)?.getPaymentCredential().hash
|
|
638
|
+
].find((kh) => kh !== void 0);
|
|
639
|
+
if (stakeKeyHash !== void 0) return stakeKeyHash.toString();
|
|
640
|
+
throw new Error(`Couldn't resolve stake key hash from address: ${bech32}`);
|
|
641
|
+
} catch (error) {
|
|
642
|
+
throw new Error(`An error occurred during resolveStakeKeyHash: ${error}.`);
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
var resolveTxHash = (txHex) => {
|
|
646
|
+
const txBody = deserializeTx(txHex).body();
|
|
647
|
+
const hash2 = blake2b(blake2b.BYTES).update(hexToBytes(txBody.toCbor())).digest();
|
|
648
|
+
return Cardano2.TransactionId.fromHexBlob(HexBlob3.fromBytes(hash2));
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
// src/serializer/index.ts
|
|
652
|
+
import { Serialization as Serialization4, TxCBOR as TxCBOR2 } from "@cardano-sdk/core";
|
|
653
|
+
import { HexBlob as HexBlob5 } from "@cardano-sdk/util";
|
|
654
|
+
import {
|
|
655
|
+
DEFAULT_V1_COST_MODEL_LIST,
|
|
656
|
+
DEFAULT_V2_COST_MODEL_LIST
|
|
657
|
+
} from "@meshsdk/common";
|
|
658
|
+
|
|
659
|
+
// src/utils/script-data-hash.ts
|
|
660
|
+
import { Serialization as Serialization3 } from "@cardano-sdk/core";
|
|
661
|
+
import * as Crypto2 from "@cardano-sdk/crypto";
|
|
662
|
+
import { Hash32ByteBase16 as Hash32ByteBase163 } from "@cardano-sdk/crypto";
|
|
663
|
+
import { HexBlob as HexBlob4 } from "@cardano-sdk/util";
|
|
664
|
+
var CBOR_EMPTY_LIST = new Uint8Array([128]);
|
|
665
|
+
var CBOR_EMPTY_MAP = new Uint8Array([160]);
|
|
666
|
+
var getCborEncodedArray = (items) => {
|
|
667
|
+
const writer = new Serialization3.CborWriter();
|
|
668
|
+
writer.writeStartArray(items.length);
|
|
669
|
+
for (const item of items) {
|
|
670
|
+
writer.writeEncodedValue(Buffer.from(item.toCbor(), "hex"));
|
|
671
|
+
}
|
|
672
|
+
return writer.encode();
|
|
673
|
+
};
|
|
674
|
+
var hashScriptData = (costModels, redemeers, datums) => {
|
|
675
|
+
const writer = new Serialization3.CborWriter();
|
|
676
|
+
if (datums && datums.length > 0 && (!redemeers || redemeers.length === 0)) {
|
|
677
|
+
writer.writeEncodedValue(CBOR_EMPTY_LIST);
|
|
678
|
+
writer.writeEncodedValue(getCborEncodedArray(datums));
|
|
679
|
+
writer.writeEncodedValue(CBOR_EMPTY_MAP);
|
|
680
|
+
} else {
|
|
681
|
+
if (!redemeers || redemeers.length === 0) return void 0;
|
|
682
|
+
writer.writeEncodedValue(getCborEncodedArray(redemeers));
|
|
683
|
+
if (datums && datums.length > 0)
|
|
684
|
+
writer.writeEncodedValue(getCborEncodedArray(datums));
|
|
685
|
+
writer.writeEncodedValue(
|
|
686
|
+
Buffer.from(costModels.languageViewsEncoding(), "hex")
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
return Hash32ByteBase163.fromHexBlob(
|
|
690
|
+
HexBlob4.fromBytes(
|
|
691
|
+
Crypto2.blake2b(Crypto2.blake2b.BYTES).update(writer.encode()).digest()
|
|
692
|
+
)
|
|
693
|
+
);
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
// src/serializer/index.ts
|
|
697
|
+
var CardanoSDKSerializer = class {
|
|
698
|
+
constructor() {
|
|
699
|
+
this.utxoContext = /* @__PURE__ */ new Map();
|
|
700
|
+
this.redeemerContext = /* @__PURE__ */ new Map();
|
|
701
|
+
this.scriptsProvided = /* @__PURE__ */ new Set();
|
|
702
|
+
this.datumsProvided = /* @__PURE__ */ new Set();
|
|
703
|
+
this.usedLanguages = {
|
|
704
|
+
[0]: false,
|
|
705
|
+
[1]: false,
|
|
706
|
+
[2]: false
|
|
707
|
+
};
|
|
708
|
+
this.deserializer = {
|
|
709
|
+
key: {
|
|
710
|
+
deserializeAddress: function(bech32) {
|
|
711
|
+
throw new Error("Function not implemented.");
|
|
712
|
+
}
|
|
713
|
+
},
|
|
714
|
+
script: {
|
|
715
|
+
deserializeNativeScript: function(script) {
|
|
716
|
+
throw new Error("Function not implemented.");
|
|
717
|
+
},
|
|
718
|
+
deserializePlutusScript: function(script) {
|
|
719
|
+
throw new Error("Function not implemented.");
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
this.resolver = {
|
|
724
|
+
keys: {
|
|
725
|
+
// resolvePaymentKeyHash: function (bech32: string): string {
|
|
726
|
+
// const cardanoAddress = toAddress(bech32);
|
|
727
|
+
// return cardanoAddress.asEnterprise()?.getPaymentCredential().type ===
|
|
728
|
+
// CredentialType.KeyHash
|
|
729
|
+
// ? cardanoAddress.asEnterprise()!.getPaymentCredential().hash
|
|
730
|
+
// : "";
|
|
731
|
+
// },
|
|
732
|
+
// resolvePlutusScriptHash: function (bech32: string): string {
|
|
733
|
+
// const cardanoAddress = toAddress(bech32);
|
|
734
|
+
// return cardanoAddress.asEnterprise()?.getPaymentCredential().type ===
|
|
735
|
+
// CredentialType.ScriptHash
|
|
736
|
+
// ? cardanoAddress.asEnterprise()!.getPaymentCredential().hash
|
|
737
|
+
// : "";
|
|
738
|
+
// },
|
|
739
|
+
resolveStakeKeyHash: function(bech32) {
|
|
740
|
+
const cardanoAddress = toAddress(bech32);
|
|
741
|
+
return cardanoAddress.asReward()?.getPaymentCredential().type === CredentialType.KeyHash ? cardanoAddress.asReward().getPaymentCredential().hash : "";
|
|
742
|
+
},
|
|
743
|
+
// resolveStakeScriptHash(bech32: string): string {
|
|
744
|
+
// const cardanoAddress = toAddress(bech32);
|
|
745
|
+
// return cardanoAddress.asReward()?.getPaymentCredential().type ===
|
|
746
|
+
// CredentialType.ScriptHash
|
|
747
|
+
// ? cardanoAddress.asReward()!.getPaymentCredential().hash
|
|
748
|
+
// : "";
|
|
749
|
+
// },
|
|
750
|
+
resolvePrivateKey: function(words) {
|
|
751
|
+
throw new Error("Function not implemented.");
|
|
752
|
+
},
|
|
753
|
+
resolveRewardAddress: function(bech32) {
|
|
754
|
+
throw new Error("Function not implemented.");
|
|
755
|
+
},
|
|
756
|
+
resolveEd25519KeyHash: function(bech32) {
|
|
757
|
+
throw new Error("Function not implemented.");
|
|
758
|
+
}
|
|
759
|
+
},
|
|
760
|
+
tx: {
|
|
761
|
+
resolveTxHash: function(txHex) {
|
|
762
|
+
return Transaction.fromCbor(TxCBOR2(txHex)).getId();
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
data: {
|
|
766
|
+
resolveDataHash: function(data) {
|
|
767
|
+
throw new Error("Function not implemented.");
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
script: {
|
|
771
|
+
// resolveNativeScript: function (script: CommonNativeScript): string {
|
|
772
|
+
// return toNativeScript(script).toCbor();
|
|
773
|
+
// },
|
|
774
|
+
resolveScriptRef: function(script) {
|
|
775
|
+
throw new Error("Function not implemented.");
|
|
776
|
+
}
|
|
777
|
+
},
|
|
778
|
+
pool: {
|
|
779
|
+
resolvePoolId: function(hash2) {
|
|
780
|
+
throw new Error("Function not implemented.");
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
this.serializeTxBody = (txBuilderBody, protocolParams) => {
|
|
785
|
+
const {
|
|
786
|
+
inputs,
|
|
787
|
+
outputs,
|
|
788
|
+
extraInputs,
|
|
789
|
+
selectionThreshold,
|
|
790
|
+
collaterals,
|
|
791
|
+
referenceInputs,
|
|
792
|
+
mints,
|
|
793
|
+
changeAddress,
|
|
794
|
+
certificates,
|
|
795
|
+
validityRange,
|
|
796
|
+
requiredSignatures,
|
|
797
|
+
metadata
|
|
798
|
+
} = txBuilderBody;
|
|
799
|
+
mints.sort((a, b) => a.policyId.localeCompare(b.policyId));
|
|
800
|
+
inputs.sort((a, b) => {
|
|
801
|
+
if (a.txIn.txHash === b.txIn.txHash) {
|
|
802
|
+
return a.txIn.txIndex - b.txIn.txIndex;
|
|
803
|
+
} else {
|
|
804
|
+
return a.txIn.txHash.localeCompare(b.txIn.txHash);
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
this.addAllInputs(inputs);
|
|
808
|
+
this.addAllCollateralInputs(collaterals);
|
|
809
|
+
this.buildWitnessSet();
|
|
810
|
+
this.balanceTx(changeAddress, requiredSignatures.length, protocolParams);
|
|
811
|
+
return new Transaction(this.txBody, this.txWitnessSet).toCbor();
|
|
812
|
+
};
|
|
813
|
+
this.addSigningKeys = (txHex, signingKeys) => {
|
|
814
|
+
let cardanoTx = Transaction.fromCbor(TxCBOR2(txHex));
|
|
815
|
+
let currentWitnessSet = cardanoTx.witnessSet();
|
|
816
|
+
let currentWitnessSetVkeys = currentWitnessSet.vkeys();
|
|
817
|
+
let currentWitnessSetVkeysValues = currentWitnessSetVkeys ? [...currentWitnessSetVkeys.values()] : [];
|
|
818
|
+
for (let i = 0; i < signingKeys.length; i++) {
|
|
819
|
+
let keyHex = signingKeys[i];
|
|
820
|
+
if (keyHex) {
|
|
821
|
+
if (keyHex.length === 68 && keyHex.substring(0, 4) === "5820") {
|
|
822
|
+
keyHex = keyHex.substring(4);
|
|
823
|
+
}
|
|
824
|
+
const cardanoSigner = new PrivateKey(Buffer.from(keyHex, "hex"), false);
|
|
825
|
+
const signature = cardanoSigner.sign(
|
|
826
|
+
Buffer.from(cardanoTx.getId(), "hex")
|
|
827
|
+
);
|
|
828
|
+
currentWitnessSetVkeysValues.push(
|
|
829
|
+
new VkeyWitness(
|
|
830
|
+
Ed25519PublicKeyHex2(
|
|
831
|
+
cardanoSigner.toPublicKey().toBytes().toString("hex")
|
|
832
|
+
),
|
|
833
|
+
Ed25519SignatureHex2(signature.toString("hex"))
|
|
834
|
+
)
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
currentWitnessSet.setVkeys(
|
|
839
|
+
Serialization4.CborSet.fromCore(
|
|
840
|
+
currentWitnessSetVkeysValues.map((vkw) => vkw.toCore()),
|
|
841
|
+
VkeyWitness.fromCore
|
|
842
|
+
)
|
|
843
|
+
);
|
|
844
|
+
cardanoTx.setWitnessSet(currentWitnessSet);
|
|
845
|
+
return cardanoTx.toCbor();
|
|
846
|
+
};
|
|
847
|
+
this.addAllInputs = (inputs) => {
|
|
848
|
+
for (let i = 0; i < inputs.length; i += 1) {
|
|
849
|
+
const currentTxIn = inputs[i];
|
|
850
|
+
if (!currentTxIn) continue;
|
|
851
|
+
switch (currentTxIn.type) {
|
|
852
|
+
case "PubKey":
|
|
853
|
+
this.addTxIn(currentTxIn);
|
|
854
|
+
break;
|
|
855
|
+
case "Script":
|
|
856
|
+
this.addScriptTxIn(
|
|
857
|
+
currentTxIn
|
|
858
|
+
);
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
this.addTxIn = (currentTxIn) => {
|
|
864
|
+
let cardanoTxIn = new TransactionInput(
|
|
865
|
+
TransactionId(currentTxIn.txIn.txHash),
|
|
866
|
+
BigInt(currentTxIn.txIn.txIndex)
|
|
867
|
+
);
|
|
868
|
+
const inputs = this.txBody.inputs();
|
|
869
|
+
const txInputsList = [...inputs.values()];
|
|
870
|
+
if (txInputsList.find((input) => {
|
|
871
|
+
input.index() == cardanoTxIn.index() && input.transactionId == cardanoTxIn.transactionId;
|
|
872
|
+
})) {
|
|
873
|
+
throw new Error("Duplicate input added to tx body");
|
|
874
|
+
}
|
|
875
|
+
txInputsList.push(cardanoTxIn);
|
|
876
|
+
inputs.setValues(txInputsList);
|
|
877
|
+
const cardanoTxOut = new TransactionOutput(
|
|
878
|
+
Address.fromBech32(currentTxIn.txIn.address),
|
|
879
|
+
toValue(currentTxIn.txIn.amount)
|
|
880
|
+
);
|
|
881
|
+
this.utxoContext.set(cardanoTxIn, cardanoTxOut);
|
|
882
|
+
this.txBody.setInputs(inputs);
|
|
883
|
+
};
|
|
884
|
+
this.addScriptTxIn = (currentTxIn) => {
|
|
885
|
+
this.addTxIn({
|
|
886
|
+
type: "PubKey",
|
|
887
|
+
txIn: currentTxIn.txIn
|
|
888
|
+
});
|
|
889
|
+
if (!currentTxIn.scriptTxIn.scriptSource) {
|
|
890
|
+
throw new Error("A script input had no script source");
|
|
891
|
+
}
|
|
892
|
+
if (!currentTxIn.scriptTxIn.datumSource) {
|
|
893
|
+
throw new Error("A script input had no datum source");
|
|
894
|
+
}
|
|
895
|
+
if (!currentTxIn.scriptTxIn.redeemer) {
|
|
896
|
+
throw new Error("A script input had no redeemer");
|
|
897
|
+
}
|
|
898
|
+
if (currentTxIn.scriptTxIn.scriptSource.type === "Provided") {
|
|
899
|
+
switch (currentTxIn.scriptTxIn.scriptSource.script.version) {
|
|
900
|
+
case "V1": {
|
|
901
|
+
this.scriptsProvided.add(
|
|
902
|
+
Script.newPlutusV1Script(
|
|
903
|
+
PlutusV1Script.fromCbor(
|
|
904
|
+
HexBlob5(currentTxIn.scriptTxIn.scriptSource.script.code)
|
|
905
|
+
)
|
|
906
|
+
)
|
|
907
|
+
);
|
|
908
|
+
this.usedLanguages[PlutusLanguageVersion.V1] = true;
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
case "V2": {
|
|
912
|
+
this.scriptsProvided.add(
|
|
913
|
+
Script.newPlutusV2Script(
|
|
914
|
+
PlutusV2Script.fromCbor(
|
|
915
|
+
HexBlob5(currentTxIn.scriptTxIn.scriptSource.script.code)
|
|
916
|
+
)
|
|
917
|
+
)
|
|
918
|
+
);
|
|
919
|
+
this.usedLanguages[PlutusLanguageVersion.V2] = true;
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
case "V3": {
|
|
923
|
+
this.scriptsProvided.add(
|
|
924
|
+
Script.newPlutusV3Script(
|
|
925
|
+
PlutusV3Script.fromCbor(
|
|
926
|
+
HexBlob5(currentTxIn.scriptTxIn.scriptSource.script.code)
|
|
927
|
+
)
|
|
928
|
+
)
|
|
929
|
+
);
|
|
930
|
+
this.usedLanguages[PlutusLanguageVersion.V3] = true;
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
} else if (currentTxIn.scriptTxIn.scriptSource.type === "Inline") {
|
|
935
|
+
let referenceInputs = this.txBody.referenceInputs() ? this.txBody.referenceInputs() : Serialization4.CborSet.fromCore([], TransactionInput.fromCore);
|
|
936
|
+
let referenceInputsList = [...referenceInputs.values()];
|
|
937
|
+
referenceInputsList.push(
|
|
938
|
+
new TransactionInput(
|
|
939
|
+
TransactionId(currentTxIn.scriptTxIn.scriptSource.txHash),
|
|
940
|
+
BigInt(currentTxIn.scriptTxIn.scriptSource.txIndex)
|
|
941
|
+
)
|
|
942
|
+
);
|
|
943
|
+
referenceInputs.setValues(referenceInputsList);
|
|
944
|
+
this.txBody.setReferenceInputs(referenceInputs);
|
|
945
|
+
switch (currentTxIn.scriptTxIn.scriptSource.version) {
|
|
946
|
+
case "V1": {
|
|
947
|
+
this.usedLanguages[PlutusLanguageVersion.V1] = true;
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
case "V2": {
|
|
951
|
+
this.usedLanguages[PlutusLanguageVersion.V2] = true;
|
|
952
|
+
break;
|
|
953
|
+
}
|
|
954
|
+
case "V3": {
|
|
955
|
+
this.usedLanguages[PlutusLanguageVersion.V3] = true;
|
|
956
|
+
break;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
if (currentTxIn.scriptTxIn.datumSource.type === "Provided") {
|
|
961
|
+
this.datumsProvided.add(
|
|
962
|
+
toPlutusData(currentTxIn.scriptTxIn.datumSource.data.content)
|
|
963
|
+
// TODO: handle json / raw datum
|
|
964
|
+
);
|
|
965
|
+
} else if (currentTxIn.scriptTxIn.datumSource.type === "Inline") {
|
|
966
|
+
let referenceInputs = this.txBody.referenceInputs() ? this.txBody.referenceInputs() : Serialization4.CborSet.fromCore([], TransactionInput.fromCore);
|
|
967
|
+
let referenceInputsList = [...referenceInputs.values()];
|
|
968
|
+
referenceInputsList.push(
|
|
969
|
+
new TransactionInput(
|
|
970
|
+
TransactionId(currentTxIn.txIn.txHash),
|
|
971
|
+
BigInt(currentTxIn.txIn.txIndex)
|
|
972
|
+
)
|
|
973
|
+
);
|
|
974
|
+
referenceInputs.setValues(referenceInputsList);
|
|
975
|
+
this.txBody.setReferenceInputs(referenceInputs);
|
|
976
|
+
}
|
|
977
|
+
let cardanoTxIn = new TransactionInput(
|
|
978
|
+
TransactionId(currentTxIn.txIn.txHash),
|
|
979
|
+
BigInt(currentTxIn.txIn.txIndex)
|
|
980
|
+
);
|
|
981
|
+
let exUnits = currentTxIn.scriptTxIn.redeemer.exUnits;
|
|
982
|
+
this.redeemerContext.set(
|
|
983
|
+
cardanoTxIn,
|
|
984
|
+
new Redeemer(
|
|
985
|
+
RedeemerTag.Spend,
|
|
986
|
+
BigInt(0),
|
|
987
|
+
toPlutusData(currentTxIn.scriptTxIn.redeemer.data.content),
|
|
988
|
+
// TODO: handle json / raw datum
|
|
989
|
+
new ExUnits(BigInt(exUnits.mem), BigInt(exUnits.steps))
|
|
990
|
+
)
|
|
991
|
+
);
|
|
992
|
+
};
|
|
993
|
+
this.addSimpleScriptTxIn = (currentTxIn) => {
|
|
994
|
+
};
|
|
995
|
+
this.addAllCollateralInputs = (collaterals) => {
|
|
996
|
+
for (let i = 0; i < collaterals.length; i++) {
|
|
997
|
+
this.addCollateralInput(
|
|
998
|
+
collaterals[i]
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
this.addCollateralInput = (collateral) => {
|
|
1003
|
+
let cardanoTxIn = new TransactionInput(
|
|
1004
|
+
TransactionId(collateral.txIn.txHash),
|
|
1005
|
+
BigInt(collateral.txIn.txIndex)
|
|
1006
|
+
);
|
|
1007
|
+
const collateralInputs = this.txBody.collateral() ? this.txBody.collateral() : Serialization4.CborSet.fromCore([], TransactionInput.fromCore);
|
|
1008
|
+
const collateralInputsList = [
|
|
1009
|
+
...collateralInputs.values()
|
|
1010
|
+
];
|
|
1011
|
+
if (collateralInputsList.find((input) => {
|
|
1012
|
+
input.index() == cardanoTxIn.index() && input.transactionId == cardanoTxIn.transactionId;
|
|
1013
|
+
})) {
|
|
1014
|
+
throw new Error("Duplicate input added to tx body");
|
|
1015
|
+
}
|
|
1016
|
+
collateralInputsList.push(cardanoTxIn);
|
|
1017
|
+
collateralInputs.setValues(collateralInputsList);
|
|
1018
|
+
const cardanoTxOut = new TransactionOutput(
|
|
1019
|
+
Address.fromBech32(collateral.txIn.address),
|
|
1020
|
+
toValue(collateral.txIn.amount)
|
|
1021
|
+
);
|
|
1022
|
+
this.utxoContext.set(cardanoTxIn, cardanoTxOut);
|
|
1023
|
+
this.txBody.setCollateral(collateralInputs);
|
|
1024
|
+
};
|
|
1025
|
+
this.buildWitnessSet = () => {
|
|
1026
|
+
const inputs = this.txBody.inputs();
|
|
1027
|
+
for (let i = 0; i < inputs.size(); i += 1) {
|
|
1028
|
+
const input = inputs.values().at(i);
|
|
1029
|
+
if (input) {
|
|
1030
|
+
let redeemer = this.redeemerContext.get(input);
|
|
1031
|
+
if (redeemer) {
|
|
1032
|
+
redeemer.setIndex(BigInt(i));
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
let redeemers = this.txWitnessSet.redeemers() ? this.txWitnessSet.redeemers() : Redeemers.fromCore([]);
|
|
1037
|
+
let redeemersList = [...redeemers.values()];
|
|
1038
|
+
this.redeemerContext.forEach((redeemer) => {
|
|
1039
|
+
redeemersList.push(redeemer);
|
|
1040
|
+
});
|
|
1041
|
+
redeemers.setValues(redeemersList);
|
|
1042
|
+
this.txWitnessSet.setRedeemers(redeemers);
|
|
1043
|
+
let nativeScripts = this.txWitnessSet.nativeScripts() ? this.txWitnessSet.nativeScripts() : Serialization4.CborSet.fromCore([], NativeScript.fromCore);
|
|
1044
|
+
let v1Scripts = this.txWitnessSet.plutusV1Scripts() ? this.txWitnessSet.plutusV1Scripts() : Serialization4.CborSet.fromCore([], PlutusV1Script.fromCore);
|
|
1045
|
+
let v2Scripts = this.txWitnessSet.plutusV2Scripts() ? this.txWitnessSet.plutusV2Scripts() : Serialization4.CborSet.fromCore([], PlutusV2Script.fromCore);
|
|
1046
|
+
let v3Scripts = this.txWitnessSet.plutusV3Scripts() ? this.txWitnessSet.plutusV3Scripts() : Serialization4.CborSet.fromCore([], PlutusV3Script.fromCore);
|
|
1047
|
+
this.scriptsProvided.forEach((script) => {
|
|
1048
|
+
if (script.asNative() !== void 0) {
|
|
1049
|
+
let nativeScriptsList = [...nativeScripts.values()];
|
|
1050
|
+
nativeScriptsList.push(script.asNative());
|
|
1051
|
+
nativeScripts.setValues(nativeScriptsList);
|
|
1052
|
+
} else if (script.asPlutusV1() !== void 0) {
|
|
1053
|
+
let v1ScriptsList = [...v1Scripts.values()];
|
|
1054
|
+
v1ScriptsList.push(script.asPlutusV1());
|
|
1055
|
+
v1Scripts.setValues(v1ScriptsList);
|
|
1056
|
+
} else if (script.asPlutusV2() !== void 0) {
|
|
1057
|
+
let v2ScriptsList = [...v2Scripts.values()];
|
|
1058
|
+
v2ScriptsList.push(script.asPlutusV2());
|
|
1059
|
+
v2Scripts.setValues(v2ScriptsList);
|
|
1060
|
+
} else if (script.asPlutusV3() !== void 0) {
|
|
1061
|
+
let v3ScriptsList = [...v3Scripts.values()];
|
|
1062
|
+
v3ScriptsList.push(script.asPlutusV3());
|
|
1063
|
+
v3Scripts.setValues(v3ScriptsList);
|
|
1064
|
+
}
|
|
1065
|
+
this.txWitnessSet.setNativeScripts(nativeScripts);
|
|
1066
|
+
this.txWitnessSet.setPlutusV1Scripts(v1Scripts);
|
|
1067
|
+
this.txWitnessSet.setPlutusV2Scripts(v2Scripts);
|
|
1068
|
+
this.txWitnessSet.setPlutusV3Scripts(v3Scripts);
|
|
1069
|
+
});
|
|
1070
|
+
let datums = this.txWitnessSet.plutusData() ? this.txWitnessSet.plutusData() : Serialization4.CborSet.fromCore([], PlutusData.fromCore);
|
|
1071
|
+
this.datumsProvided.forEach((datum) => {
|
|
1072
|
+
let datumsList = [...datums.values()];
|
|
1073
|
+
datumsList.push(datum);
|
|
1074
|
+
datums.setValues(datumsList);
|
|
1075
|
+
});
|
|
1076
|
+
this.txWitnessSet.setPlutusData(datums);
|
|
1077
|
+
let costModelV1 = Serialization4.CostModel.newPlutusV1(
|
|
1078
|
+
DEFAULT_V1_COST_MODEL_LIST
|
|
1079
|
+
);
|
|
1080
|
+
let costModelV2 = Serialization4.CostModel.newPlutusV2(
|
|
1081
|
+
DEFAULT_V2_COST_MODEL_LIST
|
|
1082
|
+
);
|
|
1083
|
+
let costModels = new Serialization4.Costmdls();
|
|
1084
|
+
if (this.usedLanguages[PlutusLanguageVersion.V1]) {
|
|
1085
|
+
costModels.insert(costModelV1);
|
|
1086
|
+
}
|
|
1087
|
+
if (this.usedLanguages[PlutusLanguageVersion.V2]) {
|
|
1088
|
+
costModels.insert(costModelV2);
|
|
1089
|
+
}
|
|
1090
|
+
if (this.usedLanguages[PlutusLanguageVersion.V3]) {
|
|
1091
|
+
}
|
|
1092
|
+
let scriptDataHash = hashScriptData(
|
|
1093
|
+
costModels,
|
|
1094
|
+
redeemers.size() > 0 ? [...redeemers.values()] : void 0,
|
|
1095
|
+
datums.size() > 0 ? [...datums.values()] : void 0
|
|
1096
|
+
);
|
|
1097
|
+
if (scriptDataHash) {
|
|
1098
|
+
this.txBody.setScriptDataHash(scriptDataHash);
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
this.balanceTx = (changeAddress, numberOfRequiredWitnesses, protocolParams) => {
|
|
1102
|
+
if (changeAddress === "") {
|
|
1103
|
+
throw new Error("Can't balance tx without a change address");
|
|
1104
|
+
}
|
|
1105
|
+
const inputs = this.txBody.inputs().values();
|
|
1106
|
+
let remainingValue = new Value(BigInt(0));
|
|
1107
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
1108
|
+
let input = inputs[i];
|
|
1109
|
+
if (!input) {
|
|
1110
|
+
throw new Error("Invalid input found");
|
|
1111
|
+
}
|
|
1112
|
+
const output = this.utxoContext.get(input);
|
|
1113
|
+
if (!output) {
|
|
1114
|
+
throw new Error(`Unable to resolve input: ${input.toCbor()}`);
|
|
1115
|
+
}
|
|
1116
|
+
remainingValue = mergeValue(remainingValue, output.amount());
|
|
1117
|
+
}
|
|
1118
|
+
const withdrawals = this.txBody.withdrawals();
|
|
1119
|
+
if (withdrawals) {
|
|
1120
|
+
withdrawals.forEach((coin) => {
|
|
1121
|
+
remainingValue = mergeValue(remainingValue, new Value(coin));
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
remainingValue = mergeValue(
|
|
1125
|
+
remainingValue,
|
|
1126
|
+
new Value(BigInt(0), this.txBody.mint())
|
|
1127
|
+
);
|
|
1128
|
+
const currentOutputs = this.txBody.outputs();
|
|
1129
|
+
for (let i = 0; i < currentOutputs.length; i++) {
|
|
1130
|
+
let output = currentOutputs.at(i);
|
|
1131
|
+
if (output) {
|
|
1132
|
+
remainingValue = subValue(remainingValue, output.amount());
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
if (remainingValue.coin() < 0 || !empty(negatives(remainingValue))) {
|
|
1136
|
+
throw new Error(`Not enough funds to satisfy outputs`);
|
|
1137
|
+
}
|
|
1138
|
+
currentOutputs.push(
|
|
1139
|
+
new TransactionOutput(Address.fromBech32(changeAddress), remainingValue)
|
|
1140
|
+
);
|
|
1141
|
+
this.txBody.setOutputs(currentOutputs);
|
|
1142
|
+
this.txBody.setFee(BigInt("10000000"));
|
|
1143
|
+
const dummyTx = this.createDummyTx(numberOfRequiredWitnesses);
|
|
1144
|
+
const fee = protocolParams.minFeeB + dummyTx.toCbor().length / 2 * Number(protocolParams.coinsPerUtxoSize);
|
|
1145
|
+
this.txBody.setFee(BigInt(fee));
|
|
1146
|
+
const changeOutput = currentOutputs.pop();
|
|
1147
|
+
if (!changeOutput) {
|
|
1148
|
+
throw new Error(
|
|
1149
|
+
"Somehow the output length was 0 after attempting to calculate fees"
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
changeOutput.amount().setCoin(changeOutput.amount().coin() - BigInt(fee));
|
|
1153
|
+
currentOutputs.push(changeOutput);
|
|
1154
|
+
this.txBody.setOutputs(currentOutputs);
|
|
1155
|
+
};
|
|
1156
|
+
this.createDummyTx = (numberOfRequiredWitnesses) => {
|
|
1157
|
+
let dummyWitnessSet = new TransactionWitnessSet();
|
|
1158
|
+
const dummyVkeyWitnesses = [];
|
|
1159
|
+
for (let i = 0; i < numberOfRequiredWitnesses; i++) {
|
|
1160
|
+
dummyVkeyWitnesses.push([
|
|
1161
|
+
Ed25519PublicKeyHex2("0".repeat(64)),
|
|
1162
|
+
Ed25519SignatureHex2("0".repeat(128))
|
|
1163
|
+
]);
|
|
1164
|
+
}
|
|
1165
|
+
dummyWitnessSet.setVkeys(
|
|
1166
|
+
Serialization4.CborSet.fromCore(dummyVkeyWitnesses, VkeyWitness.fromCore)
|
|
1167
|
+
);
|
|
1168
|
+
return new Transaction(this.txBody, dummyWitnessSet);
|
|
1169
|
+
};
|
|
1170
|
+
this.txBody = new TransactionBody(
|
|
1171
|
+
Serialization4.CborSet.fromCore([], TransactionInput.fromCore),
|
|
1172
|
+
[],
|
|
1173
|
+
BigInt(0),
|
|
1174
|
+
void 0
|
|
1175
|
+
);
|
|
1176
|
+
this.txWitnessSet = new TransactionWitnessSet();
|
|
1177
|
+
}
|
|
1178
|
+
serializeAddress(address, networkId) {
|
|
1179
|
+
throw new Error("Method not implemented.");
|
|
1180
|
+
}
|
|
1181
|
+
serializeData(data) {
|
|
1182
|
+
throw new Error("Method not implemented.");
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1186
|
+
// src/index.ts
|
|
1187
|
+
import * as CardanoSDKUtil from "@cardano-sdk/util";
|
|
1188
|
+
import * as Crypto3 from "@cardano-sdk/crypto";
|
|
1189
|
+
import * as CardanoSDK from "@cardano-sdk/core";
|
|
1190
|
+
export {
|
|
1191
|
+
Address,
|
|
1192
|
+
AddressType,
|
|
1193
|
+
AssetFingerprint,
|
|
1194
|
+
AssetId,
|
|
1195
|
+
AssetName,
|
|
1196
|
+
BaseAddress,
|
|
1197
|
+
Bip32PrivateKey3 as Bip32PrivateKey,
|
|
1198
|
+
Bip32PrivateKeyHex2 as Bip32PrivateKeyHex,
|
|
1199
|
+
Cardano4 as Cardano,
|
|
1200
|
+
CardanoSDK,
|
|
1201
|
+
CardanoSDKSerializer,
|
|
1202
|
+
CardanoSDKUtil,
|
|
1203
|
+
CborSet,
|
|
1204
|
+
CborWriter,
|
|
1205
|
+
Certificate,
|
|
1206
|
+
CertificateType,
|
|
1207
|
+
ConstrPlutusData,
|
|
1208
|
+
CostModel,
|
|
1209
|
+
Costmdls,
|
|
1210
|
+
Credential,
|
|
1211
|
+
CredentialType,
|
|
1212
|
+
Crypto3 as Crypto,
|
|
1213
|
+
Datum,
|
|
1214
|
+
DatumHash,
|
|
1215
|
+
DatumKind,
|
|
1216
|
+
Ed25519KeyHash2 as Ed25519KeyHash,
|
|
1217
|
+
Ed25519KeyHashHex2 as Ed25519KeyHashHex,
|
|
1218
|
+
Ed25519PrivateExtendedKeyHex,
|
|
1219
|
+
Ed25519PrivateNormalKeyHex,
|
|
1220
|
+
Ed25519PublicKey2 as Ed25519PublicKey,
|
|
1221
|
+
Ed25519PublicKeyHex2 as Ed25519PublicKeyHex,
|
|
1222
|
+
Ed25519Signature2 as Ed25519Signature,
|
|
1223
|
+
Ed25519SignatureHex2 as Ed25519SignatureHex,
|
|
1224
|
+
EnterpriseAddress,
|
|
1225
|
+
ExUnits,
|
|
1226
|
+
Hash,
|
|
1227
|
+
Hash28ByteBase162 as Hash28ByteBase16,
|
|
1228
|
+
Hash32ByteBase162 as Hash32ByteBase16,
|
|
1229
|
+
NativeScript,
|
|
1230
|
+
NetworkId,
|
|
1231
|
+
PaymentAddress,
|
|
1232
|
+
PlutusData,
|
|
1233
|
+
PlutusLanguageVersion,
|
|
1234
|
+
PlutusList,
|
|
1235
|
+
PlutusMap,
|
|
1236
|
+
PlutusV1Script,
|
|
1237
|
+
PlutusV2Script,
|
|
1238
|
+
PlutusV3Script,
|
|
1239
|
+
PolicyId,
|
|
1240
|
+
PoolId,
|
|
1241
|
+
PrivateKey,
|
|
1242
|
+
PublicKey,
|
|
1243
|
+
Redeemer,
|
|
1244
|
+
RedeemerPurpose,
|
|
1245
|
+
RedeemerTag,
|
|
1246
|
+
Redeemers,
|
|
1247
|
+
RequireAllOf,
|
|
1248
|
+
RequireAnyOf,
|
|
1249
|
+
RequireNOf,
|
|
1250
|
+
RequireSignature,
|
|
1251
|
+
RequireTimeAfter,
|
|
1252
|
+
RequireTimeBefore,
|
|
1253
|
+
RewardAccount,
|
|
1254
|
+
RewardAddress,
|
|
1255
|
+
Script,
|
|
1256
|
+
ScriptHash,
|
|
1257
|
+
ScriptPubkey,
|
|
1258
|
+
Serialization5 as Serialization,
|
|
1259
|
+
Slot,
|
|
1260
|
+
StakeDelegation,
|
|
1261
|
+
StakeRegistration,
|
|
1262
|
+
Transaction,
|
|
1263
|
+
TransactionBody,
|
|
1264
|
+
TransactionId,
|
|
1265
|
+
TransactionInput,
|
|
1266
|
+
TransactionOutput,
|
|
1267
|
+
TransactionUnspentOutput,
|
|
1268
|
+
TransactionWitnessSet,
|
|
1269
|
+
Value,
|
|
1270
|
+
VkeyWitness,
|
|
1271
|
+
VrfVkBech32,
|
|
1272
|
+
addressToBech32,
|
|
1273
|
+
assetTypes,
|
|
1274
|
+
buildBaseAddress,
|
|
1275
|
+
buildBip32PrivateKey,
|
|
1276
|
+
buildEnterpriseAddress,
|
|
1277
|
+
buildKeys,
|
|
1278
|
+
buildRewardAddress,
|
|
1279
|
+
buildScriptPubkey,
|
|
1280
|
+
checkSignature,
|
|
1281
|
+
deserializeAddress,
|
|
1282
|
+
deserializeDataHash,
|
|
1283
|
+
deserializeEd25519KeyHash,
|
|
1284
|
+
deserializeNativeScript,
|
|
1285
|
+
deserializePlutusData,
|
|
1286
|
+
deserializePlutusScript,
|
|
1287
|
+
deserializeScriptHash,
|
|
1288
|
+
deserializeScriptRef,
|
|
1289
|
+
deserializeTx,
|
|
1290
|
+
deserializeTxHash,
|
|
1291
|
+
deserializeTxUnspentOutput,
|
|
1292
|
+
deserializeValue,
|
|
1293
|
+
empty,
|
|
1294
|
+
fromNativeScript,
|
|
1295
|
+
fromScriptRef,
|
|
1296
|
+
fromTxUnspentOutput,
|
|
1297
|
+
fromValue,
|
|
1298
|
+
mergeValue,
|
|
1299
|
+
negateValue,
|
|
1300
|
+
negatives,
|
|
1301
|
+
resolveDataHash,
|
|
1302
|
+
resolveNativeScriptAddress,
|
|
1303
|
+
resolveNativeScriptHash,
|
|
1304
|
+
resolvePaymentKeyHash,
|
|
1305
|
+
resolvePlutusScriptAddress,
|
|
1306
|
+
resolvePlutusScriptHash,
|
|
1307
|
+
resolvePoolId,
|
|
1308
|
+
resolvePrivateKey,
|
|
1309
|
+
resolveRewardAddress,
|
|
1310
|
+
resolveScriptRef,
|
|
1311
|
+
resolveStakeKeyHash,
|
|
1312
|
+
resolveTxHash,
|
|
1313
|
+
signData,
|
|
1314
|
+
subValue,
|
|
1315
|
+
toAddress,
|
|
1316
|
+
toBaseAddress,
|
|
1317
|
+
toEnterpriseAddress,
|
|
1318
|
+
toNativeScript,
|
|
1319
|
+
toPlutusData,
|
|
1320
|
+
toRewardAddress,
|
|
1321
|
+
toScriptRef,
|
|
1322
|
+
toTxUnspentOutput,
|
|
1323
|
+
toValue
|
|
1324
|
+
};
|