@meshsdk/core-cst 1.9.0-beta.17 → 1.9.0-beta.18
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 +96 -91
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +95 -91
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3600,6 +3600,7 @@ __export(index_exports, {
|
|
|
3600
3600
|
buildRewardAddress: () => buildRewardAddress,
|
|
3601
3601
|
buildScriptPubkey: () => buildScriptPubkey,
|
|
3602
3602
|
bytesToHex: () => bytesToHex,
|
|
3603
|
+
calculateFees: () => calculateFees,
|
|
3603
3604
|
checkSignature: () => checkSignature,
|
|
3604
3605
|
clampScalar: () => clampScalar,
|
|
3605
3606
|
computeAuxiliaryDataHash: () => computeAuxiliaryDataHash,
|
|
@@ -5170,6 +5171,54 @@ var addVKeyWitnessSetToTransaction = (txHex, vkeyWitnessSet) => {
|
|
|
5170
5171
|
return tx.toCbor();
|
|
5171
5172
|
};
|
|
5172
5173
|
|
|
5174
|
+
// src/utils/fee.ts
|
|
5175
|
+
var calculateFees = (minFeeA, minFeeB, minFeeRefScriptCostPerByte, priceMem, priceStep, tx, refScriptSize) => {
|
|
5176
|
+
let fee = minFeeB + tx.toCbor().length / 2 * minFeeA;
|
|
5177
|
+
fee += calculateRefScriptFees(refScriptSize, minFeeRefScriptCostPerByte);
|
|
5178
|
+
let scriptFee = BigInt(0);
|
|
5179
|
+
let priceMemNumerator = priceMem;
|
|
5180
|
+
let priceMemDenominator = 1;
|
|
5181
|
+
while (priceMemNumerator % 1) {
|
|
5182
|
+
priceMemNumerator *= 10;
|
|
5183
|
+
priceMemDenominator *= 10;
|
|
5184
|
+
}
|
|
5185
|
+
let priceStepNumerator = priceStep;
|
|
5186
|
+
let priceStepDenominator = 1;
|
|
5187
|
+
while (priceStepNumerator % 1) {
|
|
5188
|
+
priceStepNumerator *= 10;
|
|
5189
|
+
priceStepDenominator *= 10;
|
|
5190
|
+
}
|
|
5191
|
+
if (tx.witnessSet().redeemers()) {
|
|
5192
|
+
for (const redeemer of tx.witnessSet().redeemers().values()) {
|
|
5193
|
+
scriptFee += redeemer.exUnits().mem() * BigInt(priceMemNumerator.toString()) / BigInt(priceMemDenominator.toString());
|
|
5194
|
+
scriptFee += redeemer.exUnits().steps() * BigInt(priceStepNumerator.toString()) / BigInt(priceStepDenominator.toString());
|
|
5195
|
+
if (priceMemNumerator % priceMemDenominator !== 0) {
|
|
5196
|
+
scriptFee += BigInt(1);
|
|
5197
|
+
}
|
|
5198
|
+
if (priceStepNumerator % priceStepDenominator !== 0) {
|
|
5199
|
+
scriptFee += BigInt(1);
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5202
|
+
}
|
|
5203
|
+
return BigInt(fee) + scriptFee;
|
|
5204
|
+
};
|
|
5205
|
+
var calculateRefScriptFees = (refScriptSize, minFeeRefScriptCostPerByte, tierMultiplier = 1.2) => {
|
|
5206
|
+
let fee = 0;
|
|
5207
|
+
const tierSize = 25600;
|
|
5208
|
+
let currentRefScriptSize = refScriptSize;
|
|
5209
|
+
let multiplier = 1;
|
|
5210
|
+
while (currentRefScriptSize >= tierSize) {
|
|
5211
|
+
fee += tierSize * multiplier * minFeeRefScriptCostPerByte;
|
|
5212
|
+
currentRefScriptSize -= tierSize;
|
|
5213
|
+
multiplier *= tierMultiplier;
|
|
5214
|
+
}
|
|
5215
|
+
if (currentRefScriptSize > 0) {
|
|
5216
|
+
fee += currentRefScriptSize * multiplier * minFeeRefScriptCostPerByte;
|
|
5217
|
+
}
|
|
5218
|
+
fee = Math.ceil(fee);
|
|
5219
|
+
return fee;
|
|
5220
|
+
};
|
|
5221
|
+
|
|
5173
5222
|
// src/resolvers/index.ts
|
|
5174
5223
|
var resolveDataHash = (data) => {
|
|
5175
5224
|
const plutusData = toPlutusData(data);
|
|
@@ -5401,7 +5450,7 @@ var toCardanoCert = (cert) => {
|
|
|
5401
5450
|
return Certificate.newStakeDelegation(
|
|
5402
5451
|
new import_core5.Serialization.StakeDelegation(
|
|
5403
5452
|
rewardAddress.getPaymentCredential(),
|
|
5404
|
-
Ed25519KeyHashHex2(cert.poolId)
|
|
5453
|
+
cert.poolId.startsWith("pool1") ? import_core5.Cardano.PoolId.toKeyHash(import_core5.Cardano.PoolId(cert.poolId)) : Ed25519KeyHashHex2(cert.poolId)
|
|
5405
5454
|
)
|
|
5406
5455
|
);
|
|
5407
5456
|
}
|
|
@@ -5423,7 +5472,7 @@ var toCardanoCert = (cert) => {
|
|
|
5423
5472
|
case "RetirePool": {
|
|
5424
5473
|
return Certificate.newPoolRetirement(
|
|
5425
5474
|
new import_core5.Serialization.PoolRetirement(
|
|
5426
|
-
Ed25519KeyHashHex2(cert.poolId),
|
|
5475
|
+
cert.poolId.startsWith("pool1") ? import_core5.Cardano.PoolId.toKeyHash(import_core5.Cardano.PoolId(cert.poolId)) : Ed25519KeyHashHex2(cert.poolId),
|
|
5427
5476
|
import_core5.Cardano.EpochNo(cert.epoch)
|
|
5428
5477
|
)
|
|
5429
5478
|
);
|
|
@@ -5676,54 +5725,6 @@ var toCardanoCert = (cert) => {
|
|
|
5676
5725
|
}
|
|
5677
5726
|
};
|
|
5678
5727
|
|
|
5679
|
-
// src/utils/fee.ts
|
|
5680
|
-
var calculateFees = (minFeeA, minFeeB, minFeeRefScriptCostPerByte, priceMem, priceStep, tx, refScriptSize) => {
|
|
5681
|
-
let fee = minFeeB + tx.toCbor().length / 2 * minFeeA;
|
|
5682
|
-
fee += calculateRefScriptFees(refScriptSize, minFeeRefScriptCostPerByte);
|
|
5683
|
-
let scriptFee = BigInt(0);
|
|
5684
|
-
let priceMemNumerator = priceMem;
|
|
5685
|
-
let priceMemDenominator = 1;
|
|
5686
|
-
while (priceMemNumerator % 1) {
|
|
5687
|
-
priceMemNumerator *= 10;
|
|
5688
|
-
priceMemDenominator *= 10;
|
|
5689
|
-
}
|
|
5690
|
-
let priceStepNumerator = priceStep;
|
|
5691
|
-
let priceStepDenominator = 1;
|
|
5692
|
-
while (priceStepNumerator % 1) {
|
|
5693
|
-
priceStepNumerator *= 10;
|
|
5694
|
-
priceStepDenominator *= 10;
|
|
5695
|
-
}
|
|
5696
|
-
if (tx.witnessSet().redeemers()) {
|
|
5697
|
-
for (const redeemer of tx.witnessSet().redeemers().values()) {
|
|
5698
|
-
scriptFee += redeemer.exUnits().mem() * BigInt(priceMemNumerator.toString()) / BigInt(priceMemDenominator.toString());
|
|
5699
|
-
scriptFee += redeemer.exUnits().steps() * BigInt(priceStepNumerator.toString()) / BigInt(priceStepDenominator.toString());
|
|
5700
|
-
if (priceMemNumerator % priceMemDenominator !== 0) {
|
|
5701
|
-
scriptFee += BigInt(1);
|
|
5702
|
-
}
|
|
5703
|
-
if (priceStepNumerator % priceStepDenominator !== 0) {
|
|
5704
|
-
scriptFee += BigInt(1);
|
|
5705
|
-
}
|
|
5706
|
-
}
|
|
5707
|
-
}
|
|
5708
|
-
return BigInt(fee) + scriptFee;
|
|
5709
|
-
};
|
|
5710
|
-
var calculateRefScriptFees = (refScriptSize, minFeeRefScriptCostPerByte, tierMultiplier = 1.2) => {
|
|
5711
|
-
let fee = 0;
|
|
5712
|
-
const tierSize = 25600;
|
|
5713
|
-
let currentRefScriptSize = refScriptSize;
|
|
5714
|
-
let multiplier = 1;
|
|
5715
|
-
while (currentRefScriptSize >= tierSize) {
|
|
5716
|
-
fee += tierSize * multiplier * minFeeRefScriptCostPerByte;
|
|
5717
|
-
currentRefScriptSize -= tierSize;
|
|
5718
|
-
multiplier *= tierMultiplier;
|
|
5719
|
-
}
|
|
5720
|
-
if (currentRefScriptSize > 0) {
|
|
5721
|
-
fee += currentRefScriptSize * multiplier * minFeeRefScriptCostPerByte;
|
|
5722
|
-
}
|
|
5723
|
-
fee = Math.ceil(fee);
|
|
5724
|
-
return fee;
|
|
5725
|
-
};
|
|
5726
|
-
|
|
5727
5728
|
// src/utils/metadata.ts
|
|
5728
5729
|
var toCardanoMetadataMap = (metadata) => {
|
|
5729
5730
|
let cardanoMetadataMap = /* @__PURE__ */ new Map();
|
|
@@ -6207,6 +6208,10 @@ var CardanoSDKSerializerCore = class {
|
|
|
6207
6208
|
withdrawals,
|
|
6208
6209
|
votes
|
|
6209
6210
|
} = txBuilderBody;
|
|
6211
|
+
const uniqueRefInputs = this.removeBodyInputRefInputOverlap(
|
|
6212
|
+
inputs,
|
|
6213
|
+
referenceInputs
|
|
6214
|
+
);
|
|
6210
6215
|
this.addAllInputs(inputs);
|
|
6211
6216
|
this.sanitizeOutputs(outputs);
|
|
6212
6217
|
this.addAllOutputs(outputs);
|
|
@@ -6215,7 +6220,7 @@ var CardanoSDKSerializerCore = class {
|
|
|
6215
6220
|
this.addAllWithdrawals(withdrawals);
|
|
6216
6221
|
this.addAllVotes(votes);
|
|
6217
6222
|
this.addAllCollateralInputs(collaterals);
|
|
6218
|
-
this.addAllReferenceInputs(
|
|
6223
|
+
this.addAllReferenceInputs(uniqueRefInputs);
|
|
6219
6224
|
this.removeInputRefInputOverlap();
|
|
6220
6225
|
this.setValidityInterval(validityRange);
|
|
6221
6226
|
this.addAllRequiredSignatures(requiredSignatures);
|
|
@@ -6334,16 +6339,10 @@ var CardanoSDKSerializerCore = class {
|
|
|
6334
6339
|
fromBuilderToPlutusData(currentTxIn.scriptTxIn.datumSource.data)
|
|
6335
6340
|
);
|
|
6336
6341
|
} else if (currentTxIn.scriptTxIn.datumSource.type === "Inline") {
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
TransactionId(currentTxIn.txIn.txHash),
|
|
6342
|
-
BigInt(currentTxIn.txIn.txIndex)
|
|
6343
|
-
)
|
|
6344
|
-
);
|
|
6345
|
-
referenceInputs.setValues(referenceInputsList);
|
|
6346
|
-
this.txBody.setReferenceInputs(referenceInputs);
|
|
6342
|
+
this.addReferenceInput({
|
|
6343
|
+
txHash: currentTxIn.txIn.txHash,
|
|
6344
|
+
txIndex: currentTxIn.txIn.txIndex
|
|
6345
|
+
});
|
|
6347
6346
|
}
|
|
6348
6347
|
let exUnits = currentTxIn.scriptTxIn.redeemer.exUnits;
|
|
6349
6348
|
let redeemers = this.txWitnessSet.redeemers() ?? Redeemers.fromCore([]);
|
|
@@ -6451,6 +6450,10 @@ var CardanoSDKSerializerCore = class {
|
|
|
6451
6450
|
addReferenceInput = (refInput) => {
|
|
6452
6451
|
let referenceInputs = this.txBody.referenceInputs() ?? import_core8.Serialization.CborSet.fromCore([], TransactionInput.fromCore);
|
|
6453
6452
|
let referenceInputsList = [...referenceInputs.values()];
|
|
6453
|
+
if (referenceInputsList.some(
|
|
6454
|
+
(input) => input.transactionId().toString() === refInput.txHash && input.index().toString() === refInput.txIndex.toString()
|
|
6455
|
+
))
|
|
6456
|
+
return;
|
|
6454
6457
|
referenceInputsList.push(
|
|
6455
6458
|
new TransactionInput(
|
|
6456
6459
|
TransactionId(refInput.txHash),
|
|
@@ -6458,6 +6461,9 @@ var CardanoSDKSerializerCore = class {
|
|
|
6458
6461
|
)
|
|
6459
6462
|
);
|
|
6460
6463
|
referenceInputs.setValues(referenceInputsList);
|
|
6464
|
+
if (refInput.scriptSize) {
|
|
6465
|
+
this.refScriptSize += refInput.scriptSize;
|
|
6466
|
+
}
|
|
6461
6467
|
this.txBody.setReferenceInputs(referenceInputs);
|
|
6462
6468
|
};
|
|
6463
6469
|
addAllMints = (mints) => {
|
|
@@ -6835,6 +6841,18 @@ var CardanoSDKSerializerCore = class {
|
|
|
6835
6841
|
);
|
|
6836
6842
|
}
|
|
6837
6843
|
};
|
|
6844
|
+
removeBodyInputRefInputOverlap = (inputs, refInputs) => {
|
|
6845
|
+
let finalRefInputs = [];
|
|
6846
|
+
for (let i = 0; i < refInputs.length; i++) {
|
|
6847
|
+
let refInput = refInputs[i];
|
|
6848
|
+
if (!inputs.some(
|
|
6849
|
+
(input) => input.txIn.txHash === refInput.txHash && input.txIn.txIndex === refInput.txIndex
|
|
6850
|
+
)) {
|
|
6851
|
+
finalRefInputs.push(refInput);
|
|
6852
|
+
}
|
|
6853
|
+
}
|
|
6854
|
+
return finalRefInputs;
|
|
6855
|
+
};
|
|
6838
6856
|
balanceTx = (changeAddress) => {
|
|
6839
6857
|
if (changeAddress === "") {
|
|
6840
6858
|
throw new Error("Can't balance tx without a change address");
|
|
@@ -7024,16 +7042,16 @@ var CardanoSDKSerializerCore = class {
|
|
|
7024
7042
|
if (scriptSource.type !== "Inline") {
|
|
7025
7043
|
return;
|
|
7026
7044
|
}
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7045
|
+
if (!scriptSource.scriptSize) {
|
|
7046
|
+
throw new Error(
|
|
7047
|
+
"A reference script was used without providing its size, this must be provided as fee calculations are based on it"
|
|
7048
|
+
);
|
|
7049
|
+
}
|
|
7050
|
+
this.addReferenceInput({
|
|
7051
|
+
txHash: scriptSource.txHash,
|
|
7052
|
+
txIndex: scriptSource.txIndex,
|
|
7053
|
+
scriptSize: Number(scriptSource.scriptSize)
|
|
7054
|
+
});
|
|
7037
7055
|
switch (scriptSource.version) {
|
|
7038
7056
|
case "V1": {
|
|
7039
7057
|
this.usedLanguages[PlutusLanguageVersion.V1] = true;
|
|
@@ -7048,35 +7066,21 @@ var CardanoSDKSerializerCore = class {
|
|
|
7048
7066
|
break;
|
|
7049
7067
|
}
|
|
7050
7068
|
}
|
|
7051
|
-
if (scriptSource.scriptSize) {
|
|
7052
|
-
this.refScriptSize += Number(scriptSource.scriptSize);
|
|
7053
|
-
} else {
|
|
7054
|
-
throw new Error(
|
|
7055
|
-
"A reference script was used without providing its size, this must be provided as fee calculations are based on it"
|
|
7056
|
-
);
|
|
7057
|
-
}
|
|
7058
7069
|
};
|
|
7059
7070
|
addSimpleScriptRef = (simpleScriptSource) => {
|
|
7060
7071
|
if (simpleScriptSource.type !== "Inline") {
|
|
7061
7072
|
return;
|
|
7062
7073
|
}
|
|
7063
|
-
|
|
7064
|
-
let referenceInputsList = [...referenceInputs.values()];
|
|
7065
|
-
referenceInputsList.push(
|
|
7066
|
-
new TransactionInput(
|
|
7067
|
-
TransactionId(simpleScriptSource.txHash),
|
|
7068
|
-
BigInt(simpleScriptSource.txIndex)
|
|
7069
|
-
)
|
|
7070
|
-
);
|
|
7071
|
-
if (simpleScriptSource.scriptSize) {
|
|
7072
|
-
this.refScriptSize += Number(simpleScriptSource.scriptSize);
|
|
7073
|
-
} else {
|
|
7074
|
+
if (!simpleScriptSource.scriptSize) {
|
|
7074
7075
|
throw new Error(
|
|
7075
7076
|
"A reference script was used without providing its size, this must be provided as fee calculations are based on it"
|
|
7076
7077
|
);
|
|
7077
7078
|
}
|
|
7078
|
-
|
|
7079
|
-
|
|
7079
|
+
this.addReferenceInput({
|
|
7080
|
+
txHash: simpleScriptSource.txHash,
|
|
7081
|
+
txIndex: simpleScriptSource.txIndex,
|
|
7082
|
+
scriptSize: Number(simpleScriptSource.scriptSize)
|
|
7083
|
+
});
|
|
7080
7084
|
};
|
|
7081
7085
|
countNumberOfRequiredWitnesses() {
|
|
7082
7086
|
let requiredWitnesses = /* @__PURE__ */ new Set();
|
|
@@ -7608,6 +7612,7 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
|
|
|
7608
7612
|
buildRewardAddress,
|
|
7609
7613
|
buildScriptPubkey,
|
|
7610
7614
|
bytesToHex,
|
|
7615
|
+
calculateFees,
|
|
7611
7616
|
checkSignature,
|
|
7612
7617
|
clampScalar,
|
|
7613
7618
|
computeAuxiliaryDataHash,
|
package/dist/index.d.cts
CHANGED
|
@@ -406,6 +406,8 @@ declare const hexToBech32: (prefix: string, hex: string) => string;
|
|
|
406
406
|
|
|
407
407
|
declare const addVKeyWitnessSetToTransaction: (txHex: string, vkeyWitnessSet: string) => string;
|
|
408
408
|
|
|
409
|
+
declare const calculateFees: (minFeeA: number, minFeeB: number, minFeeRefScriptCostPerByte: number, priceMem: number, priceStep: number, tx: Transaction, refScriptSize: number) => bigint;
|
|
410
|
+
|
|
409
411
|
/**
|
|
410
412
|
* MIT License
|
|
411
413
|
*
|
|
@@ -451,4 +453,4 @@ declare const normalizePlutusScript: (plutusScript: string, encoding: OutputEnco
|
|
|
451
453
|
declare const applyEncoding: (plutusScript: Uint8Array, outputEncoding: OutputEncoding) => Uint8Array;
|
|
452
454
|
declare const applyParamsToScript: (rawScript: string, params: object[] | Data[], type?: PlutusDataType) => string;
|
|
453
455
|
|
|
454
|
-
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, type AuxiliaryData, AuxilliaryData, BaseAddress, Bip32PrivateKey, Bip32PrivateKeyHex, Bip32PublicKey, Bip32PublicKeyHex, CardanoSDKSerializer, CborSet, CborWriter, CertIndex, Certificate, CertificateType, ConstrPlutusData, CoseSign1, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, DRep, DRepID, Datum, DatumHash, DatumKind, Ed25519KeyHash, Ed25519KeyHashHex, Ed25519PrivateExtendedKeyHex, Ed25519PrivateKey, Ed25519PrivateNormalKeyHex, Ed25519PublicKey, Ed25519PublicKeyHex, Ed25519Signature, Ed25519SignatureHex, EnterpriseAddress, ExUnits, Hash, Hash28ByteBase16, Hash32ByteBase16, HexBlob, type Metadatum, MetadatumList, MetadatumMap, NativeScript, NetworkId, type OutputEncoding, PaymentAddress, PlutusData, PlutusDataKind, PlutusLanguageVersion, PlutusList, PlutusMap, PlutusV1Script, PlutusV2Script, PlutusV3Script, PointerAddress, PolicyId, PoolId, Redeemer, RedeemerPurpose, RedeemerTag, Redeemers, RequireAllOf, RequireAnyOf, RequireNOf, RequireSignature, RequireTimeAfter, RequireTimeBefore, RewardAccount, RewardAddress, Script, ScriptHash, ScriptPubkey, type Signatures, type Signer, Slot, StakeCredentialStatus, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, type TokenMap, Transaction, TransactionBody, TransactionId, TransactionInput, type TransactionInputSet, TransactionMetadatum, TransactionOutput, TransactionUnspentOutput, type TransactionWitnessPlutusData, TransactionWitnessSet, TxCBOR, TxIndex, Value, VkeyWitness, VrfVkBech32, type Witness, addVKeyWitnessSetToTransaction, addrBech32ToPlutusDataHex, addrBech32ToPlutusDataObj, addressToBech32, applyEncoding, applyParamsToScript, assetTypes, blake2b, buildBaseAddress, buildBip32PrivateKey, buildDRepID, buildEd25519PrivateKeyFromSecretKey, buildEnterpriseAddress, buildKeys, buildRewardAddress, buildScriptPubkey, bytesToHex, checkSignature, clampScalar, computeAuxiliaryDataHash, deserializeAddress, deserializeBech32Address, deserializeDataHash, deserializeEd25519KeyHash, deserializeNativeScript, deserializePlutusData, deserializePlutusScript, deserializeScriptHash, deserializeScriptRef, deserializeTx, deserializeTxHash, deserializeTxUnspentOutput, deserializeValue, empty, fromBuilderToPlutusData, fromJsonToPlutusData, fromNativeScript, fromPlutusDataToJson, fromScriptRef, fromTxUnspentOutput, fromValue, generateNonce, getCoseKeyFromPublicKey, getDRepIds, getPublicKeyFromCoseKey, hexToBech32, hexToBytes, keyHashToRewardAddress, mergeValue, negateValue, negatives, normalizePlutusScript, parseDatumCbor, parseInlineDatum, resolveDataHash, resolveEd25519KeyHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolvePaymentKeyHash, resolvePlutusScriptAddress, resolvePlutusScriptHash, resolvePoolId, resolvePrivateKey, resolveRewardAddress, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, resolveTxHash, scriptHashToBech32, scriptHashToRewardAddress, serializeAddressObj, serializePlutusAddressToBech32, serialzeAddress, signData, subValue, toAddress, toBaseAddress, toCardanoAddress, toDRep, toEnterpriseAddress, toNativeScript, toPlutusData, toRewardAddress, toScriptRef, toTxUnspentOutput, toValue, utf8ToBytes, utf8ToHex, v2ScriptToBech32 };
|
|
456
|
+
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, type AuxiliaryData, AuxilliaryData, BaseAddress, Bip32PrivateKey, Bip32PrivateKeyHex, Bip32PublicKey, Bip32PublicKeyHex, CardanoSDKSerializer, CborSet, CborWriter, CertIndex, Certificate, CertificateType, ConstrPlutusData, CoseSign1, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, DRep, DRepID, Datum, DatumHash, DatumKind, Ed25519KeyHash, Ed25519KeyHashHex, Ed25519PrivateExtendedKeyHex, Ed25519PrivateKey, Ed25519PrivateNormalKeyHex, Ed25519PublicKey, Ed25519PublicKeyHex, Ed25519Signature, Ed25519SignatureHex, EnterpriseAddress, ExUnits, Hash, Hash28ByteBase16, Hash32ByteBase16, HexBlob, type Metadatum, MetadatumList, MetadatumMap, NativeScript, NetworkId, type OutputEncoding, PaymentAddress, PlutusData, PlutusDataKind, PlutusLanguageVersion, PlutusList, PlutusMap, PlutusV1Script, PlutusV2Script, PlutusV3Script, PointerAddress, PolicyId, PoolId, Redeemer, RedeemerPurpose, RedeemerTag, Redeemers, RequireAllOf, RequireAnyOf, RequireNOf, RequireSignature, RequireTimeAfter, RequireTimeBefore, RewardAccount, RewardAddress, Script, ScriptHash, ScriptPubkey, type Signatures, type Signer, Slot, StakeCredentialStatus, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, type TokenMap, Transaction, TransactionBody, TransactionId, TransactionInput, type TransactionInputSet, TransactionMetadatum, TransactionOutput, TransactionUnspentOutput, type TransactionWitnessPlutusData, TransactionWitnessSet, TxCBOR, TxIndex, Value, VkeyWitness, VrfVkBech32, type Witness, addVKeyWitnessSetToTransaction, addrBech32ToPlutusDataHex, addrBech32ToPlutusDataObj, addressToBech32, applyEncoding, applyParamsToScript, assetTypes, blake2b, buildBaseAddress, buildBip32PrivateKey, buildDRepID, buildEd25519PrivateKeyFromSecretKey, buildEnterpriseAddress, buildKeys, buildRewardAddress, buildScriptPubkey, bytesToHex, calculateFees, checkSignature, clampScalar, computeAuxiliaryDataHash, deserializeAddress, deserializeBech32Address, deserializeDataHash, deserializeEd25519KeyHash, deserializeNativeScript, deserializePlutusData, deserializePlutusScript, deserializeScriptHash, deserializeScriptRef, deserializeTx, deserializeTxHash, deserializeTxUnspentOutput, deserializeValue, empty, fromBuilderToPlutusData, fromJsonToPlutusData, fromNativeScript, fromPlutusDataToJson, fromScriptRef, fromTxUnspentOutput, fromValue, generateNonce, getCoseKeyFromPublicKey, getDRepIds, getPublicKeyFromCoseKey, hexToBech32, hexToBytes, keyHashToRewardAddress, mergeValue, negateValue, negatives, normalizePlutusScript, parseDatumCbor, parseInlineDatum, resolveDataHash, resolveEd25519KeyHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolvePaymentKeyHash, resolvePlutusScriptAddress, resolvePlutusScriptHash, resolvePoolId, resolvePrivateKey, resolveRewardAddress, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, resolveTxHash, scriptHashToBech32, scriptHashToRewardAddress, serializeAddressObj, serializePlutusAddressToBech32, serialzeAddress, signData, subValue, toAddress, toBaseAddress, toCardanoAddress, toDRep, toEnterpriseAddress, toNativeScript, toPlutusData, toRewardAddress, toScriptRef, toTxUnspentOutput, toValue, utf8ToBytes, utf8ToHex, v2ScriptToBech32 };
|
package/dist/index.d.ts
CHANGED
|
@@ -406,6 +406,8 @@ declare const hexToBech32: (prefix: string, hex: string) => string;
|
|
|
406
406
|
|
|
407
407
|
declare const addVKeyWitnessSetToTransaction: (txHex: string, vkeyWitnessSet: string) => string;
|
|
408
408
|
|
|
409
|
+
declare const calculateFees: (minFeeA: number, minFeeB: number, minFeeRefScriptCostPerByte: number, priceMem: number, priceStep: number, tx: Transaction, refScriptSize: number) => bigint;
|
|
410
|
+
|
|
409
411
|
/**
|
|
410
412
|
* MIT License
|
|
411
413
|
*
|
|
@@ -451,4 +453,4 @@ declare const normalizePlutusScript: (plutusScript: string, encoding: OutputEnco
|
|
|
451
453
|
declare const applyEncoding: (plutusScript: Uint8Array, outputEncoding: OutputEncoding) => Uint8Array;
|
|
452
454
|
declare const applyParamsToScript: (rawScript: string, params: object[] | Data[], type?: PlutusDataType) => string;
|
|
453
455
|
|
|
454
|
-
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, type AuxiliaryData, AuxilliaryData, BaseAddress, Bip32PrivateKey, Bip32PrivateKeyHex, Bip32PublicKey, Bip32PublicKeyHex, CardanoSDKSerializer, CborSet, CborWriter, CertIndex, Certificate, CertificateType, ConstrPlutusData, CoseSign1, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, DRep, DRepID, Datum, DatumHash, DatumKind, Ed25519KeyHash, Ed25519KeyHashHex, Ed25519PrivateExtendedKeyHex, Ed25519PrivateKey, Ed25519PrivateNormalKeyHex, Ed25519PublicKey, Ed25519PublicKeyHex, Ed25519Signature, Ed25519SignatureHex, EnterpriseAddress, ExUnits, Hash, Hash28ByteBase16, Hash32ByteBase16, HexBlob, type Metadatum, MetadatumList, MetadatumMap, NativeScript, NetworkId, type OutputEncoding, PaymentAddress, PlutusData, PlutusDataKind, PlutusLanguageVersion, PlutusList, PlutusMap, PlutusV1Script, PlutusV2Script, PlutusV3Script, PointerAddress, PolicyId, PoolId, Redeemer, RedeemerPurpose, RedeemerTag, Redeemers, RequireAllOf, RequireAnyOf, RequireNOf, RequireSignature, RequireTimeAfter, RequireTimeBefore, RewardAccount, RewardAddress, Script, ScriptHash, ScriptPubkey, type Signatures, type Signer, Slot, StakeCredentialStatus, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, type TokenMap, Transaction, TransactionBody, TransactionId, TransactionInput, type TransactionInputSet, TransactionMetadatum, TransactionOutput, TransactionUnspentOutput, type TransactionWitnessPlutusData, TransactionWitnessSet, TxCBOR, TxIndex, Value, VkeyWitness, VrfVkBech32, type Witness, addVKeyWitnessSetToTransaction, addrBech32ToPlutusDataHex, addrBech32ToPlutusDataObj, addressToBech32, applyEncoding, applyParamsToScript, assetTypes, blake2b, buildBaseAddress, buildBip32PrivateKey, buildDRepID, buildEd25519PrivateKeyFromSecretKey, buildEnterpriseAddress, buildKeys, buildRewardAddress, buildScriptPubkey, bytesToHex, checkSignature, clampScalar, computeAuxiliaryDataHash, deserializeAddress, deserializeBech32Address, deserializeDataHash, deserializeEd25519KeyHash, deserializeNativeScript, deserializePlutusData, deserializePlutusScript, deserializeScriptHash, deserializeScriptRef, deserializeTx, deserializeTxHash, deserializeTxUnspentOutput, deserializeValue, empty, fromBuilderToPlutusData, fromJsonToPlutusData, fromNativeScript, fromPlutusDataToJson, fromScriptRef, fromTxUnspentOutput, fromValue, generateNonce, getCoseKeyFromPublicKey, getDRepIds, getPublicKeyFromCoseKey, hexToBech32, hexToBytes, keyHashToRewardAddress, mergeValue, negateValue, negatives, normalizePlutusScript, parseDatumCbor, parseInlineDatum, resolveDataHash, resolveEd25519KeyHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolvePaymentKeyHash, resolvePlutusScriptAddress, resolvePlutusScriptHash, resolvePoolId, resolvePrivateKey, resolveRewardAddress, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, resolveTxHash, scriptHashToBech32, scriptHashToRewardAddress, serializeAddressObj, serializePlutusAddressToBech32, serialzeAddress, signData, subValue, toAddress, toBaseAddress, toCardanoAddress, toDRep, toEnterpriseAddress, toNativeScript, toPlutusData, toRewardAddress, toScriptRef, toTxUnspentOutput, toValue, utf8ToBytes, utf8ToHex, v2ScriptToBech32 };
|
|
456
|
+
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, type AuxiliaryData, AuxilliaryData, BaseAddress, Bip32PrivateKey, Bip32PrivateKeyHex, Bip32PublicKey, Bip32PublicKeyHex, CardanoSDKSerializer, CborSet, CborWriter, CertIndex, Certificate, CertificateType, ConstrPlutusData, CoseSign1, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, DRep, DRepID, Datum, DatumHash, DatumKind, Ed25519KeyHash, Ed25519KeyHashHex, Ed25519PrivateExtendedKeyHex, Ed25519PrivateKey, Ed25519PrivateNormalKeyHex, Ed25519PublicKey, Ed25519PublicKeyHex, Ed25519Signature, Ed25519SignatureHex, EnterpriseAddress, ExUnits, Hash, Hash28ByteBase16, Hash32ByteBase16, HexBlob, type Metadatum, MetadatumList, MetadatumMap, NativeScript, NetworkId, type OutputEncoding, PaymentAddress, PlutusData, PlutusDataKind, PlutusLanguageVersion, PlutusList, PlutusMap, PlutusV1Script, PlutusV2Script, PlutusV3Script, PointerAddress, PolicyId, PoolId, Redeemer, RedeemerPurpose, RedeemerTag, Redeemers, RequireAllOf, RequireAnyOf, RequireNOf, RequireSignature, RequireTimeAfter, RequireTimeBefore, RewardAccount, RewardAddress, Script, ScriptHash, ScriptPubkey, type Signatures, type Signer, Slot, StakeCredentialStatus, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, type TokenMap, Transaction, TransactionBody, TransactionId, TransactionInput, type TransactionInputSet, TransactionMetadatum, TransactionOutput, TransactionUnspentOutput, type TransactionWitnessPlutusData, TransactionWitnessSet, TxCBOR, TxIndex, Value, VkeyWitness, VrfVkBech32, type Witness, addVKeyWitnessSetToTransaction, addrBech32ToPlutusDataHex, addrBech32ToPlutusDataObj, addressToBech32, applyEncoding, applyParamsToScript, assetTypes, blake2b, buildBaseAddress, buildBip32PrivateKey, buildDRepID, buildEd25519PrivateKeyFromSecretKey, buildEnterpriseAddress, buildKeys, buildRewardAddress, buildScriptPubkey, bytesToHex, calculateFees, checkSignature, clampScalar, computeAuxiliaryDataHash, deserializeAddress, deserializeBech32Address, deserializeDataHash, deserializeEd25519KeyHash, deserializeNativeScript, deserializePlutusData, deserializePlutusScript, deserializeScriptHash, deserializeScriptRef, deserializeTx, deserializeTxHash, deserializeTxUnspentOutput, deserializeValue, empty, fromBuilderToPlutusData, fromJsonToPlutusData, fromNativeScript, fromPlutusDataToJson, fromScriptRef, fromTxUnspentOutput, fromValue, generateNonce, getCoseKeyFromPublicKey, getDRepIds, getPublicKeyFromCoseKey, hexToBech32, hexToBytes, keyHashToRewardAddress, mergeValue, negateValue, negatives, normalizePlutusScript, parseDatumCbor, parseInlineDatum, resolveDataHash, resolveEd25519KeyHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolvePaymentKeyHash, resolvePlutusScriptAddress, resolvePlutusScriptHash, resolvePoolId, resolvePrivateKey, resolveRewardAddress, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, resolveTxHash, scriptHashToBech32, scriptHashToRewardAddress, serializeAddressObj, serializePlutusAddressToBech32, serialzeAddress, signData, subValue, toAddress, toBaseAddress, toCardanoAddress, toDRep, toEnterpriseAddress, toNativeScript, toPlutusData, toRewardAddress, toScriptRef, toTxUnspentOutput, toValue, utf8ToBytes, utf8ToHex, v2ScriptToBech32 };
|
package/dist/index.js
CHANGED
|
@@ -5007,6 +5007,54 @@ var addVKeyWitnessSetToTransaction = (txHex, vkeyWitnessSet) => {
|
|
|
5007
5007
|
return tx.toCbor();
|
|
5008
5008
|
};
|
|
5009
5009
|
|
|
5010
|
+
// src/utils/fee.ts
|
|
5011
|
+
var calculateFees = (minFeeA, minFeeB, minFeeRefScriptCostPerByte, priceMem, priceStep, tx, refScriptSize) => {
|
|
5012
|
+
let fee = minFeeB + tx.toCbor().length / 2 * minFeeA;
|
|
5013
|
+
fee += calculateRefScriptFees(refScriptSize, minFeeRefScriptCostPerByte);
|
|
5014
|
+
let scriptFee = BigInt(0);
|
|
5015
|
+
let priceMemNumerator = priceMem;
|
|
5016
|
+
let priceMemDenominator = 1;
|
|
5017
|
+
while (priceMemNumerator % 1) {
|
|
5018
|
+
priceMemNumerator *= 10;
|
|
5019
|
+
priceMemDenominator *= 10;
|
|
5020
|
+
}
|
|
5021
|
+
let priceStepNumerator = priceStep;
|
|
5022
|
+
let priceStepDenominator = 1;
|
|
5023
|
+
while (priceStepNumerator % 1) {
|
|
5024
|
+
priceStepNumerator *= 10;
|
|
5025
|
+
priceStepDenominator *= 10;
|
|
5026
|
+
}
|
|
5027
|
+
if (tx.witnessSet().redeemers()) {
|
|
5028
|
+
for (const redeemer of tx.witnessSet().redeemers().values()) {
|
|
5029
|
+
scriptFee += redeemer.exUnits().mem() * BigInt(priceMemNumerator.toString()) / BigInt(priceMemDenominator.toString());
|
|
5030
|
+
scriptFee += redeemer.exUnits().steps() * BigInt(priceStepNumerator.toString()) / BigInt(priceStepDenominator.toString());
|
|
5031
|
+
if (priceMemNumerator % priceMemDenominator !== 0) {
|
|
5032
|
+
scriptFee += BigInt(1);
|
|
5033
|
+
}
|
|
5034
|
+
if (priceStepNumerator % priceStepDenominator !== 0) {
|
|
5035
|
+
scriptFee += BigInt(1);
|
|
5036
|
+
}
|
|
5037
|
+
}
|
|
5038
|
+
}
|
|
5039
|
+
return BigInt(fee) + scriptFee;
|
|
5040
|
+
};
|
|
5041
|
+
var calculateRefScriptFees = (refScriptSize, minFeeRefScriptCostPerByte, tierMultiplier = 1.2) => {
|
|
5042
|
+
let fee = 0;
|
|
5043
|
+
const tierSize = 25600;
|
|
5044
|
+
let currentRefScriptSize = refScriptSize;
|
|
5045
|
+
let multiplier = 1;
|
|
5046
|
+
while (currentRefScriptSize >= tierSize) {
|
|
5047
|
+
fee += tierSize * multiplier * minFeeRefScriptCostPerByte;
|
|
5048
|
+
currentRefScriptSize -= tierSize;
|
|
5049
|
+
multiplier *= tierMultiplier;
|
|
5050
|
+
}
|
|
5051
|
+
if (currentRefScriptSize > 0) {
|
|
5052
|
+
fee += currentRefScriptSize * multiplier * minFeeRefScriptCostPerByte;
|
|
5053
|
+
}
|
|
5054
|
+
fee = Math.ceil(fee);
|
|
5055
|
+
return fee;
|
|
5056
|
+
};
|
|
5057
|
+
|
|
5010
5058
|
// src/resolvers/index.ts
|
|
5011
5059
|
var resolveDataHash = (data) => {
|
|
5012
5060
|
const plutusData = toPlutusData(data);
|
|
@@ -5253,7 +5301,7 @@ var toCardanoCert = (cert) => {
|
|
|
5253
5301
|
return Certificate.newStakeDelegation(
|
|
5254
5302
|
new Serialization4.StakeDelegation(
|
|
5255
5303
|
rewardAddress.getPaymentCredential(),
|
|
5256
|
-
Ed25519KeyHashHex2(cert.poolId)
|
|
5304
|
+
cert.poolId.startsWith("pool1") ? Cardano3.PoolId.toKeyHash(Cardano3.PoolId(cert.poolId)) : Ed25519KeyHashHex2(cert.poolId)
|
|
5257
5305
|
)
|
|
5258
5306
|
);
|
|
5259
5307
|
}
|
|
@@ -5275,7 +5323,7 @@ var toCardanoCert = (cert) => {
|
|
|
5275
5323
|
case "RetirePool": {
|
|
5276
5324
|
return Certificate.newPoolRetirement(
|
|
5277
5325
|
new Serialization4.PoolRetirement(
|
|
5278
|
-
Ed25519KeyHashHex2(cert.poolId),
|
|
5326
|
+
cert.poolId.startsWith("pool1") ? Cardano3.PoolId.toKeyHash(Cardano3.PoolId(cert.poolId)) : Ed25519KeyHashHex2(cert.poolId),
|
|
5279
5327
|
Cardano3.EpochNo(cert.epoch)
|
|
5280
5328
|
)
|
|
5281
5329
|
);
|
|
@@ -5528,54 +5576,6 @@ var toCardanoCert = (cert) => {
|
|
|
5528
5576
|
}
|
|
5529
5577
|
};
|
|
5530
5578
|
|
|
5531
|
-
// src/utils/fee.ts
|
|
5532
|
-
var calculateFees = (minFeeA, minFeeB, minFeeRefScriptCostPerByte, priceMem, priceStep, tx, refScriptSize) => {
|
|
5533
|
-
let fee = minFeeB + tx.toCbor().length / 2 * minFeeA;
|
|
5534
|
-
fee += calculateRefScriptFees(refScriptSize, minFeeRefScriptCostPerByte);
|
|
5535
|
-
let scriptFee = BigInt(0);
|
|
5536
|
-
let priceMemNumerator = priceMem;
|
|
5537
|
-
let priceMemDenominator = 1;
|
|
5538
|
-
while (priceMemNumerator % 1) {
|
|
5539
|
-
priceMemNumerator *= 10;
|
|
5540
|
-
priceMemDenominator *= 10;
|
|
5541
|
-
}
|
|
5542
|
-
let priceStepNumerator = priceStep;
|
|
5543
|
-
let priceStepDenominator = 1;
|
|
5544
|
-
while (priceStepNumerator % 1) {
|
|
5545
|
-
priceStepNumerator *= 10;
|
|
5546
|
-
priceStepDenominator *= 10;
|
|
5547
|
-
}
|
|
5548
|
-
if (tx.witnessSet().redeemers()) {
|
|
5549
|
-
for (const redeemer of tx.witnessSet().redeemers().values()) {
|
|
5550
|
-
scriptFee += redeemer.exUnits().mem() * BigInt(priceMemNumerator.toString()) / BigInt(priceMemDenominator.toString());
|
|
5551
|
-
scriptFee += redeemer.exUnits().steps() * BigInt(priceStepNumerator.toString()) / BigInt(priceStepDenominator.toString());
|
|
5552
|
-
if (priceMemNumerator % priceMemDenominator !== 0) {
|
|
5553
|
-
scriptFee += BigInt(1);
|
|
5554
|
-
}
|
|
5555
|
-
if (priceStepNumerator % priceStepDenominator !== 0) {
|
|
5556
|
-
scriptFee += BigInt(1);
|
|
5557
|
-
}
|
|
5558
|
-
}
|
|
5559
|
-
}
|
|
5560
|
-
return BigInt(fee) + scriptFee;
|
|
5561
|
-
};
|
|
5562
|
-
var calculateRefScriptFees = (refScriptSize, minFeeRefScriptCostPerByte, tierMultiplier = 1.2) => {
|
|
5563
|
-
let fee = 0;
|
|
5564
|
-
const tierSize = 25600;
|
|
5565
|
-
let currentRefScriptSize = refScriptSize;
|
|
5566
|
-
let multiplier = 1;
|
|
5567
|
-
while (currentRefScriptSize >= tierSize) {
|
|
5568
|
-
fee += tierSize * multiplier * minFeeRefScriptCostPerByte;
|
|
5569
|
-
currentRefScriptSize -= tierSize;
|
|
5570
|
-
multiplier *= tierMultiplier;
|
|
5571
|
-
}
|
|
5572
|
-
if (currentRefScriptSize > 0) {
|
|
5573
|
-
fee += currentRefScriptSize * multiplier * minFeeRefScriptCostPerByte;
|
|
5574
|
-
}
|
|
5575
|
-
fee = Math.ceil(fee);
|
|
5576
|
-
return fee;
|
|
5577
|
-
};
|
|
5578
|
-
|
|
5579
5579
|
// src/utils/metadata.ts
|
|
5580
5580
|
var toCardanoMetadataMap = (metadata) => {
|
|
5581
5581
|
let cardanoMetadataMap = /* @__PURE__ */ new Map();
|
|
@@ -6059,6 +6059,10 @@ var CardanoSDKSerializerCore = class {
|
|
|
6059
6059
|
withdrawals,
|
|
6060
6060
|
votes
|
|
6061
6061
|
} = txBuilderBody;
|
|
6062
|
+
const uniqueRefInputs = this.removeBodyInputRefInputOverlap(
|
|
6063
|
+
inputs,
|
|
6064
|
+
referenceInputs
|
|
6065
|
+
);
|
|
6062
6066
|
this.addAllInputs(inputs);
|
|
6063
6067
|
this.sanitizeOutputs(outputs);
|
|
6064
6068
|
this.addAllOutputs(outputs);
|
|
@@ -6067,7 +6071,7 @@ var CardanoSDKSerializerCore = class {
|
|
|
6067
6071
|
this.addAllWithdrawals(withdrawals);
|
|
6068
6072
|
this.addAllVotes(votes);
|
|
6069
6073
|
this.addAllCollateralInputs(collaterals);
|
|
6070
|
-
this.addAllReferenceInputs(
|
|
6074
|
+
this.addAllReferenceInputs(uniqueRefInputs);
|
|
6071
6075
|
this.removeInputRefInputOverlap();
|
|
6072
6076
|
this.setValidityInterval(validityRange);
|
|
6073
6077
|
this.addAllRequiredSignatures(requiredSignatures);
|
|
@@ -6186,16 +6190,10 @@ var CardanoSDKSerializerCore = class {
|
|
|
6186
6190
|
fromBuilderToPlutusData(currentTxIn.scriptTxIn.datumSource.data)
|
|
6187
6191
|
);
|
|
6188
6192
|
} else if (currentTxIn.scriptTxIn.datumSource.type === "Inline") {
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
TransactionId(currentTxIn.txIn.txHash),
|
|
6194
|
-
BigInt(currentTxIn.txIn.txIndex)
|
|
6195
|
-
)
|
|
6196
|
-
);
|
|
6197
|
-
referenceInputs.setValues(referenceInputsList);
|
|
6198
|
-
this.txBody.setReferenceInputs(referenceInputs);
|
|
6193
|
+
this.addReferenceInput({
|
|
6194
|
+
txHash: currentTxIn.txIn.txHash,
|
|
6195
|
+
txIndex: currentTxIn.txIn.txIndex
|
|
6196
|
+
});
|
|
6199
6197
|
}
|
|
6200
6198
|
let exUnits = currentTxIn.scriptTxIn.redeemer.exUnits;
|
|
6201
6199
|
let redeemers = this.txWitnessSet.redeemers() ?? Redeemers.fromCore([]);
|
|
@@ -6303,6 +6301,10 @@ var CardanoSDKSerializerCore = class {
|
|
|
6303
6301
|
addReferenceInput = (refInput) => {
|
|
6304
6302
|
let referenceInputs = this.txBody.referenceInputs() ?? Serialization7.CborSet.fromCore([], TransactionInput.fromCore);
|
|
6305
6303
|
let referenceInputsList = [...referenceInputs.values()];
|
|
6304
|
+
if (referenceInputsList.some(
|
|
6305
|
+
(input) => input.transactionId().toString() === refInput.txHash && input.index().toString() === refInput.txIndex.toString()
|
|
6306
|
+
))
|
|
6307
|
+
return;
|
|
6306
6308
|
referenceInputsList.push(
|
|
6307
6309
|
new TransactionInput(
|
|
6308
6310
|
TransactionId(refInput.txHash),
|
|
@@ -6310,6 +6312,9 @@ var CardanoSDKSerializerCore = class {
|
|
|
6310
6312
|
)
|
|
6311
6313
|
);
|
|
6312
6314
|
referenceInputs.setValues(referenceInputsList);
|
|
6315
|
+
if (refInput.scriptSize) {
|
|
6316
|
+
this.refScriptSize += refInput.scriptSize;
|
|
6317
|
+
}
|
|
6313
6318
|
this.txBody.setReferenceInputs(referenceInputs);
|
|
6314
6319
|
};
|
|
6315
6320
|
addAllMints = (mints) => {
|
|
@@ -6687,6 +6692,18 @@ var CardanoSDKSerializerCore = class {
|
|
|
6687
6692
|
);
|
|
6688
6693
|
}
|
|
6689
6694
|
};
|
|
6695
|
+
removeBodyInputRefInputOverlap = (inputs, refInputs) => {
|
|
6696
|
+
let finalRefInputs = [];
|
|
6697
|
+
for (let i = 0; i < refInputs.length; i++) {
|
|
6698
|
+
let refInput = refInputs[i];
|
|
6699
|
+
if (!inputs.some(
|
|
6700
|
+
(input) => input.txIn.txHash === refInput.txHash && input.txIn.txIndex === refInput.txIndex
|
|
6701
|
+
)) {
|
|
6702
|
+
finalRefInputs.push(refInput);
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6705
|
+
return finalRefInputs;
|
|
6706
|
+
};
|
|
6690
6707
|
balanceTx = (changeAddress) => {
|
|
6691
6708
|
if (changeAddress === "") {
|
|
6692
6709
|
throw new Error("Can't balance tx without a change address");
|
|
@@ -6876,16 +6893,16 @@ var CardanoSDKSerializerCore = class {
|
|
|
6876
6893
|
if (scriptSource.type !== "Inline") {
|
|
6877
6894
|
return;
|
|
6878
6895
|
}
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6896
|
+
if (!scriptSource.scriptSize) {
|
|
6897
|
+
throw new Error(
|
|
6898
|
+
"A reference script was used without providing its size, this must be provided as fee calculations are based on it"
|
|
6899
|
+
);
|
|
6900
|
+
}
|
|
6901
|
+
this.addReferenceInput({
|
|
6902
|
+
txHash: scriptSource.txHash,
|
|
6903
|
+
txIndex: scriptSource.txIndex,
|
|
6904
|
+
scriptSize: Number(scriptSource.scriptSize)
|
|
6905
|
+
});
|
|
6889
6906
|
switch (scriptSource.version) {
|
|
6890
6907
|
case "V1": {
|
|
6891
6908
|
this.usedLanguages[PlutusLanguageVersion.V1] = true;
|
|
@@ -6900,35 +6917,21 @@ var CardanoSDKSerializerCore = class {
|
|
|
6900
6917
|
break;
|
|
6901
6918
|
}
|
|
6902
6919
|
}
|
|
6903
|
-
if (scriptSource.scriptSize) {
|
|
6904
|
-
this.refScriptSize += Number(scriptSource.scriptSize);
|
|
6905
|
-
} else {
|
|
6906
|
-
throw new Error(
|
|
6907
|
-
"A reference script was used without providing its size, this must be provided as fee calculations are based on it"
|
|
6908
|
-
);
|
|
6909
|
-
}
|
|
6910
6920
|
};
|
|
6911
6921
|
addSimpleScriptRef = (simpleScriptSource) => {
|
|
6912
6922
|
if (simpleScriptSource.type !== "Inline") {
|
|
6913
6923
|
return;
|
|
6914
6924
|
}
|
|
6915
|
-
|
|
6916
|
-
let referenceInputsList = [...referenceInputs.values()];
|
|
6917
|
-
referenceInputsList.push(
|
|
6918
|
-
new TransactionInput(
|
|
6919
|
-
TransactionId(simpleScriptSource.txHash),
|
|
6920
|
-
BigInt(simpleScriptSource.txIndex)
|
|
6921
|
-
)
|
|
6922
|
-
);
|
|
6923
|
-
if (simpleScriptSource.scriptSize) {
|
|
6924
|
-
this.refScriptSize += Number(simpleScriptSource.scriptSize);
|
|
6925
|
-
} else {
|
|
6925
|
+
if (!simpleScriptSource.scriptSize) {
|
|
6926
6926
|
throw new Error(
|
|
6927
6927
|
"A reference script was used without providing its size, this must be provided as fee calculations are based on it"
|
|
6928
6928
|
);
|
|
6929
6929
|
}
|
|
6930
|
-
|
|
6931
|
-
|
|
6930
|
+
this.addReferenceInput({
|
|
6931
|
+
txHash: simpleScriptSource.txHash,
|
|
6932
|
+
txIndex: simpleScriptSource.txIndex,
|
|
6933
|
+
scriptSize: Number(simpleScriptSource.scriptSize)
|
|
6934
|
+
});
|
|
6932
6935
|
};
|
|
6933
6936
|
countNumberOfRequiredWitnesses() {
|
|
6934
6937
|
let requiredWitnesses = /* @__PURE__ */ new Set();
|
|
@@ -7465,6 +7468,7 @@ export {
|
|
|
7465
7468
|
buildRewardAddress,
|
|
7466
7469
|
buildScriptPubkey,
|
|
7467
7470
|
bytesToHex,
|
|
7471
|
+
calculateFees,
|
|
7468
7472
|
checkSignature,
|
|
7469
7473
|
clampScalar,
|
|
7470
7474
|
computeAuxiliaryDataHash,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/core-cst",
|
|
3
|
-
"version": "1.9.0-beta.
|
|
3
|
+
"version": "1.9.0-beta.18",
|
|
4
4
|
"description": "Types and utilities functions between Mesh and cardano-js-sdk",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"browser": "./dist/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@harmoniclabs/cbor": "1.3.0",
|
|
43
43
|
"@harmoniclabs/plutus-data": "1.2.4",
|
|
44
44
|
"@harmoniclabs/uplc": "1.2.4",
|
|
45
|
-
"@meshsdk/common": "1.9.0-beta.
|
|
45
|
+
"@meshsdk/common": "1.9.0-beta.18",
|
|
46
46
|
"@types/base32-encoding": "^1.0.2",
|
|
47
47
|
"base32-encoding": "^1.0.0",
|
|
48
48
|
"bech32": "^2.0.0",
|