@meshsdk/core-cst 1.6.1 → 1.6.2

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 CHANGED
@@ -1 +1 @@
1
- "use strict";var xt=Object.create;var ee=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var mt=Object.getPrototypeOf,ht=Object.prototype.hasOwnProperty;var gt=(t,e)=>{for(var r in e)ee(t,r,{get:e[r],enumerable:!0})},je=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of yt(e))!ht.call(t,i)&&i!==r&&ee(t,i,{get:()=>e[i],enumerable:!(s=St(e,i))||s.enumerable});return t};var M=(t,e,r)=>(r=t!=null?xt(mt(t)):{},je(e||!t||!t.__esModule?ee(r,"default",{value:t,enumerable:!0}):r,t)),Ct=t=>je(ee({},"__esModule",{value:!0}),t);var wr={};gt(wr,{Address:()=>b,AddressType:()=>vt,AssetFingerprint:()=>wt,AssetId:()=>$,AssetName:()=>ge,BaseAddress:()=>Q,Bip32PrivateKey:()=>ve,Bip32PrivateKeyHex:()=>zt,Cardano:()=>ue.Cardano,CardanoSDK:()=>br,CardanoSDKSerializer:()=>Ge,CardanoSDKUtil:()=>Br,CborSet:()=>Ft,CborWriter:()=>Lt,Certificate:()=>Ht,CertificateType:()=>Dt,ConstrPlutusData:()=>Pe,CostModel:()=>Mt,Costmdls:()=>Ot,Credential:()=>Bt,CredentialType:()=>z,Crypto:()=>Tr,Datum:()=>W,DatumHash:()=>j,DatumKind:()=>Ut,Ed25519KeyHash:()=>Ie,Ed25519KeyHashHex:()=>G,Ed25519PrivateExtendedKeyHex:()=>bt,Ed25519PrivateNormalKeyHex:()=>Tt,Ed25519PublicKey:()=>kt,Ed25519PublicKeyHex:()=>se,Ed25519Signature:()=>Nt,Ed25519SignatureHex:()=>ie,EnterpriseAddress:()=>N,ExUnits:()=>we,Hash:()=>qt,Hash28ByteBase16:()=>Vt,Hash32ByteBase16:()=>At,NativeScript:()=>y,NetworkId:()=>_t,PaymentAddress:()=>Pt,PlutusData:()=>v,PlutusLanguageVersion:()=>h,PlutusList:()=>fe,PlutusMap:()=>xe,PlutusV1Script:()=>V,PlutusV2Script:()=>A,PlutusV3Script:()=>H,PolicyId:()=>he,PoolId:()=>Et,PrivateKey:()=>E,PublicKey:()=>te,Redeemer:()=>ye,RedeemerPurpose:()=>It,RedeemerTag:()=>me,Redeemers:()=>Se,RequireAllOf:()=>Be,RequireAnyOf:()=>Te,RequireNOf:()=>be,RequireSignature:()=>Ve,RequireTimeAfter:()=>Ae,RequireTimeBefore:()=>He,RewardAccount:()=>Wt,RewardAddress:()=>Y,Script:()=>S,ScriptHash:()=>Ce,ScriptPubkey:()=>Ee,Serialization:()=>ue.Serialization,Slot:()=>L,StakeDelegation:()=>Kt,StakeRegistration:()=>Rt,Transaction:()=>D,TransactionBody:()=>le,TransactionId:()=>I,TransactionInput:()=>x,TransactionOutput:()=>k,TransactionUnspentOutput:()=>F,TransactionWitnessSet:()=>re,Value:()=>C,VkeyWitness:()=>Z,VrfVkBech32:()=>$t,addressToBech32:()=>pr,assetTypes:()=>pt,buildBaseAddress:()=>Gt,buildBip32PrivateKey:()=>jt,buildEnterpriseAddress:()=>Zt,buildKeys:()=>Jt,buildRewardAddress:()=>Re,buildScriptPubkey:()=>Xt,checkSignature:()=>Qt,deserializeAddress:()=>er,deserializeDataHash:()=>Ke,deserializeEd25519KeyHash:()=>tr,deserializeNativeScript:()=>rr,deserializePlutusData:()=>De,deserializePlutusScript:()=>J,deserializeScriptHash:()=>sr,deserializeScriptRef:()=>ke,deserializeTx:()=>Ne,deserializeTxHash:()=>ze,deserializeTxUnspentOutput:()=>ir,deserializeValue:()=>or,empty:()=>Ue,fromNativeScript:()=>We,fromScriptRef:()=>ur,fromTxUnspentOutput:()=>nr,fromValue:()=>nt,mergeValue:()=>U,negateValue:()=>at,negatives:()=>_e,resolveDataHash:()=>dr,resolveNativeScriptAddress:()=>cr,resolveNativeScriptHash:()=>lr,resolvePaymentKeyHash:()=>fr,resolvePlutusScriptAddress:()=>xr,resolvePlutusScriptHash:()=>Sr,resolvePoolId:()=>yr,resolvePrivateKey:()=>mr,resolveRewardAddress:()=>gr,resolveScriptRef:()=>hr,resolveStakeKeyHash:()=>Cr,resolveTxHash:()=>Ir,signData:()=>Yt,subValue:()=>qe,toAddress:()=>R,toBaseAddress:()=>X,toEnterpriseAddress:()=>ne,toNativeScript:()=>q,toPlutusData:()=>w,toRewardAddress:()=>Me,toScriptRef:()=>Le,toTxUnspentOutput:()=>ar,toValue:()=>_});module.exports=Ct(wr);var ue=require("@cardano-sdk/core");var de=M(require("@stricahq/bip32ed25519"),1),Je=M(require("hash.js"),1),E=class extends de.default.PrivateKey{constructor(e,r=!0){if(!r){let s=Je.default.sha512().update(e).digest();s[0]&&s[31]&&(s[0]&=248,s[31]&=63,s[31]|=64),e=Buffer.from(s)}super(e)}},{PublicKey:te,Bip32PrivateKey:Xe,Bip32PublicKey:Ar}=de.default;var o=require("@cardano-sdk/core"),l=M(require("@cardano-sdk/crypto"),1),ce=require("@cardano-sdk/util"),L=o.Cardano.Slot,C=o.Serialization.Value,D=o.Serialization.Transaction,I=o.Cardano.TransactionId,le=o.Serialization.TransactionBody,re=o.Serialization.TransactionWitnessSet,F=o.Serialization.TransactionUnspentOutput,x=o.Serialization.TransactionInput,k=o.Serialization.TransactionOutput,v=o.Serialization.PlutusData,fe=o.Serialization.PlutusList,xe=o.Serialization.PlutusMap,Se=o.Serialization.Redeemers,ye=o.Serialization.Redeemer,It=o.Cardano.RedeemerPurpose,me=o.Serialization.RedeemerTag,S=o.Serialization.Script,he=o.Cardano.PolicyId,ge=o.Cardano.AssetName,$=o.Cardano.AssetId,Ce=l.Hash28ByteBase16,b=o.Cardano.Address,Y=o.Cardano.RewardAddress,vt=o.Cardano.AddressType,Q=o.Cardano.BaseAddress,N=o.Cardano.EnterpriseAddress,Pt=o.Cardano.PaymentAddress,wt=o.Cardano.AssetFingerprint,Bt=o.Serialization.Credential,se=l.Ed25519PublicKeyHex,Tt=t=>(0,ce.typedHex)(t,64),bt=t=>(0,ce.typedHex)(t,128),Ie=l.Ed25519KeyHash,G=l.Ed25519KeyHashHex,Vt=l.Hash28ByteBase16,At=l.Hash32ByteBase16,z=o.Cardano.CredentialType,Ht=o.Serialization.Certificate,Et=o.Cardano.PoolId,Rt=o.Serialization.StakeRegistration,Kt=o.Serialization.StakeDelegation,Dt=o.Cardano.CertificateType,Z=o.Serialization.VkeyWitness,ie=l.Ed25519SignatureHex,kt=l.Ed25519PublicKey,Nt=l.Ed25519Signature,ve=l.Bip32PrivateKey,zt=l.Bip32PrivateKeyHex,h=o.Cardano.PlutusLanguageVersion,y=o.Serialization.NativeScript,V=o.Serialization.PlutusV1Script,A=o.Serialization.PlutusV2Script,H=o.Serialization.PlutusV3Script,Ot=o.Serialization.Costmdls,Mt=o.Serialization.CostModel,Lt=o.Serialization.CborWriter,Pe=o.Serialization.ConstrPlutusData,Wt=o.Cardano.RewardAccount,qt=o.Serialization.Hash,j=l.Hash32ByteBase16,W=o.Serialization.Datum,we=o.Serialization.ExUnits,_t=o.Cardano.NetworkId,Ut=o.Serialization.DatumKind,Ft=o.Serialization.CborSet,Be=o.Cardano.NativeScriptKind.RequireAllOf,Te=o.Cardano.NativeScriptKind.RequireAnyOf,be=o.Cardano.NativeScriptKind.RequireNOf,Ve=o.Cardano.NativeScriptKind.RequireSignature,Ae=o.Cardano.NativeScriptKind.RequireTimeAfter,He=o.Cardano.NativeScriptKind.RequireTimeBefore,$t=o.Cardano.VrfVkBech32,Ee=o.Serialization.ScriptPubkey;var Yt=(t,e)=>{let r=Buffer.from(t),s=e.sign(r);return{key:e.toPublicKey().toBytes().toString("hex"),signature:s.toString("hex")}},Qt=(t,{key:e,signature:r})=>new te(Buffer.from(e,"hex")).verify(Buffer.from(r,"hex"),Buffer.from(t));var ae=require("@cardano-sdk/core"),Fe=require("@cardano-sdk/crypto"),dt=require("@cardano-sdk/util");var et=require("pbkdf2"),oe=require("@meshsdk/common");var Gt=(t,e,r)=>Q.fromCredentials(t,{hash:e,type:z.KeyHash},{hash:r,type:z.KeyHash}),Zt=(t,e)=>N.fromCredentials(t,{hash:e,type:z.KeyHash}),jt=(t,e="")=>{let i="sha512",n=u=>(u[0]!==void 0&&(u[0]&=248),u[31]!==void 0&&(u[31]&=31,u[31]|=64),u),a=Buffer.from(t,"hex"),c=(0,et.pbkdf2Sync)(e,a,4096,96,i);return ve.fromBytes(n(c))},Re=(t,e)=>{let r={type:z.KeyHash,hash:e};return Y.fromCredentials(t,r)},Jt=(t,e,r=0)=>{if(typeof t=="string"){let i=new Xe(Buffer.from(t,"hex")).derive(oe.HARDENED_KEY_START+1852).derive(oe.HARDENED_KEY_START+1815).derive(oe.HARDENED_KEY_START+e),n=i.derive(0).derive(r).toPrivateKey(),a=i.derive(2).derive(0).toPrivateKey();return{paymentKey:n,stakeKey:a}}else{let s=new E(Buffer.from(t[0],"hex"),!1),i=new E(Buffer.from(t[1],"hex"),!1);return{paymentKey:s,stakeKey:i}}},Xt=t=>{let e=new Ee(G(t.hex()));return y.newScriptPubkey(e)};var O=require("@cardano-sdk/core"),it=require("@cardano-sdk/crypto"),ot=require("@cardano-sdk/util"),Oe=require("@meshsdk/common");var tt=require("@cardano-sdk/core"),rt=require("@cardano-sdk/crypto"),P=require("@cardano-sdk/util"),st=require("@meshsdk/common");var er=t=>{let e=b.fromString(t);if(e===null)throw new Error("Invalid address");return e},tr=t=>Ie.fromBytes((0,st.toBytes)(t)),Ke=t=>j.fromHexBlob((0,P.HexBlob)(t)),De=t=>v.fromCbor((0,P.HexBlob)(t)),J=(t,e)=>{switch(e){case"V1":return V.fromCbor((0,P.HexBlob)(t));case"V2":return A.fromCbor((0,P.HexBlob)(t));case"V3":return H.fromCbor((0,P.HexBlob)(t));default:throw new Error("Invalid Plutus script version")}},rr=t=>y.fromCbor((0,P.HexBlob)(t)),sr=t=>Ce.fromEd25519KeyHashHex((0,rt.Ed25519KeyHashHex)(t)),ke=t=>S.fromCbor((0,P.HexBlob)(t)),ir=t=>F.fromCbor((0,P.HexBlob)(t)),or=t=>C.fromCbor((0,P.HexBlob)(t)),Ne=t=>D.fromCbor((0,tt.TxCBOR)(t)),ze=t=>I.fromHexBlob((0,P.HexBlob)(t));var R=t=>b.fromBech32(t),X=t=>Q.fromAddress(R(t)),ne=t=>N.fromAddress(R(t)),Me=t=>Y.fromAddress(R(t)),nr=t=>{let e=t.output().datum()?t.output().datum()?.toCbor().toString():void 0,r=t.output().scriptRef()?t.output().scriptRef()?.toCbor().toString():void 0,s=t.output().datum()?.asInlineData()?t.output().datum()?.asInlineData()?.toCbor().toString():void 0;return{input:{outputIndex:Number(t.input().index()),txHash:t.input().transactionId()},output:{address:t.output().address().toBech32(),amount:nt(t.output().amount()),dataHash:e,plutusData:s,scriptRef:r}}},ar=t=>{let e=new x(ze(t.input.txHash),BigInt(t.input.outputIndex)),r=new k(R(t.output.address),_(t.output.amount));if(t.output.dataHash!==void 0&&r.setDatum(W.fromCore(Ke(t.output.dataHash))),t.output.plutusData!==void 0){let s=De(t.output.plutusData),i=new O.Serialization.Datum(void 0,s);r.setDatum(i)}return t.output.scriptRef!==void 0&&r.setScriptRef(ke(t.output.scriptRef)),new F(e,r)},pr=t=>t.toBech32(),nt=t=>{let e=[{unit:"lovelace",quantity:t.coin().toString()}],r=t.multiasset();if(r!==void 0){let s=Array.from(r.keys());for(let i=0;i<s.length;i+=1){let n=s[i];if(n!==void 0){let a=r.get(n);a!==void 0&&e.push({unit:n,quantity:a.toString()})}}}return e},Le=t=>{if("code"in t){let e=J(t.code,t.version);if(e instanceof V)return S.newPlutusV1Script(e);if(e instanceof A)return S.newPlutusV2Script(e);if(e instanceof H)return S.newPlutusV3Script(e)}return S.newNativeScript(q(t))},ur=t=>{let e=S.fromCbor((0,ot.HexBlob)(t)),r=e.asPlutusV3()?.toCbor().toString();if(r)return{code:r,version:"V3"};let s=e.asPlutusV2()?.toCbor().toString();if(s)return{code:s,version:"V2"};let i=e.asPlutusV1()?.toCbor().toString();if(i)return{code:i,version:"V1"};let n=e.asNative();if(!n)throw new Error("Invalid script");return We(n)},We=t=>{let e=r=>{let s=new Array;for(let i=0;i<r.length;i+=1){let n=r[i];n&&s.push(We(n))}return s};switch(t.kind()){case Be:{let r=t.asScriptAll();return{type:"all",scripts:e(r.nativeScripts())}}case Te:{let r=t.asScriptAny();return{type:"any",scripts:e(r.nativeScripts())}}case be:{let r=t.asScriptNOfK();return{type:"atLeast",required:r.required(),scripts:e(r.nativeScripts())}}case Ae:return{type:"after",slot:t.asTimelockStart().slot().toString()};case He:return{type:"before",slot:t.asTimelockExpiry().slot().toString()};case Ve:return{type:"sig",keyHash:t.asScriptPubkey().keyHash().toString()};default:throw new Error(`Script Kind: ${t.kind()}, is not supported`)}},q=t=>{let e=r=>{let s=[];return r.forEach(i=>{s.push(q(i))}),s};switch(t.type){case"all":return y.newScriptAll(new O.Serialization.ScriptAll(e(t.scripts)));case"any":return y.newScriptAny(new O.Serialization.ScriptAny(e(t.scripts)));case"atLeast":return y.newScriptNOfK(new O.Serialization.ScriptNOfK(e(t.scripts),t.required));case"after":return y.newTimelockStart(new O.Serialization.TimelockStart(L(parseInt(t.slot))));case"before":return y.newTimelockExpiry(new O.Serialization.TimelockExpiry(L(parseInt(t.slot))));case"sig":return y.newScriptPubkey(new O.Serialization.ScriptPubkey(it.Ed25519KeyHash.fromBytes((0,Oe.toBytes)(t.keyHash)).hex()))}},w=t=>{let e=r=>{let s=new fe;return r.forEach(i=>{s.add(w(i))}),s};switch(typeof t){case"string":return v.newBytes((0,Oe.toBytes)(t));case"number":return v.newInteger(BigInt(t));case"bigint":return v.newInteger(BigInt(t));case"object":if(t instanceof Array){let r=e(t);return v.newList(r)}else if(t instanceof Map){let r=new xe;return t.forEach((s,i)=>{r.insert(w(i),w(s))}),v.newMap(r)}else return v.newConstrPlutusData(new Pe(BigInt(t.alternative),e(t.fields)))}},_=t=>{let e=new Map;t.filter(i=>i.unit!=="lovelace").forEach(i=>{e.set($(i.unit),BigInt(i.quantity))});let r=t.find(i=>i.unit==="lovelace"),s=new C(BigInt(r?r.quantity:0));return(t.length>1||!r)&&s.setMultiasset(e),s};function U(t,e){let r=t.multiasset()??new Map;return e.multiasset()?.forEach((s,i)=>{let n=(r.get(i)??0n)+s;n==0n?r.delete(i):r.set(i,n)}),new C(BigInt(t.coin())+BigInt(e.coin()),r.size>0?r:void 0)}function at(t){let e=t.multiasset()?.entries(),r=new Map;if(e)for(let s of e)r.set(s[0],-s[1]);return new C(-t.coin(),r)}function qe(t,e){return U(t,at(e))}function _e(t){let e=t.multiasset()?.entries(),r=t.coin()<0n?t.coin():0n,s=new Map;if(e)for(let i of e)i[1]<0n&&s.set(i[0],i[1]);return new C(r,s)}function pt(t){let e=t.coin()==0n?0:1,r=t.multiasset();return r&&r.forEach(()=>{e+=1}),e}function Ue(t){return pt(t)==0}var ut=t=>Buffer.from(t,"hex");var dr=t=>w(t).hash().toString(),cr=(t,e=0)=>{let r=q(t);return N.fromCredentials(e,{hash:r.hash(),type:ae.Cardano.CredentialType.ScriptHash}).toAddress().toBech32()},lr=t=>q(t).hash().toString(),fr=t=>{try{let e=[X(t)?.getPaymentCredential().hash,ne(t)?.getPaymentCredential().hash].find(r=>r!==void 0);if(e!==void 0)return e.toString();throw new Error(`Couldn't resolve payment key hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolvePaymentKeyHash: ${e}.`)}},xr=(t,e=0)=>{let r=J(t.code,t.version);return N.fromCredentials(e,{hash:r.hash(),type:ae.Cardano.CredentialType.ScriptHash}).toAddress().toBech32()},Sr=t=>{try{let r=ne(t)?.getPaymentCredential().hash;if(r!==void 0)return r.toString();throw new Error(`Couldn't resolve script hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveScriptHash: ${e}.`)}},yr=t=>G(t).toString(),mr=t=>(console.log(t),"not implemented"),hr=t=>Le(t).toCbor().toString(),gr=t=>{try{let e=R(t),s=X(t)?.getStakeCredential().hash;if(s!==void 0)return Re(e.getNetworkId(),s).toAddress().toBech32();throw new Error(`Couldn't resolve reward address from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveRewardAddress: ${e}.`)}},Cr=t=>{try{let e=[X(t)?.getStakeCredential().hash,Me(t)?.getPaymentCredential().hash].find(r=>r!==void 0);if(e!==void 0)return e.toString();throw new Error(`Couldn't resolve stake key hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveStakeKeyHash: ${e}.`)}},Ir=t=>{let e=Ne(t).body(),r=(0,Fe.blake2b)(Fe.blake2b.BYTES).update(ut(e.toCbor())).digest();return ae.Cardano.TransactionId.fromHexBlob(dt.HexBlob.fromBytes(r))};var f=require("@cardano-sdk/core"),g=require("@cardano-sdk/util"),pe=require("@meshsdk/common");var Qe=require("@cardano-sdk/core"),Ye=M(require("@cardano-sdk/crypto"),1),ct=require("@cardano-sdk/crypto"),lt=require("@cardano-sdk/util"),vr=new Uint8Array([128]),Pr=new Uint8Array([160]),$e=t=>{let e=new Qe.Serialization.CborWriter;e.writeStartArray(t.length);for(let r of t)e.writeEncodedValue(Buffer.from(r.toCbor(),"hex"));return e.encode()},ft=(t,e,r)=>{let s=new Qe.Serialization.CborWriter;if(r&&r.length>0&&(!e||e.length===0))s.writeEncodedValue(vr),s.writeEncodedValue($e(r)),s.writeEncodedValue(Pr);else{if(!e||e.length===0)return;s.writeEncodedValue($e(e)),r&&r.length>0&&s.writeEncodedValue($e(r)),s.writeEncodedValue(Buffer.from(t.languageViewsEncoding(),"hex"))}return ct.Hash32ByteBase16.fromHexBlob(lt.HexBlob.fromBytes(Ye.blake2b(Ye.blake2b.BYTES).update(s.encode()).digest()))};var Ge=class{txBody;txWitnessSet;utxoContext=new Map;redeemerContext=new Map;scriptsProvided=new Set;datumsProvided=new Set;usedLanguages={0:!1,1:!1,2:!1};constructor(){this.txBody=new le(f.Serialization.CborSet.fromCore([],x.fromCore),[],BigInt(0),void 0),this.txWitnessSet=new re}serializeAddress(e,r){throw new Error("Method not implemented.")}serializeData(e){throw new Error("Method not implemented.")}deserializer={key:{deserializeAddress:function(e){throw new Error("Function not implemented.")}},script:{deserializeNativeScript:function(e){throw new Error("Function not implemented.")},deserializePlutusScript:function(e){throw new Error("Function not implemented.")}}};resolver={keys:{resolveStakeKeyHash:function(e){let r=R(e);return r.asReward()?.getPaymentCredential().type===z.KeyHash?r.asReward().getPaymentCredential().hash:""},resolvePrivateKey:function(e){throw new Error("Function not implemented.")},resolveRewardAddress:function(e){throw new Error("Function not implemented.")},resolveEd25519KeyHash:function(e){throw new Error("Function not implemented.")}},tx:{resolveTxHash:function(e){return D.fromCbor((0,f.TxCBOR)(e)).getId()}},data:{resolveDataHash:function(e){throw new Error("Function not implemented.")}},script:{resolveScriptRef:function(e){throw new Error("Function not implemented.")}},pool:{resolvePoolId:function(e){throw new Error("Function not implemented.")}}};serializeTxBody=(e,r)=>{let{inputs:s,outputs:i,collaterals:n,referenceInputs:a,mints:c,changeAddress:u,certificates:K,validityRange:B,requiredSignatures:m,metadata:T}=e;return c.sort((p,d)=>p.policyId.localeCompare(d.policyId)),s.sort((p,d)=>p.txIn.txHash===d.txIn.txHash?p.txIn.txIndex-d.txIn.txIndex:p.txIn.txHash.localeCompare(d.txIn.txHash)),this.addAllInputs(s),this.addAllOutputs(i),this.addAllMints(c),this.addAllCollateralInputs(n),this.addAllReferenceInputs(a),this.setValidityInterval(B),this.buildWitnessSet(),this.balanceTx(u,m.length,r),new D(this.txBody,this.txWitnessSet).toCbor()};addSigningKeys=(e,r)=>{let s=D.fromCbor((0,f.TxCBOR)(e)),i=s.witnessSet(),n=i.vkeys(),a=n?[...n.values()]:[];for(let c=0;c<r.length;c++){let u=r[c];if(u){u.length===68&&u.substring(0,4)==="5820"&&(u=u.substring(4));let K=new E(Buffer.from(u,"hex"),!1),B=K.sign(Buffer.from(s.getId(),"hex"));a.push(new Z(se(K.toPublicKey().toBytes().toString("hex")),ie(B.toString("hex"))))}}return i.setVkeys(f.Serialization.CborSet.fromCore(a.map(c=>c.toCore()),Z.fromCore)),s.setWitnessSet(i),s.toCbor()};addAllInputs=e=>{for(let r=0;r<e.length;r+=1){let s=e[r];if(s)switch(s.type){case"PubKey":this.addTxIn(s);break;case"Script":this.addScriptTxIn(s);break;case"SimpleScript":this.addSimpleScriptTxIn(s)}}};addTxIn=e=>{let r=new x(I(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=this.txBody.inputs(),i=[...s.values()];if(i.find(a=>{a.index()==r.index()&&a.transactionId==r.transactionId}))throw new Error("Duplicate input added to tx body");i.push(r),s.setValues(i);let n=new k(b.fromBech32(e.txIn.address),_(e.txIn.amount));this.utxoContext.set(r,n),this.txBody.setInputs(s)};addScriptTxIn=e=>{if(this.addTxIn({type:"PubKey",txIn:e.txIn}),!e.scriptTxIn.scriptSource)throw new Error("A script input had no script source");if(!e.scriptTxIn.datumSource)throw new Error("A script input had no datum source");if(!e.scriptTxIn.redeemer)throw new Error("A script input had no redeemer");if(e.scriptTxIn.scriptSource.type==="Provided")switch(e.scriptTxIn.scriptSource.script.version){case"V1":{this.scriptsProvided.add(S.newPlutusV1Script(V.fromCbor((0,g.HexBlob)(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[h.V1]=!0;break}case"V2":{this.scriptsProvided.add(S.newPlutusV2Script(A.fromCbor((0,g.HexBlob)(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[h.V2]=!0;break}case"V3":{this.scriptsProvided.add(S.newPlutusV3Script(H.fromCbor((0,g.HexBlob)(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[h.V3]=!0;break}}else if(e.scriptTxIn.scriptSource.type==="Inline"){let i=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),n=[...i.values()];switch(n.push(new x(I(e.scriptTxIn.scriptSource.txHash),BigInt(e.scriptTxIn.scriptSource.txIndex))),i.setValues(n),this.txBody.setReferenceInputs(i),e.scriptTxIn.scriptSource.version){case"V1":{this.usedLanguages[h.V1]=!0;break}case"V2":{this.usedLanguages[h.V2]=!0;break}case"V3":{this.usedLanguages[h.V3]=!0;break}}}if(e.scriptTxIn.datumSource.type==="Provided")this.datumsProvided.add(w(e.scriptTxIn.datumSource.data.content));else if(e.scriptTxIn.datumSource.type==="Inline"){let i=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),n=[...i.values()];n.push(new x(I(e.txIn.txHash),BigInt(e.txIn.txIndex))),i.setValues(n),this.txBody.setReferenceInputs(i)}let r=new x(I(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=e.scriptTxIn.redeemer.exUnits;this.redeemerContext.set(r,new ye(me.Spend,BigInt(0),w(e.scriptTxIn.redeemer.data.content),new we(BigInt(s.mem),BigInt(s.steps))))};addSimpleScriptTxIn=e=>{if(this.addTxIn({type:"PubKey",txIn:e.txIn}),!e.simpleScriptTxIn.scriptSource)throw new Error("A native script input had no script source");if(e.simpleScriptTxIn.scriptSource.type==="Provided")this.scriptsProvided.add(S.newNativeScript(y.fromCbor((0,g.HexBlob)(e.simpleScriptTxIn.scriptSource.script))));else if(e.simpleScriptTxIn.scriptSource.type==="Inline"&&e.simpleScriptTxIn.scriptSource.txInInfo.type==="Inline"){let r=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),s=[...r.values()];s.push(new x(I(e.simpleScriptTxIn.scriptSource.txInInfo.txHash),BigInt(e.simpleScriptTxIn.scriptSource.txInInfo.txIndex))),r.setValues(s),this.txBody.setReferenceInputs(r)}};addAllOutputs=e=>{for(let r=0;r<e.length;r++)this.addOutput(e[r])};addOutput=e=>{let r=this.txBody.outputs(),s=new k(b.fromBech32(e.address),_(e.amount));if(e.datum?.type==="Hash"?s.setDatum(W.newDataHash(j.fromHexBlob((0,g.HexBlob)(w(e.datum.data.content).hash())))):e.datum?.type==="Inline"&&s.setDatum(W.newInlineData(w(e.datum.data.content))),e.referenceScript)switch(e.referenceScript.version){case"V1":{s.setScriptRef(S.newPlutusV1Script(V.fromCbor((0,g.HexBlob)(e.referenceScript.code))));break}case"V2":{s.setScriptRef(S.newPlutusV2Script(A.fromCbor((0,g.HexBlob)(e.referenceScript.code))));break}case"V3":{s.setScriptRef(S.newPlutusV3Script(H.fromCbor((0,g.HexBlob)(e.referenceScript.code))));break}}r.push(s),this.txBody.setOutputs(r)};addAllReferenceInputs=e=>{for(let r=0;r<e.length;r++)this.addReferenceIput(e[r])};addReferenceIput=e=>{let r=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),s=[...r.values()];s.push(new x(I.fromHexBlob((0,g.HexBlob)(e.txHash)),BigInt(e.txIndex))),r.setValues(s),this.txBody.setReferenceInputs(r)};addAllMints=e=>{for(let r=0;r<e.length;r++)this.addMint(e[r])};addMint=e=>{let r=this.txBody.mint()??new Map,s=e.policyId+e.assetName;for(let i of r.keys())if(i.toString()==s)throw new Error("The same asset is already in the mint field");if(r.set($.fromParts(he(e.policyId),ge(e.assetName)),BigInt(e.amount)),this.txBody.setMint(r),e.type==="Native"){if(!e.scriptSource)throw new Error("Script source not provided for native script mint");let i=e.scriptSource;if(!i)throw new Error("A script source for a native script was not a native script somehow");if(i.type==="Provided")this.scriptsProvided.add(S.newNativeScript(y.fromCbor((0,g.HexBlob)(i.scriptCode))));else if(i.type==="Inline"){let n=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),a=[...n.values()];a.push(new x(I(i.txHash),BigInt(i.txIndex))),n.setValues(a),this.txBody.setReferenceInputs(n)}}else if(e.type==="Plutus"){if(!e.scriptSource)throw new Error("Script source not provided for plutus script mint");let i=e.scriptSource;if(!i)throw new Error("A script source for a plutus mint was not plutus script somehow");if(i.type==="Provided")switch(i.script.version){case"V1":this.scriptsProvided.add(S.newPlutusV1Script(V.fromCbor((0,g.HexBlob)(i.script.code))));break;case"V2":this.scriptsProvided.add(S.newPlutusV2Script(A.fromCbor((0,g.HexBlob)(i.script.code))));break;case"V3":this.scriptsProvided.add(S.newPlutusV3Script(H.fromCbor((0,g.HexBlob)(i.script.code))));break}else if(i.type==="Inline"){let n=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),a=[...n.values()];switch(a.push(new x(I(i.txHash),BigInt(i.txIndex))),n.setValues(a),this.txBody.setReferenceInputs(n),i.version){case"V1":{this.usedLanguages[h.V1]=!0;break}case"V2":{this.usedLanguages[h.V2]=!0;break}case"V3":{this.usedLanguages[h.V3]=!0;break}}}}};addAllCollateralInputs=e=>{for(let r=0;r<e.length;r++)this.addCollateralInput(e[r])};addCollateralInput=e=>{let r=new x(I(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=this.txBody.collateral()??f.Serialization.CborSet.fromCore([],x.fromCore),i=[...s.values()];if(i.find(a=>{a.index()==r.index()&&a.transactionId==r.transactionId}))throw new Error("Duplicate input added to tx body");i.push(r),s.setValues(i);let n=new k(b.fromBech32(e.txIn.address),_(e.txIn.amount));this.utxoContext.set(r,n),this.txBody.setCollateral(s)};setValidityInterval=e=>{e.invalidBefore&&this.txBody.setValidityStartInterval(L(e.invalidBefore)),e.invalidHereafter&&this.txBody.setTtl(L(e.invalidHereafter))};buildWitnessSet=()=>{let e=this.txBody.inputs();for(let p=0;p<e.size();p+=1){let d=e.values().at(p);if(d){let Ze=this.redeemerContext.get(d);Ze&&Ze.setIndex(BigInt(p))}}let r=this.txWitnessSet.redeemers()??Se.fromCore([]),s=[...r.values()];this.redeemerContext.forEach(p=>{s.push(p)}),r.setValues(s),this.txWitnessSet.setRedeemers(r);let i=this.txWitnessSet.nativeScripts()??f.Serialization.CborSet.fromCore([],y.fromCore),n=this.txWitnessSet.plutusV1Scripts()??f.Serialization.CborSet.fromCore([],V.fromCore),a=this.txWitnessSet.plutusV2Scripts()??f.Serialization.CborSet.fromCore([],A.fromCore),c=this.txWitnessSet.plutusV3Scripts()??f.Serialization.CborSet.fromCore([],H.fromCore);this.scriptsProvided.forEach(p=>{if(p.asNative()!==void 0){let d=[...i.values()];d.push(p.asNative()),i.setValues(d)}else if(p.asPlutusV1()!==void 0){let d=[...n.values()];d.push(p.asPlutusV1()),n.setValues(d)}else if(p.asPlutusV2()!==void 0){let d=[...a.values()];d.push(p.asPlutusV2()),a.setValues(d)}else if(p.asPlutusV3()!==void 0){let d=[...c.values()];d.push(p.asPlutusV3()),c.setValues(d)}this.txWitnessSet.setNativeScripts(i),this.txWitnessSet.setPlutusV1Scripts(n),this.txWitnessSet.setPlutusV2Scripts(a),this.txWitnessSet.setPlutusV3Scripts(c)});let u=this.txWitnessSet.plutusData()??f.Serialization.CborSet.fromCore([],v.fromCore);this.datumsProvided.forEach(p=>{let d=[...u.values()];d.push(p),u.setValues(d)}),this.txWitnessSet.setPlutusData(u);let K=f.Serialization.CostModel.newPlutusV1(pe.DEFAULT_V1_COST_MODEL_LIST),B=f.Serialization.CostModel.newPlutusV2(pe.DEFAULT_V2_COST_MODEL_LIST),m=new f.Serialization.Costmdls;this.usedLanguages[h.V1]&&m.insert(K),this.usedLanguages[h.V2]&&m.insert(B),this.usedLanguages[h.V3];let T=ft(m,r.size()>0?[...r.values()]:void 0,u.size()>0?[...u.values()]:void 0);T&&this.txBody.setScriptDataHash(T)};balanceTx=(e,r,s)=>{if(e==="")throw new Error("Can't balance tx without a change address");let i=this.txBody.inputs().values(),n=new C(BigInt(0));for(let m=0;m<i.length;m++){let T=i[m];if(!T)throw new Error("Invalid input found");let p=this.utxoContext.get(T);if(!p)throw new Error(`Unable to resolve input: ${T.toCbor()}`);n=U(n,p.amount())}let a=this.txBody.withdrawals();a&&a.forEach(m=>{n=U(n,new C(m))}),n=U(n,new C(BigInt(0),this.txBody.mint()));let c=this.txBody.outputs();for(let m=0;m<c.length;m++){let T=c.at(m);T&&(n=qe(n,T.amount()))}if(n.coin()<0||!Ue(_e(n)))throw new Error("Not enough funds to satisfy outputs");c.push(new k(b.fromBech32(e),n)),this.txBody.setOutputs(c),this.txBody.setFee(BigInt("10000000"));let u=this.createDummyTx(r),K=s.minFeeB+u.toCbor().length/2*Number(s.coinsPerUtxoSize);this.txBody.setFee(BigInt(K));let B=c.pop();if(!B)throw new Error("Somehow the output length was 0 after attempting to calculate fees");B.amount().setCoin(B.amount().coin()-BigInt(K)),c.push(B),this.txBody.setOutputs(c)};createDummyTx=e=>{let r=new re,s=[];for(let i=0;i<e;i++)s.push([se("0".repeat(64)),ie("0".repeat(128))]);return r.setVkeys(f.Serialization.CborSet.fromCore(s,Z.fromCore)),new D(this.txBody,r)}};var Br=M(require("@cardano-sdk/util"),1),Tr=M(require("@cardano-sdk/crypto"),1),br=M(require("@cardano-sdk/core"),1);0&&(module.exports={Address,AddressType,AssetFingerprint,AssetId,AssetName,BaseAddress,Bip32PrivateKey,Bip32PrivateKeyHex,Cardano,CardanoSDK,CardanoSDKSerializer,CardanoSDKUtil,CborSet,CborWriter,Certificate,CertificateType,ConstrPlutusData,CostModel,Costmdls,Credential,CredentialType,Crypto,Datum,DatumHash,DatumKind,Ed25519KeyHash,Ed25519KeyHashHex,Ed25519PrivateExtendedKeyHex,Ed25519PrivateNormalKeyHex,Ed25519PublicKey,Ed25519PublicKeyHex,Ed25519Signature,Ed25519SignatureHex,EnterpriseAddress,ExUnits,Hash,Hash28ByteBase16,Hash32ByteBase16,NativeScript,NetworkId,PaymentAddress,PlutusData,PlutusLanguageVersion,PlutusList,PlutusMap,PlutusV1Script,PlutusV2Script,PlutusV3Script,PolicyId,PoolId,PrivateKey,PublicKey,Redeemer,RedeemerPurpose,RedeemerTag,Redeemers,RequireAllOf,RequireAnyOf,RequireNOf,RequireSignature,RequireTimeAfter,RequireTimeBefore,RewardAccount,RewardAddress,Script,ScriptHash,ScriptPubkey,Serialization,Slot,StakeDelegation,StakeRegistration,Transaction,TransactionBody,TransactionId,TransactionInput,TransactionOutput,TransactionUnspentOutput,TransactionWitnessSet,Value,VkeyWitness,VrfVkBech32,addressToBech32,assetTypes,buildBaseAddress,buildBip32PrivateKey,buildEnterpriseAddress,buildKeys,buildRewardAddress,buildScriptPubkey,checkSignature,deserializeAddress,deserializeDataHash,deserializeEd25519KeyHash,deserializeNativeScript,deserializePlutusData,deserializePlutusScript,deserializeScriptHash,deserializeScriptRef,deserializeTx,deserializeTxHash,deserializeTxUnspentOutput,deserializeValue,empty,fromNativeScript,fromScriptRef,fromTxUnspentOutput,fromValue,mergeValue,negateValue,negatives,resolveDataHash,resolveNativeScriptAddress,resolveNativeScriptHash,resolvePaymentKeyHash,resolvePlutusScriptAddress,resolvePlutusScriptHash,resolvePoolId,resolvePrivateKey,resolveRewardAddress,resolveScriptRef,resolveStakeKeyHash,resolveTxHash,signData,subValue,toAddress,toBaseAddress,toEnterpriseAddress,toNativeScript,toPlutusData,toRewardAddress,toScriptRef,toTxUnspentOutput,toValue});
1
+ "use strict";var xt=Object.create;var ee=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var mt=Object.getPrototypeOf,ht=Object.prototype.hasOwnProperty;var gt=(t,e)=>{for(var r in e)ee(t,r,{get:e[r],enumerable:!0})},je=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of yt(e))!ht.call(t,i)&&i!==r&&ee(t,i,{get:()=>e[i],enumerable:!(s=St(e,i))||s.enumerable});return t};var M=(t,e,r)=>(r=t!=null?xt(mt(t)):{},je(e||!t||!t.__esModule?ee(r,"default",{value:t,enumerable:!0}):r,t)),Ct=t=>je(ee({},"__esModule",{value:!0}),t);var wr={};gt(wr,{Address:()=>b,AddressType:()=>vt,AssetFingerprint:()=>wt,AssetId:()=>$,AssetName:()=>ge,BaseAddress:()=>Q,Bip32PrivateKey:()=>ve,Bip32PrivateKeyHex:()=>zt,Cardano:()=>ue.Cardano,CardanoSDK:()=>br,CardanoSDKSerializer:()=>Ge,CardanoSDKUtil:()=>Br,CborSet:()=>Ft,CborWriter:()=>Lt,Certificate:()=>Ht,CertificateType:()=>Dt,ConstrPlutusData:()=>Pe,CostModel:()=>Mt,Costmdls:()=>Ot,Credential:()=>Bt,CredentialType:()=>z,Crypto:()=>Tr,Datum:()=>W,DatumHash:()=>j,DatumKind:()=>Ut,Ed25519KeyHash:()=>Ie,Ed25519KeyHashHex:()=>G,Ed25519PrivateExtendedKeyHex:()=>bt,Ed25519PrivateNormalKeyHex:()=>Tt,Ed25519PublicKey:()=>kt,Ed25519PublicKeyHex:()=>se,Ed25519Signature:()=>Nt,Ed25519SignatureHex:()=>ie,EnterpriseAddress:()=>N,ExUnits:()=>we,Hash:()=>qt,Hash28ByteBase16:()=>Vt,Hash32ByteBase16:()=>At,NativeScript:()=>y,NetworkId:()=>_t,PaymentAddress:()=>Pt,PlutusData:()=>v,PlutusLanguageVersion:()=>h,PlutusList:()=>fe,PlutusMap:()=>xe,PlutusV1Script:()=>V,PlutusV2Script:()=>A,PlutusV3Script:()=>H,PolicyId:()=>he,PoolId:()=>Et,PrivateKey:()=>E,PublicKey:()=>te,Redeemer:()=>ye,RedeemerPurpose:()=>It,RedeemerTag:()=>me,Redeemers:()=>Se,RequireAllOf:()=>Be,RequireAnyOf:()=>Te,RequireNOf:()=>be,RequireSignature:()=>Ve,RequireTimeAfter:()=>Ae,RequireTimeBefore:()=>He,RewardAccount:()=>Wt,RewardAddress:()=>Y,Script:()=>S,ScriptHash:()=>Ce,ScriptPubkey:()=>Ee,Serialization:()=>ue.Serialization,Slot:()=>L,StakeDelegation:()=>Kt,StakeRegistration:()=>Rt,Transaction:()=>D,TransactionBody:()=>le,TransactionId:()=>I,TransactionInput:()=>x,TransactionOutput:()=>k,TransactionUnspentOutput:()=>F,TransactionWitnessSet:()=>re,Value:()=>C,VkeyWitness:()=>Z,VrfVkBech32:()=>$t,addressToBech32:()=>pr,assetTypes:()=>pt,buildBaseAddress:()=>Gt,buildBip32PrivateKey:()=>jt,buildEnterpriseAddress:()=>Zt,buildKeys:()=>Jt,buildRewardAddress:()=>Re,buildScriptPubkey:()=>Xt,checkSignature:()=>Qt,deserializeAddress:()=>er,deserializeDataHash:()=>Ke,deserializeEd25519KeyHash:()=>tr,deserializeNativeScript:()=>rr,deserializePlutusData:()=>De,deserializePlutusScript:()=>J,deserializeScriptHash:()=>sr,deserializeScriptRef:()=>ke,deserializeTx:()=>Ne,deserializeTxHash:()=>ze,deserializeTxUnspentOutput:()=>ir,deserializeValue:()=>or,empty:()=>Ue,fromNativeScript:()=>We,fromScriptRef:()=>ur,fromTxUnspentOutput:()=>nr,fromValue:()=>nt,mergeValue:()=>U,negateValue:()=>at,negatives:()=>_e,resolveDataHash:()=>dr,resolveNativeScriptAddress:()=>cr,resolveNativeScriptHash:()=>lr,resolvePaymentKeyHash:()=>fr,resolvePlutusScriptAddress:()=>xr,resolvePlutusScriptHash:()=>Sr,resolvePoolId:()=>yr,resolvePrivateKey:()=>mr,resolveRewardAddress:()=>gr,resolveScriptRef:()=>hr,resolveStakeKeyHash:()=>Cr,resolveTxHash:()=>Ir,signData:()=>Yt,subValue:()=>qe,toAddress:()=>R,toBaseAddress:()=>X,toEnterpriseAddress:()=>ne,toNativeScript:()=>q,toPlutusData:()=>w,toRewardAddress:()=>Me,toScriptRef:()=>Le,toTxUnspentOutput:()=>ar,toValue:()=>_});module.exports=Ct(wr);var ue=require("@cardano-sdk/core");var de=M(require("@stricahq/bip32ed25519"),1),Je=M(require("hash.js"),1),E=class extends de.default.PrivateKey{constructor(e,r=!0){if(!r){let s=Je.default.sha512().update(e).digest();s[0]&&s[31]&&(s[0]&=248,s[31]&=63,s[31]|=64),e=Buffer.from(s)}super(e)}},{PublicKey:te,Bip32PrivateKey:Xe,Bip32PublicKey:Ar}=de.default;var o=require("@cardano-sdk/core"),l=M(require("@cardano-sdk/crypto"),1),ce=require("@cardano-sdk/util"),L=o.Cardano.Slot,C=o.Serialization.Value,D=o.Serialization.Transaction,I=o.Cardano.TransactionId,le=o.Serialization.TransactionBody,re=o.Serialization.TransactionWitnessSet,F=o.Serialization.TransactionUnspentOutput,x=o.Serialization.TransactionInput,k=o.Serialization.TransactionOutput,v=o.Serialization.PlutusData,fe=o.Serialization.PlutusList,xe=o.Serialization.PlutusMap,Se=o.Serialization.Redeemers,ye=o.Serialization.Redeemer,It=o.Cardano.RedeemerPurpose,me=o.Serialization.RedeemerTag,S=o.Serialization.Script,he=o.Cardano.PolicyId,ge=o.Cardano.AssetName,$=o.Cardano.AssetId,Ce=l.Hash28ByteBase16,b=o.Cardano.Address,Y=o.Cardano.RewardAddress,vt=o.Cardano.AddressType,Q=o.Cardano.BaseAddress,N=o.Cardano.EnterpriseAddress,Pt=o.Cardano.PaymentAddress,wt=o.Cardano.AssetFingerprint,Bt=o.Serialization.Credential,se=l.Ed25519PublicKeyHex,Tt=t=>(0,ce.typedHex)(t,64),bt=t=>(0,ce.typedHex)(t,128),Ie=l.Ed25519KeyHash,G=l.Ed25519KeyHashHex,Vt=l.Hash28ByteBase16,At=l.Hash32ByteBase16,z=o.Cardano.CredentialType,Ht=o.Serialization.Certificate,Et=o.Cardano.PoolId,Rt=o.Serialization.StakeRegistration,Kt=o.Serialization.StakeDelegation,Dt=o.Cardano.CertificateType,Z=o.Serialization.VkeyWitness,ie=l.Ed25519SignatureHex,kt=l.Ed25519PublicKey,Nt=l.Ed25519Signature,ve=l.Bip32PrivateKey,zt=l.Bip32PrivateKeyHex,h=o.Cardano.PlutusLanguageVersion,y=o.Serialization.NativeScript,V=o.Serialization.PlutusV1Script,A=o.Serialization.PlutusV2Script,H=o.Serialization.PlutusV3Script,Ot=o.Serialization.Costmdls,Mt=o.Serialization.CostModel,Lt=o.Serialization.CborWriter,Pe=o.Serialization.ConstrPlutusData,Wt=o.Cardano.RewardAccount,qt=o.Serialization.Hash,j=l.Hash32ByteBase16,W=o.Serialization.Datum,we=o.Serialization.ExUnits,_t=o.Cardano.NetworkId,Ut=o.Serialization.DatumKind,Ft=o.Serialization.CborSet,Be=o.Cardano.NativeScriptKind.RequireAllOf,Te=o.Cardano.NativeScriptKind.RequireAnyOf,be=o.Cardano.NativeScriptKind.RequireNOf,Ve=o.Cardano.NativeScriptKind.RequireSignature,Ae=o.Cardano.NativeScriptKind.RequireTimeAfter,He=o.Cardano.NativeScriptKind.RequireTimeBefore,$t=o.Cardano.VrfVkBech32,Ee=o.Serialization.ScriptPubkey;var Yt=(t,e)=>{let r=Buffer.from(t),s=e.sign(r);return{key:e.toPublicKey().toBytes().toString("hex"),signature:s.toString("hex")}},Qt=(t,{key:e,signature:r})=>new te(Buffer.from(e,"hex")).verify(Buffer.from(r,"hex"),Buffer.from(t));var ae=require("@cardano-sdk/core"),Fe=require("@cardano-sdk/crypto"),dt=require("@cardano-sdk/util");var et=require("pbkdf2"),oe=require("@meshsdk/common");var Gt=(t,e,r)=>Q.fromCredentials(t,{hash:e,type:z.KeyHash},{hash:r,type:z.KeyHash}),Zt=(t,e)=>N.fromCredentials(t,{hash:e,type:z.KeyHash}),jt=(t,e="")=>{let i="sha512",n=u=>(u[0]!==void 0&&(u[0]&=248),u[31]!==void 0&&(u[31]&=31,u[31]|=64),u),a=Buffer.from(t,"hex"),c=(0,et.pbkdf2Sync)(e,a,4096,96,i);return ve.fromBytes(n(c))},Re=(t,e)=>{let r={type:z.KeyHash,hash:e};return Y.fromCredentials(t,r)},Jt=(t,e,r=0)=>{if(typeof t=="string"){let i=new Xe(Buffer.from(t,"hex")).derive(oe.HARDENED_KEY_START+1852).derive(oe.HARDENED_KEY_START+1815).derive(oe.HARDENED_KEY_START+e),n=i.derive(0).derive(r).toPrivateKey(),a=i.derive(2).derive(0).toPrivateKey();return{paymentKey:n,stakeKey:a}}else{let s=new E(Buffer.from(t[0],"hex"),!1),i=new E(Buffer.from(t[1],"hex"),!1);return{paymentKey:s,stakeKey:i}}},Xt=t=>{let e=new Ee(G(t.hex()));return y.newScriptPubkey(e)};var O=require("@cardano-sdk/core"),it=require("@cardano-sdk/crypto"),ot=require("@cardano-sdk/util"),Oe=require("@meshsdk/common");var tt=require("@cardano-sdk/core"),rt=require("@cardano-sdk/crypto"),P=require("@cardano-sdk/util"),st=require("@meshsdk/common");var er=t=>{let e=b.fromString(t);if(e===null)throw new Error("Invalid address");return e},tr=t=>Ie.fromBytes((0,st.toBytes)(t)),Ke=t=>j.fromHexBlob((0,P.HexBlob)(t)),De=t=>v.fromCbor((0,P.HexBlob)(t)),J=(t,e)=>{switch(e){case"V1":return V.fromCbor((0,P.HexBlob)(t));case"V2":return A.fromCbor((0,P.HexBlob)(t));case"V3":return H.fromCbor((0,P.HexBlob)(t));default:throw new Error("Invalid Plutus script version")}},rr=t=>y.fromCbor((0,P.HexBlob)(t)),sr=t=>Ce.fromEd25519KeyHashHex((0,rt.Ed25519KeyHashHex)(t)),ke=t=>S.fromCbor((0,P.HexBlob)(t)),ir=t=>F.fromCbor((0,P.HexBlob)(t)),or=t=>C.fromCbor((0,P.HexBlob)(t)),Ne=t=>D.fromCbor((0,tt.TxCBOR)(t)),ze=t=>I.fromHexBlob((0,P.HexBlob)(t));var R=t=>b.fromBech32(t),X=t=>Q.fromAddress(R(t)),ne=t=>N.fromAddress(R(t)),Me=t=>Y.fromAddress(R(t)),nr=t=>{let e=t.output().datum()?t.output().datum()?.toCbor().toString():void 0,r=t.output().scriptRef()?t.output().scriptRef()?.toCbor().toString():void 0,s=t.output().datum()?.asInlineData()?t.output().datum()?.asInlineData()?.toCbor().toString():void 0;return{input:{outputIndex:Number(t.input().index()),txHash:t.input().transactionId()},output:{address:t.output().address().toBech32(),amount:nt(t.output().amount()),dataHash:e,plutusData:s,scriptRef:r}}},ar=t=>{let e=new x(ze(t.input.txHash),BigInt(t.input.outputIndex)),r=new k(R(t.output.address),_(t.output.amount));if(t.output.dataHash!==void 0&&r.setDatum(W.fromCore(Ke(t.output.dataHash))),t.output.plutusData!==void 0){let s=De(t.output.plutusData),i=new O.Serialization.Datum(void 0,s);r.setDatum(i)}return t.output.scriptRef!==void 0&&r.setScriptRef(ke(t.output.scriptRef)),new F(e,r)},pr=t=>t.toBech32(),nt=t=>{let e=[{unit:"lovelace",quantity:t.coin().toString()}],r=t.multiasset();if(r!==void 0){let s=Array.from(r.keys());for(let i=0;i<s.length;i+=1){let n=s[i];if(n!==void 0){let a=r.get(n);a!==void 0&&e.push({unit:n,quantity:a.toString()})}}}return e},Le=t=>{if("code"in t){let e=J(t.code,t.version);if(e instanceof V)return S.newPlutusV1Script(e);if(e instanceof A)return S.newPlutusV2Script(e);if(e instanceof H)return S.newPlutusV3Script(e)}return S.newNativeScript(q(t))},ur=t=>{let e=S.fromCbor((0,ot.HexBlob)(t)),r=e.asPlutusV3()?.toCbor().toString();if(r)return{code:r,version:"V3"};let s=e.asPlutusV2()?.toCbor().toString();if(s)return{code:s,version:"V2"};let i=e.asPlutusV1()?.toCbor().toString();if(i)return{code:i,version:"V1"};let n=e.asNative();if(!n)throw new Error("Invalid script");return We(n)},We=t=>{let e=r=>{let s=new Array;for(let i=0;i<r.length;i+=1){let n=r[i];n&&s.push(We(n))}return s};switch(t.kind()){case Be:{let r=t.asScriptAll();return{type:"all",scripts:e(r.nativeScripts())}}case Te:{let r=t.asScriptAny();return{type:"any",scripts:e(r.nativeScripts())}}case be:{let r=t.asScriptNOfK();return{type:"atLeast",required:r.required(),scripts:e(r.nativeScripts())}}case Ae:return{type:"after",slot:t.asTimelockStart().slot().toString()};case He:return{type:"before",slot:t.asTimelockExpiry().slot().toString()};case Ve:return{type:"sig",keyHash:t.asScriptPubkey().keyHash().toString()};default:throw new Error(`Script Kind: ${t.kind()}, is not supported`)}},q=t=>{let e=r=>{let s=[];return r.forEach(i=>{s.push(q(i))}),s};switch(t.type){case"all":return y.newScriptAll(new O.Serialization.ScriptAll(e(t.scripts)));case"any":return y.newScriptAny(new O.Serialization.ScriptAny(e(t.scripts)));case"atLeast":return y.newScriptNOfK(new O.Serialization.ScriptNOfK(e(t.scripts),t.required));case"after":return y.newTimelockStart(new O.Serialization.TimelockStart(L(parseInt(t.slot))));case"before":return y.newTimelockExpiry(new O.Serialization.TimelockExpiry(L(parseInt(t.slot))));case"sig":return y.newScriptPubkey(new O.Serialization.ScriptPubkey(it.Ed25519KeyHash.fromBytes((0,Oe.toBytes)(t.keyHash)).hex()))}},w=t=>{let e=r=>{let s=new fe;return r.forEach(i=>{s.add(w(i))}),s};switch(typeof t){case"string":return v.newBytes((0,Oe.toBytes)(t));case"number":return v.newInteger(BigInt(t));case"bigint":return v.newInteger(BigInt(t));case"object":if(t instanceof Array){let r=e(t);return v.newList(r)}else if(t instanceof Map){let r=new xe;return t.forEach((s,i)=>{r.insert(w(i),w(s))}),v.newMap(r)}else return v.newConstrPlutusData(new Pe(BigInt(t.alternative),e(t.fields)))}},_=t=>{let e=new Map;t.filter(i=>i.unit!=="lovelace").forEach(i=>{e.set($(i.unit),BigInt(i.quantity))});let r=t.find(i=>i.unit==="lovelace"),s=new C(BigInt(r?r.quantity:0));return(t.length>1||!r)&&s.setMultiasset(e),s};function U(t,e){let r=t.multiasset()??new Map;return e.multiasset()?.forEach((s,i)=>{let n=(r.get(i)??0n)+s;n==0n?r.delete(i):r.set(i,n)}),new C(BigInt(t.coin())+BigInt(e.coin()),r.size>0?r:void 0)}function at(t){let e=t.multiasset()?.entries(),r=new Map;if(e)for(let s of e)r.set(s[0],-s[1]);return new C(-t.coin(),r)}function qe(t,e){return U(t,at(e))}function _e(t){let e=t.multiasset()?.entries(),r=t.coin()<0n?t.coin():0n,s=new Map;if(e)for(let i of e)i[1]<0n&&s.set(i[0],i[1]);return new C(r,s)}function pt(t){let e=t.coin()==0n?0:1,r=t.multiasset();return r&&r.forEach(()=>{e+=1}),e}function Ue(t){return pt(t)==0}var ut=t=>Buffer.from(t,"hex");var dr=t=>w(t).hash().toString(),cr=(t,e=0)=>{let r=q(t);return N.fromCredentials(e,{hash:r.hash(),type:ae.Cardano.CredentialType.ScriptHash}).toAddress().toBech32()},lr=t=>q(t).hash().toString(),fr=t=>{try{let e=[X(t)?.getPaymentCredential().hash,ne(t)?.getPaymentCredential().hash].find(r=>r!==void 0);if(e!==void 0)return e.toString();throw new Error(`Couldn't resolve payment key hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolvePaymentKeyHash: ${e}.`)}},xr=(t,e=0)=>{let r=J(t.code,t.version);return N.fromCredentials(e,{hash:r.hash(),type:ae.Cardano.CredentialType.ScriptHash}).toAddress().toBech32()},Sr=t=>{try{let r=ne(t)?.getPaymentCredential().hash;if(r!==void 0)return r.toString();throw new Error(`Couldn't resolve script hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveScriptHash: ${e}.`)}},yr=t=>G(t).toString(),mr=t=>"not implemented",hr=t=>Le(t).toCbor().toString(),gr=t=>{try{let e=R(t),s=X(t)?.getStakeCredential().hash;if(s!==void 0)return Re(e.getNetworkId(),s).toAddress().toBech32();throw new Error(`Couldn't resolve reward address from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveRewardAddress: ${e}.`)}},Cr=t=>{try{let e=[X(t)?.getStakeCredential().hash,Me(t)?.getPaymentCredential().hash].find(r=>r!==void 0);if(e!==void 0)return e.toString();throw new Error(`Couldn't resolve stake key hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveStakeKeyHash: ${e}.`)}},Ir=t=>{let e=Ne(t).body(),r=(0,Fe.blake2b)(Fe.blake2b.BYTES).update(ut(e.toCbor())).digest();return ae.Cardano.TransactionId.fromHexBlob(dt.HexBlob.fromBytes(r))};var f=require("@cardano-sdk/core"),g=require("@cardano-sdk/util"),pe=require("@meshsdk/common");var Qe=require("@cardano-sdk/core"),Ye=M(require("@cardano-sdk/crypto"),1),ct=require("@cardano-sdk/crypto"),lt=require("@cardano-sdk/util"),vr=new Uint8Array([128]),Pr=new Uint8Array([160]),$e=t=>{let e=new Qe.Serialization.CborWriter;e.writeStartArray(t.length);for(let r of t)e.writeEncodedValue(Buffer.from(r.toCbor(),"hex"));return e.encode()},ft=(t,e,r)=>{let s=new Qe.Serialization.CborWriter;if(r&&r.length>0&&(!e||e.length===0))s.writeEncodedValue(vr),s.writeEncodedValue($e(r)),s.writeEncodedValue(Pr);else{if(!e||e.length===0)return;s.writeEncodedValue($e(e)),r&&r.length>0&&s.writeEncodedValue($e(r)),s.writeEncodedValue(Buffer.from(t.languageViewsEncoding(),"hex"))}return ct.Hash32ByteBase16.fromHexBlob(lt.HexBlob.fromBytes(Ye.blake2b(Ye.blake2b.BYTES).update(s.encode()).digest()))};var Ge=class{txBody;txWitnessSet;utxoContext=new Map;redeemerContext=new Map;scriptsProvided=new Set;datumsProvided=new Set;usedLanguages={0:!1,1:!1,2:!1};constructor(){this.txBody=new le(f.Serialization.CborSet.fromCore([],x.fromCore),[],BigInt(0),void 0),this.txWitnessSet=new re}serializePoolId(e){throw new Error("Method not implemented.")}serializeAddress(e,r){throw new Error("Method not implemented.")}serializeData(e){throw new Error("Method not implemented.")}deserializer={key:{deserializeAddress:function(e){throw new Error("Function not implemented.")}},script:{deserializeNativeScript:function(e){throw new Error("Function not implemented.")},deserializePlutusScript:function(e){throw new Error("Function not implemented.")}},cert:{deserializePoolId:function(e){throw new Error("Function not implemented.")}}};resolver={keys:{resolveStakeKeyHash:function(e){let r=R(e);return r.asReward()?.getPaymentCredential().type===z.KeyHash?r.asReward().getPaymentCredential().hash:""},resolvePrivateKey:function(e){throw new Error("Function not implemented.")},resolveRewardAddress:function(e){throw new Error("Function not implemented.")},resolveEd25519KeyHash:function(e){throw new Error("Function not implemented.")}},tx:{resolveTxHash:function(e){return D.fromCbor((0,f.TxCBOR)(e)).getId()}},data:{resolveDataHash:function(e){throw new Error("Function not implemented.")}},script:{resolveScriptRef:function(e){throw new Error("Function not implemented.")}}};serializeTxBody=(e,r)=>{let{inputs:s,outputs:i,collaterals:n,referenceInputs:a,mints:c,changeAddress:u,certificates:K,validityRange:B,requiredSignatures:m,metadata:T}=e;return c.sort((p,d)=>p.policyId.localeCompare(d.policyId)),s.sort((p,d)=>p.txIn.txHash===d.txIn.txHash?p.txIn.txIndex-d.txIn.txIndex:p.txIn.txHash.localeCompare(d.txIn.txHash)),this.addAllInputs(s),this.addAllOutputs(i),this.addAllMints(c),this.addAllCollateralInputs(n),this.addAllReferenceInputs(a),this.setValidityInterval(B),this.buildWitnessSet(),this.balanceTx(u,m.length,r),new D(this.txBody,this.txWitnessSet).toCbor()};addSigningKeys=(e,r)=>{let s=D.fromCbor((0,f.TxCBOR)(e)),i=s.witnessSet(),n=i.vkeys(),a=n?[...n.values()]:[];for(let c=0;c<r.length;c++){let u=r[c];if(u){u.length===68&&u.substring(0,4)==="5820"&&(u=u.substring(4));let K=new E(Buffer.from(u,"hex"),!1),B=K.sign(Buffer.from(s.getId(),"hex"));a.push(new Z(se(K.toPublicKey().toBytes().toString("hex")),ie(B.toString("hex"))))}}return i.setVkeys(f.Serialization.CborSet.fromCore(a.map(c=>c.toCore()),Z.fromCore)),s.setWitnessSet(i),s.toCbor()};addAllInputs=e=>{for(let r=0;r<e.length;r+=1){let s=e[r];if(s)switch(s.type){case"PubKey":this.addTxIn(s);break;case"Script":this.addScriptTxIn(s);break;case"SimpleScript":this.addSimpleScriptTxIn(s)}}};addTxIn=e=>{let r=new x(I(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=this.txBody.inputs(),i=[...s.values()];if(i.find(a=>{a.index()==r.index()&&a.transactionId==r.transactionId}))throw new Error("Duplicate input added to tx body");i.push(r),s.setValues(i);let n=new k(b.fromBech32(e.txIn.address),_(e.txIn.amount));this.utxoContext.set(r,n),this.txBody.setInputs(s)};addScriptTxIn=e=>{if(this.addTxIn({type:"PubKey",txIn:e.txIn}),!e.scriptTxIn.scriptSource)throw new Error("A script input had no script source");if(!e.scriptTxIn.datumSource)throw new Error("A script input had no datum source");if(!e.scriptTxIn.redeemer)throw new Error("A script input had no redeemer");if(e.scriptTxIn.scriptSource.type==="Provided")switch(e.scriptTxIn.scriptSource.script.version){case"V1":{this.scriptsProvided.add(S.newPlutusV1Script(V.fromCbor((0,g.HexBlob)(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[h.V1]=!0;break}case"V2":{this.scriptsProvided.add(S.newPlutusV2Script(A.fromCbor((0,g.HexBlob)(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[h.V2]=!0;break}case"V3":{this.scriptsProvided.add(S.newPlutusV3Script(H.fromCbor((0,g.HexBlob)(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[h.V3]=!0;break}}else if(e.scriptTxIn.scriptSource.type==="Inline"){let i=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),n=[...i.values()];switch(n.push(new x(I(e.scriptTxIn.scriptSource.txHash),BigInt(e.scriptTxIn.scriptSource.txIndex))),i.setValues(n),this.txBody.setReferenceInputs(i),e.scriptTxIn.scriptSource.version){case"V1":{this.usedLanguages[h.V1]=!0;break}case"V2":{this.usedLanguages[h.V2]=!0;break}case"V3":{this.usedLanguages[h.V3]=!0;break}}}if(e.scriptTxIn.datumSource.type==="Provided")this.datumsProvided.add(w(e.scriptTxIn.datumSource.data.content));else if(e.scriptTxIn.datumSource.type==="Inline"){let i=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),n=[...i.values()];n.push(new x(I(e.txIn.txHash),BigInt(e.txIn.txIndex))),i.setValues(n),this.txBody.setReferenceInputs(i)}let r=new x(I(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=e.scriptTxIn.redeemer.exUnits;this.redeemerContext.set(r,new ye(me.Spend,BigInt(0),w(e.scriptTxIn.redeemer.data.content),new we(BigInt(s.mem),BigInt(s.steps))))};addSimpleScriptTxIn=e=>{if(this.addTxIn({type:"PubKey",txIn:e.txIn}),!e.simpleScriptTxIn.scriptSource)throw new Error("A native script input had no script source");if(e.simpleScriptTxIn.scriptSource.type==="Provided")this.scriptsProvided.add(S.newNativeScript(y.fromCbor((0,g.HexBlob)(e.simpleScriptTxIn.scriptSource.script))));else if(e.simpleScriptTxIn.scriptSource.type==="Inline"&&e.simpleScriptTxIn.scriptSource.txInInfo.type==="Inline"){let r=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),s=[...r.values()];s.push(new x(I(e.simpleScriptTxIn.scriptSource.txInInfo.txHash),BigInt(e.simpleScriptTxIn.scriptSource.txInInfo.txIndex))),r.setValues(s),this.txBody.setReferenceInputs(r)}};addAllOutputs=e=>{for(let r=0;r<e.length;r++)this.addOutput(e[r])};addOutput=e=>{let r=this.txBody.outputs(),s=new k(b.fromBech32(e.address),_(e.amount));if(e.datum?.type==="Hash"?s.setDatum(W.newDataHash(j.fromHexBlob((0,g.HexBlob)(w(e.datum.data.content).hash())))):e.datum?.type==="Inline"&&s.setDatum(W.newInlineData(w(e.datum.data.content))),e.referenceScript)switch(e.referenceScript.version){case"V1":{s.setScriptRef(S.newPlutusV1Script(V.fromCbor((0,g.HexBlob)(e.referenceScript.code))));break}case"V2":{s.setScriptRef(S.newPlutusV2Script(A.fromCbor((0,g.HexBlob)(e.referenceScript.code))));break}case"V3":{s.setScriptRef(S.newPlutusV3Script(H.fromCbor((0,g.HexBlob)(e.referenceScript.code))));break}}r.push(s),this.txBody.setOutputs(r)};addAllReferenceInputs=e=>{for(let r=0;r<e.length;r++)this.addReferenceIput(e[r])};addReferenceIput=e=>{let r=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),s=[...r.values()];s.push(new x(I.fromHexBlob((0,g.HexBlob)(e.txHash)),BigInt(e.txIndex))),r.setValues(s),this.txBody.setReferenceInputs(r)};addAllMints=e=>{for(let r=0;r<e.length;r++)this.addMint(e[r])};addMint=e=>{let r=this.txBody.mint()??new Map,s=e.policyId+e.assetName;for(let i of r.keys())if(i.toString()==s)throw new Error("The same asset is already in the mint field");if(r.set($.fromParts(he(e.policyId),ge(e.assetName)),BigInt(e.amount)),this.txBody.setMint(r),e.type==="Native"){if(!e.scriptSource)throw new Error("Script source not provided for native script mint");let i=e.scriptSource;if(!i)throw new Error("A script source for a native script was not a native script somehow");if(i.type==="Provided")this.scriptsProvided.add(S.newNativeScript(y.fromCbor((0,g.HexBlob)(i.scriptCode))));else if(i.type==="Inline"){let n=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),a=[...n.values()];a.push(new x(I(i.txHash),BigInt(i.txIndex))),n.setValues(a),this.txBody.setReferenceInputs(n)}}else if(e.type==="Plutus"){if(!e.scriptSource)throw new Error("Script source not provided for plutus script mint");let i=e.scriptSource;if(!i)throw new Error("A script source for a plutus mint was not plutus script somehow");if(i.type==="Provided")switch(i.script.version){case"V1":this.scriptsProvided.add(S.newPlutusV1Script(V.fromCbor((0,g.HexBlob)(i.script.code))));break;case"V2":this.scriptsProvided.add(S.newPlutusV2Script(A.fromCbor((0,g.HexBlob)(i.script.code))));break;case"V3":this.scriptsProvided.add(S.newPlutusV3Script(H.fromCbor((0,g.HexBlob)(i.script.code))));break}else if(i.type==="Inline"){let n=this.txBody.referenceInputs()??f.Serialization.CborSet.fromCore([],x.fromCore),a=[...n.values()];switch(a.push(new x(I(i.txHash),BigInt(i.txIndex))),n.setValues(a),this.txBody.setReferenceInputs(n),i.version){case"V1":{this.usedLanguages[h.V1]=!0;break}case"V2":{this.usedLanguages[h.V2]=!0;break}case"V3":{this.usedLanguages[h.V3]=!0;break}}}}};addAllCollateralInputs=e=>{for(let r=0;r<e.length;r++)this.addCollateralInput(e[r])};addCollateralInput=e=>{let r=new x(I(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=this.txBody.collateral()??f.Serialization.CborSet.fromCore([],x.fromCore),i=[...s.values()];if(i.find(a=>{a.index()==r.index()&&a.transactionId==r.transactionId}))throw new Error("Duplicate input added to tx body");i.push(r),s.setValues(i);let n=new k(b.fromBech32(e.txIn.address),_(e.txIn.amount));this.utxoContext.set(r,n),this.txBody.setCollateral(s)};setValidityInterval=e=>{e.invalidBefore&&this.txBody.setValidityStartInterval(L(e.invalidBefore)),e.invalidHereafter&&this.txBody.setTtl(L(e.invalidHereafter))};buildWitnessSet=()=>{let e=this.txBody.inputs();for(let p=0;p<e.size();p+=1){let d=e.values().at(p);if(d){let Ze=this.redeemerContext.get(d);Ze&&Ze.setIndex(BigInt(p))}}let r=this.txWitnessSet.redeemers()??Se.fromCore([]),s=[...r.values()];this.redeemerContext.forEach(p=>{s.push(p)}),r.setValues(s),this.txWitnessSet.setRedeemers(r);let i=this.txWitnessSet.nativeScripts()??f.Serialization.CborSet.fromCore([],y.fromCore),n=this.txWitnessSet.plutusV1Scripts()??f.Serialization.CborSet.fromCore([],V.fromCore),a=this.txWitnessSet.plutusV2Scripts()??f.Serialization.CborSet.fromCore([],A.fromCore),c=this.txWitnessSet.plutusV3Scripts()??f.Serialization.CborSet.fromCore([],H.fromCore);this.scriptsProvided.forEach(p=>{if(p.asNative()!==void 0){let d=[...i.values()];d.push(p.asNative()),i.setValues(d)}else if(p.asPlutusV1()!==void 0){let d=[...n.values()];d.push(p.asPlutusV1()),n.setValues(d)}else if(p.asPlutusV2()!==void 0){let d=[...a.values()];d.push(p.asPlutusV2()),a.setValues(d)}else if(p.asPlutusV3()!==void 0){let d=[...c.values()];d.push(p.asPlutusV3()),c.setValues(d)}this.txWitnessSet.setNativeScripts(i),this.txWitnessSet.setPlutusV1Scripts(n),this.txWitnessSet.setPlutusV2Scripts(a),this.txWitnessSet.setPlutusV3Scripts(c)});let u=this.txWitnessSet.plutusData()??f.Serialization.CborSet.fromCore([],v.fromCore);this.datumsProvided.forEach(p=>{let d=[...u.values()];d.push(p),u.setValues(d)}),this.txWitnessSet.setPlutusData(u);let K=f.Serialization.CostModel.newPlutusV1(pe.DEFAULT_V1_COST_MODEL_LIST),B=f.Serialization.CostModel.newPlutusV2(pe.DEFAULT_V2_COST_MODEL_LIST),m=new f.Serialization.Costmdls;this.usedLanguages[h.V1]&&m.insert(K),this.usedLanguages[h.V2]&&m.insert(B),this.usedLanguages[h.V3];let T=ft(m,r.size()>0?[...r.values()]:void 0,u.size()>0?[...u.values()]:void 0);T&&this.txBody.setScriptDataHash(T)};balanceTx=(e,r,s)=>{if(e==="")throw new Error("Can't balance tx without a change address");let i=this.txBody.inputs().values(),n=new C(BigInt(0));for(let m=0;m<i.length;m++){let T=i[m];if(!T)throw new Error("Invalid input found");let p=this.utxoContext.get(T);if(!p)throw new Error(`Unable to resolve input: ${T.toCbor()}`);n=U(n,p.amount())}let a=this.txBody.withdrawals();a&&a.forEach(m=>{n=U(n,new C(m))}),n=U(n,new C(BigInt(0),this.txBody.mint()));let c=this.txBody.outputs();for(let m=0;m<c.length;m++){let T=c.at(m);T&&(n=qe(n,T.amount()))}if(n.coin()<0||!Ue(_e(n)))throw new Error("Not enough funds to satisfy outputs");c.push(new k(b.fromBech32(e),n)),this.txBody.setOutputs(c),this.txBody.setFee(BigInt("10000000"));let u=this.createDummyTx(r),K=s.minFeeB+u.toCbor().length/2*Number(s.coinsPerUtxoSize);this.txBody.setFee(BigInt(K));let B=c.pop();if(!B)throw new Error("Somehow the output length was 0 after attempting to calculate fees");B.amount().setCoin(B.amount().coin()-BigInt(K)),c.push(B),this.txBody.setOutputs(c)};createDummyTx=e=>{let r=new re,s=[];for(let i=0;i<e;i++)s.push([se("0".repeat(64)),ie("0".repeat(128))]);return r.setVkeys(f.Serialization.CborSet.fromCore(s,Z.fromCore)),new D(this.txBody,r)}};var Br=M(require("@cardano-sdk/util"),1),Tr=M(require("@cardano-sdk/crypto"),1),br=M(require("@cardano-sdk/core"),1);0&&(module.exports={Address,AddressType,AssetFingerprint,AssetId,AssetName,BaseAddress,Bip32PrivateKey,Bip32PrivateKeyHex,Cardano,CardanoSDK,CardanoSDKSerializer,CardanoSDKUtil,CborSet,CborWriter,Certificate,CertificateType,ConstrPlutusData,CostModel,Costmdls,Credential,CredentialType,Crypto,Datum,DatumHash,DatumKind,Ed25519KeyHash,Ed25519KeyHashHex,Ed25519PrivateExtendedKeyHex,Ed25519PrivateNormalKeyHex,Ed25519PublicKey,Ed25519PublicKeyHex,Ed25519Signature,Ed25519SignatureHex,EnterpriseAddress,ExUnits,Hash,Hash28ByteBase16,Hash32ByteBase16,NativeScript,NetworkId,PaymentAddress,PlutusData,PlutusLanguageVersion,PlutusList,PlutusMap,PlutusV1Script,PlutusV2Script,PlutusV3Script,PolicyId,PoolId,PrivateKey,PublicKey,Redeemer,RedeemerPurpose,RedeemerTag,Redeemers,RequireAllOf,RequireAnyOf,RequireNOf,RequireSignature,RequireTimeAfter,RequireTimeBefore,RewardAccount,RewardAddress,Script,ScriptHash,ScriptPubkey,Serialization,Slot,StakeDelegation,StakeRegistration,Transaction,TransactionBody,TransactionId,TransactionInput,TransactionOutput,TransactionUnspentOutput,TransactionWitnessSet,Value,VkeyWitness,VrfVkBech32,addressToBech32,assetTypes,buildBaseAddress,buildBip32PrivateKey,buildEnterpriseAddress,buildKeys,buildRewardAddress,buildScriptPubkey,checkSignature,deserializeAddress,deserializeDataHash,deserializeEd25519KeyHash,deserializeNativeScript,deserializePlutusData,deserializePlutusScript,deserializeScriptHash,deserializeScriptRef,deserializeTx,deserializeTxHash,deserializeTxUnspentOutput,deserializeValue,empty,fromNativeScript,fromScriptRef,fromTxUnspentOutput,fromValue,mergeValue,negateValue,negatives,resolveDataHash,resolveNativeScriptAddress,resolveNativeScriptHash,resolvePaymentKeyHash,resolvePlutusScriptAddress,resolvePlutusScriptHash,resolvePoolId,resolvePrivateKey,resolveRewardAddress,resolveScriptRef,resolveStakeKeyHash,resolveTxHash,signData,subValue,toAddress,toBaseAddress,toEnterpriseAddress,toNativeScript,toPlutusData,toRewardAddress,toScriptRef,toTxUnspentOutput,toValue});
package/dist/index.d.cts CHANGED
@@ -238,6 +238,7 @@ declare class CardanoSDKSerializer implements IMeshTxSerializer {
238
238
  private datumsProvided;
239
239
  private usedLanguages;
240
240
  constructor();
241
+ serializePoolId(hash: string): string;
241
242
  serializeAddress(address: DeserializedAddress, networkId?: 0 | 1): string;
242
243
  serializeData(data: BuilderData): string;
243
244
  deserializer: IDeserializer;
package/dist/index.d.ts CHANGED
@@ -238,6 +238,7 @@ declare class CardanoSDKSerializer implements IMeshTxSerializer {
238
238
  private datumsProvided;
239
239
  private usedLanguages;
240
240
  constructor();
241
+ serializePoolId(hash: string): string;
241
242
  serializeAddress(address: DeserializedAddress, networkId?: 0 | 1): string;
242
243
  serializeData(data: BuilderData): string;
243
244
  deserializer: IDeserializer;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Cardano as pi,Serialization as ui}from"@cardano-sdk/core";import de from"@stricahq/bip32ed25519";import Je from"hash.js";var K=class extends de.PrivateKey{constructor(e,r=!0){if(!r){let s=Je.sha512().update(e).digest();s[0]&&s[31]&&(s[0]&=248,s[31]&=63,s[31]|=64),e=Buffer.from(s)}super(e)}},{PublicKey:ee,Bip32PrivateKey:ce,Bip32PublicKey:mt}=de;import{Cardano as u,Serialization as n}from"@cardano-sdk/core";import*as f from"@cardano-sdk/crypto";import{typedHex as le}from"@cardano-sdk/util";var L=u.Slot,I=n.Value,k=n.Transaction,v=u.TransactionId,fe=n.TransactionBody,te=n.TransactionWitnessSet,F=n.TransactionUnspentOutput,x=n.TransactionInput,N=n.TransactionOutput,P=n.PlutusData,xe=n.PlutusList,Se=n.PlutusMap,ye=n.Redeemers,me=n.Redeemer,It=u.RedeemerPurpose,he=n.RedeemerTag,S=n.Script,ge=u.PolicyId,Ce=u.AssetName,$=u.AssetId,Ie=f.Hash28ByteBase16,V=u.Address,Y=u.RewardAddress,vt=u.AddressType,Q=u.BaseAddress,z=u.EnterpriseAddress,Pt=u.PaymentAddress,wt=u.AssetFingerprint,Bt=n.Credential,re=f.Ed25519PublicKeyHex,Tt=t=>le(t,64),bt=t=>le(t,128),ve=f.Ed25519KeyHash,G=f.Ed25519KeyHashHex,Vt=f.Hash28ByteBase16,At=f.Hash32ByteBase16,O=u.CredentialType,Ht=n.Certificate,Et=u.PoolId,Rt=n.StakeRegistration,Kt=n.StakeDelegation,Dt=u.CertificateType,Z=n.VkeyWitness,se=f.Ed25519SignatureHex,kt=f.Ed25519PublicKey,Nt=f.Ed25519Signature,Pe=f.Bip32PrivateKey,zt=f.Bip32PrivateKeyHex,g=u.PlutusLanguageVersion,h=n.NativeScript,A=n.PlutusV1Script,H=n.PlutusV2Script,E=n.PlutusV3Script,Ot=n.Costmdls,Mt=n.CostModel,Lt=n.CborWriter,we=n.ConstrPlutusData,Wt=u.RewardAccount,qt=n.Hash,j=f.Hash32ByteBase16,W=n.Datum,Be=n.ExUnits,_t=u.NetworkId,Ut=n.DatumKind,Ft=n.CborSet,Te=u.NativeScriptKind.RequireAllOf,be=u.NativeScriptKind.RequireAnyOf,Ve=u.NativeScriptKind.RequireNOf,Ae=u.NativeScriptKind.RequireSignature,He=u.NativeScriptKind.RequireTimeAfter,Ee=u.NativeScriptKind.RequireTimeBefore,$t=u.VrfVkBech32,Re=n.ScriptPubkey;var Xt=(t,e)=>{let r=Buffer.from(t),s=e.sign(r);return{key:e.toPublicKey().toBytes().toString("hex"),signature:s.toString("hex")}},er=(t,{key:e,signature:r})=>new ee(Buffer.from(e,"hex")).verify(Buffer.from(r,"hex"),Buffer.from(t));import{Cardano as ne}from"@cardano-sdk/core";import{blake2b as Ye}from"@cardano-sdk/crypto";import{HexBlob as pt}from"@cardano-sdk/util";import{pbkdf2Sync as Xe}from"pbkdf2";import{HARDENED_KEY_START as ie}from"@meshsdk/common";var pr=(t,e,r)=>Q.fromCredentials(t,{hash:e,type:O.KeyHash},{hash:r,type:O.KeyHash}),ur=(t,e)=>z.fromCredentials(t,{hash:e,type:O.KeyHash}),dr=(t,e="")=>{let i="sha512",o=d=>(d[0]!==void 0&&(d[0]&=248),d[31]!==void 0&&(d[31]&=31,d[31]|=64),d),a=Buffer.from(t,"hex"),l=Xe(e,a,4096,96,i);return Pe.fromBytes(o(l))},Ke=(t,e)=>{let r={type:O.KeyHash,hash:e};return Y.fromCredentials(t,r)},cr=(t,e,r=0)=>{if(typeof t=="string"){let i=new ce(Buffer.from(t,"hex")).derive(ie+1852).derive(ie+1815).derive(ie+e),o=i.derive(0).derive(r).toPrivateKey(),a=i.derive(2).derive(0).toPrivateKey();return{paymentKey:o,stakeKey:a}}else{let s=new K(Buffer.from(t[0],"hex"),!1),i=new K(Buffer.from(t[1],"hex"),!1);return{paymentKey:s,stakeKey:i}}},lr=t=>{let e=new Re(G(t.hex()));return h.newScriptPubkey(e)};import{Serialization as M}from"@cardano-sdk/core";import{Ed25519KeyHash as st}from"@cardano-sdk/crypto";import{HexBlob as it}from"@cardano-sdk/util";import{toBytes as Me}from"@meshsdk/common";import{TxCBOR as et}from"@cardano-sdk/core";import{Ed25519KeyHashHex as tt}from"@cardano-sdk/crypto";import{HexBlob as T}from"@cardano-sdk/util";import{toBytes as rt}from"@meshsdk/common";var Cr=t=>{let e=V.fromString(t);if(e===null)throw new Error("Invalid address");return e},Ir=t=>ve.fromBytes(rt(t)),De=t=>j.fromHexBlob(T(t)),ke=t=>P.fromCbor(T(t)),J=(t,e)=>{switch(e){case"V1":return A.fromCbor(T(t));case"V2":return H.fromCbor(T(t));case"V3":return E.fromCbor(T(t));default:throw new Error("Invalid Plutus script version")}},vr=t=>h.fromCbor(T(t)),Pr=t=>Ie.fromEd25519KeyHashHex(tt(t)),Ne=t=>S.fromCbor(T(t)),wr=t=>F.fromCbor(T(t)),Br=t=>I.fromCbor(T(t)),ze=t=>k.fromCbor(et(t)),Oe=t=>v.fromHexBlob(T(t));var D=t=>V.fromBech32(t),X=t=>Q.fromAddress(D(t)),oe=t=>z.fromAddress(D(t)),Le=t=>Y.fromAddress(D(t)),_r=t=>{let e=t.output().datum()?t.output().datum()?.toCbor().toString():void 0,r=t.output().scriptRef()?t.output().scriptRef()?.toCbor().toString():void 0,s=t.output().datum()?.asInlineData()?t.output().datum()?.asInlineData()?.toCbor().toString():void 0;return{input:{outputIndex:Number(t.input().index()),txHash:t.input().transactionId()},output:{address:t.output().address().toBech32(),amount:ot(t.output().amount()),dataHash:e,plutusData:s,scriptRef:r}}},Ur=t=>{let e=new x(Oe(t.input.txHash),BigInt(t.input.outputIndex)),r=new N(D(t.output.address),_(t.output.amount));if(t.output.dataHash!==void 0&&r.setDatum(W.fromCore(De(t.output.dataHash))),t.output.plutusData!==void 0){let s=ke(t.output.plutusData),i=new M.Datum(void 0,s);r.setDatum(i)}return t.output.scriptRef!==void 0&&r.setScriptRef(Ne(t.output.scriptRef)),new F(e,r)},Fr=t=>t.toBech32(),ot=t=>{let e=[{unit:"lovelace",quantity:t.coin().toString()}],r=t.multiasset();if(r!==void 0){let s=Array.from(r.keys());for(let i=0;i<s.length;i+=1){let o=s[i];if(o!==void 0){let a=r.get(o);a!==void 0&&e.push({unit:o,quantity:a.toString()})}}}return e},We=t=>{if("code"in t){let e=J(t.code,t.version);if(e instanceof A)return S.newPlutusV1Script(e);if(e instanceof H)return S.newPlutusV2Script(e);if(e instanceof E)return S.newPlutusV3Script(e)}return S.newNativeScript(q(t))},$r=t=>{let e=S.fromCbor(it(t)),r=e.asPlutusV3()?.toCbor().toString();if(r)return{code:r,version:"V3"};let s=e.asPlutusV2()?.toCbor().toString();if(s)return{code:s,version:"V2"};let i=e.asPlutusV1()?.toCbor().toString();if(i)return{code:i,version:"V1"};let o=e.asNative();if(!o)throw new Error("Invalid script");return qe(o)},qe=t=>{let e=r=>{let s=new Array;for(let i=0;i<r.length;i+=1){let o=r[i];o&&s.push(qe(o))}return s};switch(t.kind()){case Te:{let r=t.asScriptAll();return{type:"all",scripts:e(r.nativeScripts())}}case be:{let r=t.asScriptAny();return{type:"any",scripts:e(r.nativeScripts())}}case Ve:{let r=t.asScriptNOfK();return{type:"atLeast",required:r.required(),scripts:e(r.nativeScripts())}}case He:return{type:"after",slot:t.asTimelockStart().slot().toString()};case Ee:return{type:"before",slot:t.asTimelockExpiry().slot().toString()};case Ae:return{type:"sig",keyHash:t.asScriptPubkey().keyHash().toString()};default:throw new Error(`Script Kind: ${t.kind()}, is not supported`)}},q=t=>{let e=r=>{let s=[];return r.forEach(i=>{s.push(q(i))}),s};switch(t.type){case"all":return h.newScriptAll(new M.ScriptAll(e(t.scripts)));case"any":return h.newScriptAny(new M.ScriptAny(e(t.scripts)));case"atLeast":return h.newScriptNOfK(new M.ScriptNOfK(e(t.scripts),t.required));case"after":return h.newTimelockStart(new M.TimelockStart(L(parseInt(t.slot))));case"before":return h.newTimelockExpiry(new M.TimelockExpiry(L(parseInt(t.slot))));case"sig":return h.newScriptPubkey(new M.ScriptPubkey(st.fromBytes(Me(t.keyHash)).hex()))}},b=t=>{let e=r=>{let s=new xe;return r.forEach(i=>{s.add(b(i))}),s};switch(typeof t){case"string":return P.newBytes(Me(t));case"number":return P.newInteger(BigInt(t));case"bigint":return P.newInteger(BigInt(t));case"object":if(t instanceof Array){let r=e(t);return P.newList(r)}else if(t instanceof Map){let r=new Se;return t.forEach((s,i)=>{r.insert(b(i),b(s))}),P.newMap(r)}else return P.newConstrPlutusData(new we(BigInt(t.alternative),e(t.fields)))}},_=t=>{let e=new Map;t.filter(i=>i.unit!=="lovelace").forEach(i=>{e.set($(i.unit),BigInt(i.quantity))});let r=t.find(i=>i.unit==="lovelace"),s=new I(BigInt(r?r.quantity:0));return(t.length>1||!r)&&s.setMultiasset(e),s};function U(t,e){let r=t.multiasset()??new Map;return e.multiasset()?.forEach((s,i)=>{let o=(r.get(i)??0n)+s;o==0n?r.delete(i):r.set(i,o)}),new I(BigInt(t.coin())+BigInt(e.coin()),r.size>0?r:void 0)}function nt(t){let e=t.multiasset()?.entries(),r=new Map;if(e)for(let s of e)r.set(s[0],-s[1]);return new I(-t.coin(),r)}function _e(t,e){return U(t,nt(e))}function Ue(t){let e=t.multiasset()?.entries(),r=t.coin()<0n?t.coin():0n,s=new Map;if(e)for(let i of e)i[1]<0n&&s.set(i[0],i[1]);return new I(r,s)}function at(t){let e=t.coin()==0n?0:1,r=t.multiasset();return r&&r.forEach(()=>{e+=1}),e}function Fe(t){return at(t)==0}var $e=t=>Buffer.from(t,"hex");var ds=t=>b(t).hash().toString(),cs=(t,e=0)=>{let r=q(t);return z.fromCredentials(e,{hash:r.hash(),type:ne.CredentialType.ScriptHash}).toAddress().toBech32()},ls=t=>q(t).hash().toString(),fs=t=>{try{let e=[X(t)?.getPaymentCredential().hash,oe(t)?.getPaymentCredential().hash].find(r=>r!==void 0);if(e!==void 0)return e.toString();throw new Error(`Couldn't resolve payment key hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolvePaymentKeyHash: ${e}.`)}},xs=(t,e=0)=>{let r=J(t.code,t.version);return z.fromCredentials(e,{hash:r.hash(),type:ne.CredentialType.ScriptHash}).toAddress().toBech32()},Ss=t=>{try{let r=oe(t)?.getPaymentCredential().hash;if(r!==void 0)return r.toString();throw new Error(`Couldn't resolve script hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveScriptHash: ${e}.`)}},ys=t=>G(t).toString(),ms=t=>(console.log(t),"not implemented"),hs=t=>We(t).toCbor().toString(),gs=t=>{try{let e=D(t),s=X(t)?.getStakeCredential().hash;if(s!==void 0)return Ke(e.getNetworkId(),s).toAddress().toBech32();throw new Error(`Couldn't resolve reward address from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveRewardAddress: ${e}.`)}},Cs=t=>{try{let e=[X(t)?.getStakeCredential().hash,Le(t)?.getPaymentCredential().hash].find(r=>r!==void 0);if(e!==void 0)return e.toString();throw new Error(`Couldn't resolve stake key hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveStakeKeyHash: ${e}.`)}},Is=t=>{let e=ze(t).body(),r=Ye(Ye.BYTES).update($e(e.toCbor())).digest();return ne.TransactionId.fromHexBlob(pt.fromBytes(r))};import{Serialization as y,TxCBOR as Ze}from"@cardano-sdk/core";import{HexBlob as C}from"@cardano-sdk/util";import{DEFAULT_V1_COST_MODEL_LIST as ft,DEFAULT_V2_COST_MODEL_LIST as xt}from"@meshsdk/common";import{Serialization as Qe}from"@cardano-sdk/core";import*as pe from"@cardano-sdk/crypto";import{Hash32ByteBase16 as ut}from"@cardano-sdk/crypto";import{HexBlob as dt}from"@cardano-sdk/util";var ct=new Uint8Array([128]),lt=new Uint8Array([160]),ae=t=>{let e=new Qe.CborWriter;e.writeStartArray(t.length);for(let r of t)e.writeEncodedValue(Buffer.from(r.toCbor(),"hex"));return e.encode()},Ge=(t,e,r)=>{let s=new Qe.CborWriter;if(r&&r.length>0&&(!e||e.length===0))s.writeEncodedValue(ct),s.writeEncodedValue(ae(r)),s.writeEncodedValue(lt);else{if(!e||e.length===0)return;s.writeEncodedValue(ae(e)),r&&r.length>0&&s.writeEncodedValue(ae(r)),s.writeEncodedValue(Buffer.from(t.languageViewsEncoding(),"hex"))}return ut.fromHexBlob(dt.fromBytes(pe.blake2b(pe.blake2b.BYTES).update(s.encode()).digest()))};var je=class{txBody;txWitnessSet;utxoContext=new Map;redeemerContext=new Map;scriptsProvided=new Set;datumsProvided=new Set;usedLanguages={0:!1,1:!1,2:!1};constructor(){this.txBody=new fe(y.CborSet.fromCore([],x.fromCore),[],BigInt(0),void 0),this.txWitnessSet=new te}serializeAddress(e,r){throw new Error("Method not implemented.")}serializeData(e){throw new Error("Method not implemented.")}deserializer={key:{deserializeAddress:function(e){throw new Error("Function not implemented.")}},script:{deserializeNativeScript:function(e){throw new Error("Function not implemented.")},deserializePlutusScript:function(e){throw new Error("Function not implemented.")}}};resolver={keys:{resolveStakeKeyHash:function(e){let r=D(e);return r.asReward()?.getPaymentCredential().type===O.KeyHash?r.asReward().getPaymentCredential().hash:""},resolvePrivateKey:function(e){throw new Error("Function not implemented.")},resolveRewardAddress:function(e){throw new Error("Function not implemented.")},resolveEd25519KeyHash:function(e){throw new Error("Function not implemented.")}},tx:{resolveTxHash:function(e){return k.fromCbor(Ze(e)).getId()}},data:{resolveDataHash:function(e){throw new Error("Function not implemented.")}},script:{resolveScriptRef:function(e){throw new Error("Function not implemented.")}},pool:{resolvePoolId:function(e){throw new Error("Function not implemented.")}}};serializeTxBody=(e,r)=>{let{inputs:s,outputs:i,collaterals:o,referenceInputs:a,mints:l,changeAddress:d,certificates:R,validityRange:w,requiredSignatures:m,metadata:B}=e;return l.sort((p,c)=>p.policyId.localeCompare(c.policyId)),s.sort((p,c)=>p.txIn.txHash===c.txIn.txHash?p.txIn.txIndex-c.txIn.txIndex:p.txIn.txHash.localeCompare(c.txIn.txHash)),this.addAllInputs(s),this.addAllOutputs(i),this.addAllMints(l),this.addAllCollateralInputs(o),this.addAllReferenceInputs(a),this.setValidityInterval(w),this.buildWitnessSet(),this.balanceTx(d,m.length,r),new k(this.txBody,this.txWitnessSet).toCbor()};addSigningKeys=(e,r)=>{let s=k.fromCbor(Ze(e)),i=s.witnessSet(),o=i.vkeys(),a=o?[...o.values()]:[];for(let l=0;l<r.length;l++){let d=r[l];if(d){d.length===68&&d.substring(0,4)==="5820"&&(d=d.substring(4));let R=new K(Buffer.from(d,"hex"),!1),w=R.sign(Buffer.from(s.getId(),"hex"));a.push(new Z(re(R.toPublicKey().toBytes().toString("hex")),se(w.toString("hex"))))}}return i.setVkeys(y.CborSet.fromCore(a.map(l=>l.toCore()),Z.fromCore)),s.setWitnessSet(i),s.toCbor()};addAllInputs=e=>{for(let r=0;r<e.length;r+=1){let s=e[r];if(s)switch(s.type){case"PubKey":this.addTxIn(s);break;case"Script":this.addScriptTxIn(s);break;case"SimpleScript":this.addSimpleScriptTxIn(s)}}};addTxIn=e=>{let r=new x(v(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=this.txBody.inputs(),i=[...s.values()];if(i.find(a=>{a.index()==r.index()&&a.transactionId==r.transactionId}))throw new Error("Duplicate input added to tx body");i.push(r),s.setValues(i);let o=new N(V.fromBech32(e.txIn.address),_(e.txIn.amount));this.utxoContext.set(r,o),this.txBody.setInputs(s)};addScriptTxIn=e=>{if(this.addTxIn({type:"PubKey",txIn:e.txIn}),!e.scriptTxIn.scriptSource)throw new Error("A script input had no script source");if(!e.scriptTxIn.datumSource)throw new Error("A script input had no datum source");if(!e.scriptTxIn.redeemer)throw new Error("A script input had no redeemer");if(e.scriptTxIn.scriptSource.type==="Provided")switch(e.scriptTxIn.scriptSource.script.version){case"V1":{this.scriptsProvided.add(S.newPlutusV1Script(A.fromCbor(C(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[g.V1]=!0;break}case"V2":{this.scriptsProvided.add(S.newPlutusV2Script(H.fromCbor(C(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[g.V2]=!0;break}case"V3":{this.scriptsProvided.add(S.newPlutusV3Script(E.fromCbor(C(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[g.V3]=!0;break}}else if(e.scriptTxIn.scriptSource.type==="Inline"){let i=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),o=[...i.values()];switch(o.push(new x(v(e.scriptTxIn.scriptSource.txHash),BigInt(e.scriptTxIn.scriptSource.txIndex))),i.setValues(o),this.txBody.setReferenceInputs(i),e.scriptTxIn.scriptSource.version){case"V1":{this.usedLanguages[g.V1]=!0;break}case"V2":{this.usedLanguages[g.V2]=!0;break}case"V3":{this.usedLanguages[g.V3]=!0;break}}}if(e.scriptTxIn.datumSource.type==="Provided")this.datumsProvided.add(b(e.scriptTxIn.datumSource.data.content));else if(e.scriptTxIn.datumSource.type==="Inline"){let i=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),o=[...i.values()];o.push(new x(v(e.txIn.txHash),BigInt(e.txIn.txIndex))),i.setValues(o),this.txBody.setReferenceInputs(i)}let r=new x(v(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=e.scriptTxIn.redeemer.exUnits;this.redeemerContext.set(r,new me(he.Spend,BigInt(0),b(e.scriptTxIn.redeemer.data.content),new Be(BigInt(s.mem),BigInt(s.steps))))};addSimpleScriptTxIn=e=>{if(this.addTxIn({type:"PubKey",txIn:e.txIn}),!e.simpleScriptTxIn.scriptSource)throw new Error("A native script input had no script source");if(e.simpleScriptTxIn.scriptSource.type==="Provided")this.scriptsProvided.add(S.newNativeScript(h.fromCbor(C(e.simpleScriptTxIn.scriptSource.script))));else if(e.simpleScriptTxIn.scriptSource.type==="Inline"&&e.simpleScriptTxIn.scriptSource.txInInfo.type==="Inline"){let r=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),s=[...r.values()];s.push(new x(v(e.simpleScriptTxIn.scriptSource.txInInfo.txHash),BigInt(e.simpleScriptTxIn.scriptSource.txInInfo.txIndex))),r.setValues(s),this.txBody.setReferenceInputs(r)}};addAllOutputs=e=>{for(let r=0;r<e.length;r++)this.addOutput(e[r])};addOutput=e=>{let r=this.txBody.outputs(),s=new N(V.fromBech32(e.address),_(e.amount));if(e.datum?.type==="Hash"?s.setDatum(W.newDataHash(j.fromHexBlob(C(b(e.datum.data.content).hash())))):e.datum?.type==="Inline"&&s.setDatum(W.newInlineData(b(e.datum.data.content))),e.referenceScript)switch(e.referenceScript.version){case"V1":{s.setScriptRef(S.newPlutusV1Script(A.fromCbor(C(e.referenceScript.code))));break}case"V2":{s.setScriptRef(S.newPlutusV2Script(H.fromCbor(C(e.referenceScript.code))));break}case"V3":{s.setScriptRef(S.newPlutusV3Script(E.fromCbor(C(e.referenceScript.code))));break}}r.push(s),this.txBody.setOutputs(r)};addAllReferenceInputs=e=>{for(let r=0;r<e.length;r++)this.addReferenceIput(e[r])};addReferenceIput=e=>{let r=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),s=[...r.values()];s.push(new x(v.fromHexBlob(C(e.txHash)),BigInt(e.txIndex))),r.setValues(s),this.txBody.setReferenceInputs(r)};addAllMints=e=>{for(let r=0;r<e.length;r++)this.addMint(e[r])};addMint=e=>{let r=this.txBody.mint()??new Map,s=e.policyId+e.assetName;for(let i of r.keys())if(i.toString()==s)throw new Error("The same asset is already in the mint field");if(r.set($.fromParts(ge(e.policyId),Ce(e.assetName)),BigInt(e.amount)),this.txBody.setMint(r),e.type==="Native"){if(!e.scriptSource)throw new Error("Script source not provided for native script mint");let i=e.scriptSource;if(!i)throw new Error("A script source for a native script was not a native script somehow");if(i.type==="Provided")this.scriptsProvided.add(S.newNativeScript(h.fromCbor(C(i.scriptCode))));else if(i.type==="Inline"){let o=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),a=[...o.values()];a.push(new x(v(i.txHash),BigInt(i.txIndex))),o.setValues(a),this.txBody.setReferenceInputs(o)}}else if(e.type==="Plutus"){if(!e.scriptSource)throw new Error("Script source not provided for plutus script mint");let i=e.scriptSource;if(!i)throw new Error("A script source for a plutus mint was not plutus script somehow");if(i.type==="Provided")switch(i.script.version){case"V1":this.scriptsProvided.add(S.newPlutusV1Script(A.fromCbor(C(i.script.code))));break;case"V2":this.scriptsProvided.add(S.newPlutusV2Script(H.fromCbor(C(i.script.code))));break;case"V3":this.scriptsProvided.add(S.newPlutusV3Script(E.fromCbor(C(i.script.code))));break}else if(i.type==="Inline"){let o=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),a=[...o.values()];switch(a.push(new x(v(i.txHash),BigInt(i.txIndex))),o.setValues(a),this.txBody.setReferenceInputs(o),i.version){case"V1":{this.usedLanguages[g.V1]=!0;break}case"V2":{this.usedLanguages[g.V2]=!0;break}case"V3":{this.usedLanguages[g.V3]=!0;break}}}}};addAllCollateralInputs=e=>{for(let r=0;r<e.length;r++)this.addCollateralInput(e[r])};addCollateralInput=e=>{let r=new x(v(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=this.txBody.collateral()??y.CborSet.fromCore([],x.fromCore),i=[...s.values()];if(i.find(a=>{a.index()==r.index()&&a.transactionId==r.transactionId}))throw new Error("Duplicate input added to tx body");i.push(r),s.setValues(i);let o=new N(V.fromBech32(e.txIn.address),_(e.txIn.amount));this.utxoContext.set(r,o),this.txBody.setCollateral(s)};setValidityInterval=e=>{e.invalidBefore&&this.txBody.setValidityStartInterval(L(e.invalidBefore)),e.invalidHereafter&&this.txBody.setTtl(L(e.invalidHereafter))};buildWitnessSet=()=>{let e=this.txBody.inputs();for(let p=0;p<e.size();p+=1){let c=e.values().at(p);if(c){let ue=this.redeemerContext.get(c);ue&&ue.setIndex(BigInt(p))}}let r=this.txWitnessSet.redeemers()??ye.fromCore([]),s=[...r.values()];this.redeemerContext.forEach(p=>{s.push(p)}),r.setValues(s),this.txWitnessSet.setRedeemers(r);let i=this.txWitnessSet.nativeScripts()??y.CborSet.fromCore([],h.fromCore),o=this.txWitnessSet.plutusV1Scripts()??y.CborSet.fromCore([],A.fromCore),a=this.txWitnessSet.plutusV2Scripts()??y.CborSet.fromCore([],H.fromCore),l=this.txWitnessSet.plutusV3Scripts()??y.CborSet.fromCore([],E.fromCore);this.scriptsProvided.forEach(p=>{if(p.asNative()!==void 0){let c=[...i.values()];c.push(p.asNative()),i.setValues(c)}else if(p.asPlutusV1()!==void 0){let c=[...o.values()];c.push(p.asPlutusV1()),o.setValues(c)}else if(p.asPlutusV2()!==void 0){let c=[...a.values()];c.push(p.asPlutusV2()),a.setValues(c)}else if(p.asPlutusV3()!==void 0){let c=[...l.values()];c.push(p.asPlutusV3()),l.setValues(c)}this.txWitnessSet.setNativeScripts(i),this.txWitnessSet.setPlutusV1Scripts(o),this.txWitnessSet.setPlutusV2Scripts(a),this.txWitnessSet.setPlutusV3Scripts(l)});let d=this.txWitnessSet.plutusData()??y.CborSet.fromCore([],P.fromCore);this.datumsProvided.forEach(p=>{let c=[...d.values()];c.push(p),d.setValues(c)}),this.txWitnessSet.setPlutusData(d);let R=y.CostModel.newPlutusV1(ft),w=y.CostModel.newPlutusV2(xt),m=new y.Costmdls;this.usedLanguages[g.V1]&&m.insert(R),this.usedLanguages[g.V2]&&m.insert(w),this.usedLanguages[g.V3];let B=Ge(m,r.size()>0?[...r.values()]:void 0,d.size()>0?[...d.values()]:void 0);B&&this.txBody.setScriptDataHash(B)};balanceTx=(e,r,s)=>{if(e==="")throw new Error("Can't balance tx without a change address");let i=this.txBody.inputs().values(),o=new I(BigInt(0));for(let m=0;m<i.length;m++){let B=i[m];if(!B)throw new Error("Invalid input found");let p=this.utxoContext.get(B);if(!p)throw new Error(`Unable to resolve input: ${B.toCbor()}`);o=U(o,p.amount())}let a=this.txBody.withdrawals();a&&a.forEach(m=>{o=U(o,new I(m))}),o=U(o,new I(BigInt(0),this.txBody.mint()));let l=this.txBody.outputs();for(let m=0;m<l.length;m++){let B=l.at(m);B&&(o=_e(o,B.amount()))}if(o.coin()<0||!Fe(Ue(o)))throw new Error("Not enough funds to satisfy outputs");l.push(new N(V.fromBech32(e),o)),this.txBody.setOutputs(l),this.txBody.setFee(BigInt("10000000"));let d=this.createDummyTx(r),R=s.minFeeB+d.toCbor().length/2*Number(s.coinsPerUtxoSize);this.txBody.setFee(BigInt(R));let w=l.pop();if(!w)throw new Error("Somehow the output length was 0 after attempting to calculate fees");w.amount().setCoin(w.amount().coin()-BigInt(R)),l.push(w),this.txBody.setOutputs(l)};createDummyTx=e=>{let r=new te,s=[];for(let i=0;i<e;i++)s.push([re("0".repeat(64)),se("0".repeat(128))]);return r.setVkeys(y.CborSet.fromCore(s,Z.fromCore)),new k(this.txBody,r)}};import*as mi from"@cardano-sdk/util";import*as hi from"@cardano-sdk/crypto";import*as gi from"@cardano-sdk/core";export{V as Address,vt as AddressType,wt as AssetFingerprint,$ as AssetId,Ce as AssetName,Q as BaseAddress,Pe as Bip32PrivateKey,zt as Bip32PrivateKeyHex,pi as Cardano,gi as CardanoSDK,je as CardanoSDKSerializer,mi as CardanoSDKUtil,Ft as CborSet,Lt as CborWriter,Ht as Certificate,Dt as CertificateType,we as ConstrPlutusData,Mt as CostModel,Ot as Costmdls,Bt as Credential,O as CredentialType,hi as Crypto,W as Datum,j as DatumHash,Ut as DatumKind,ve as Ed25519KeyHash,G as Ed25519KeyHashHex,bt as Ed25519PrivateExtendedKeyHex,Tt as Ed25519PrivateNormalKeyHex,kt as Ed25519PublicKey,re as Ed25519PublicKeyHex,Nt as Ed25519Signature,se as Ed25519SignatureHex,z as EnterpriseAddress,Be as ExUnits,qt as Hash,Vt as Hash28ByteBase16,At as Hash32ByteBase16,h as NativeScript,_t as NetworkId,Pt as PaymentAddress,P as PlutusData,g as PlutusLanguageVersion,xe as PlutusList,Se as PlutusMap,A as PlutusV1Script,H as PlutusV2Script,E as PlutusV3Script,ge as PolicyId,Et as PoolId,K as PrivateKey,ee as PublicKey,me as Redeemer,It as RedeemerPurpose,he as RedeemerTag,ye as Redeemers,Te as RequireAllOf,be as RequireAnyOf,Ve as RequireNOf,Ae as RequireSignature,He as RequireTimeAfter,Ee as RequireTimeBefore,Wt as RewardAccount,Y as RewardAddress,S as Script,Ie as ScriptHash,Re as ScriptPubkey,ui as Serialization,L as Slot,Kt as StakeDelegation,Rt as StakeRegistration,k as Transaction,fe as TransactionBody,v as TransactionId,x as TransactionInput,N as TransactionOutput,F as TransactionUnspentOutput,te as TransactionWitnessSet,I as Value,Z as VkeyWitness,$t as VrfVkBech32,Fr as addressToBech32,at as assetTypes,pr as buildBaseAddress,dr as buildBip32PrivateKey,ur as buildEnterpriseAddress,cr as buildKeys,Ke as buildRewardAddress,lr as buildScriptPubkey,er as checkSignature,Cr as deserializeAddress,De as deserializeDataHash,Ir as deserializeEd25519KeyHash,vr as deserializeNativeScript,ke as deserializePlutusData,J as deserializePlutusScript,Pr as deserializeScriptHash,Ne as deserializeScriptRef,ze as deserializeTx,Oe as deserializeTxHash,wr as deserializeTxUnspentOutput,Br as deserializeValue,Fe as empty,qe as fromNativeScript,$r as fromScriptRef,_r as fromTxUnspentOutput,ot as fromValue,U as mergeValue,nt as negateValue,Ue as negatives,ds as resolveDataHash,cs as resolveNativeScriptAddress,ls as resolveNativeScriptHash,fs as resolvePaymentKeyHash,xs as resolvePlutusScriptAddress,Ss as resolvePlutusScriptHash,ys as resolvePoolId,ms as resolvePrivateKey,gs as resolveRewardAddress,hs as resolveScriptRef,Cs as resolveStakeKeyHash,Is as resolveTxHash,Xt as signData,_e as subValue,D as toAddress,X as toBaseAddress,oe as toEnterpriseAddress,q as toNativeScript,b as toPlutusData,Le as toRewardAddress,We as toScriptRef,Ur as toTxUnspentOutput,_ as toValue};
1
+ import{Cardano as pi,Serialization as ui}from"@cardano-sdk/core";import de from"@stricahq/bip32ed25519";import Je from"hash.js";var K=class extends de.PrivateKey{constructor(e,r=!0){if(!r){let s=Je.sha512().update(e).digest();s[0]&&s[31]&&(s[0]&=248,s[31]&=63,s[31]|=64),e=Buffer.from(s)}super(e)}},{PublicKey:ee,Bip32PrivateKey:ce,Bip32PublicKey:mt}=de;import{Cardano as u,Serialization as n}from"@cardano-sdk/core";import*as f from"@cardano-sdk/crypto";import{typedHex as le}from"@cardano-sdk/util";var L=u.Slot,I=n.Value,k=n.Transaction,v=u.TransactionId,fe=n.TransactionBody,te=n.TransactionWitnessSet,F=n.TransactionUnspentOutput,x=n.TransactionInput,N=n.TransactionOutput,P=n.PlutusData,xe=n.PlutusList,Se=n.PlutusMap,ye=n.Redeemers,me=n.Redeemer,It=u.RedeemerPurpose,he=n.RedeemerTag,S=n.Script,ge=u.PolicyId,Ce=u.AssetName,$=u.AssetId,Ie=f.Hash28ByteBase16,V=u.Address,Y=u.RewardAddress,vt=u.AddressType,Q=u.BaseAddress,z=u.EnterpriseAddress,Pt=u.PaymentAddress,wt=u.AssetFingerprint,Bt=n.Credential,re=f.Ed25519PublicKeyHex,Tt=t=>le(t,64),bt=t=>le(t,128),ve=f.Ed25519KeyHash,G=f.Ed25519KeyHashHex,Vt=f.Hash28ByteBase16,At=f.Hash32ByteBase16,O=u.CredentialType,Ht=n.Certificate,Et=u.PoolId,Rt=n.StakeRegistration,Kt=n.StakeDelegation,Dt=u.CertificateType,Z=n.VkeyWitness,se=f.Ed25519SignatureHex,kt=f.Ed25519PublicKey,Nt=f.Ed25519Signature,Pe=f.Bip32PrivateKey,zt=f.Bip32PrivateKeyHex,g=u.PlutusLanguageVersion,h=n.NativeScript,A=n.PlutusV1Script,H=n.PlutusV2Script,E=n.PlutusV3Script,Ot=n.Costmdls,Mt=n.CostModel,Lt=n.CborWriter,we=n.ConstrPlutusData,Wt=u.RewardAccount,qt=n.Hash,j=f.Hash32ByteBase16,W=n.Datum,Be=n.ExUnits,_t=u.NetworkId,Ut=n.DatumKind,Ft=n.CborSet,Te=u.NativeScriptKind.RequireAllOf,be=u.NativeScriptKind.RequireAnyOf,Ve=u.NativeScriptKind.RequireNOf,Ae=u.NativeScriptKind.RequireSignature,He=u.NativeScriptKind.RequireTimeAfter,Ee=u.NativeScriptKind.RequireTimeBefore,$t=u.VrfVkBech32,Re=n.ScriptPubkey;var Xt=(t,e)=>{let r=Buffer.from(t),s=e.sign(r);return{key:e.toPublicKey().toBytes().toString("hex"),signature:s.toString("hex")}},er=(t,{key:e,signature:r})=>new ee(Buffer.from(e,"hex")).verify(Buffer.from(r,"hex"),Buffer.from(t));import{Cardano as ne}from"@cardano-sdk/core";import{blake2b as Ye}from"@cardano-sdk/crypto";import{HexBlob as pt}from"@cardano-sdk/util";import{pbkdf2Sync as Xe}from"pbkdf2";import{HARDENED_KEY_START as ie}from"@meshsdk/common";var pr=(t,e,r)=>Q.fromCredentials(t,{hash:e,type:O.KeyHash},{hash:r,type:O.KeyHash}),ur=(t,e)=>z.fromCredentials(t,{hash:e,type:O.KeyHash}),dr=(t,e="")=>{let i="sha512",o=d=>(d[0]!==void 0&&(d[0]&=248),d[31]!==void 0&&(d[31]&=31,d[31]|=64),d),a=Buffer.from(t,"hex"),l=Xe(e,a,4096,96,i);return Pe.fromBytes(o(l))},Ke=(t,e)=>{let r={type:O.KeyHash,hash:e};return Y.fromCredentials(t,r)},cr=(t,e,r=0)=>{if(typeof t=="string"){let i=new ce(Buffer.from(t,"hex")).derive(ie+1852).derive(ie+1815).derive(ie+e),o=i.derive(0).derive(r).toPrivateKey(),a=i.derive(2).derive(0).toPrivateKey();return{paymentKey:o,stakeKey:a}}else{let s=new K(Buffer.from(t[0],"hex"),!1),i=new K(Buffer.from(t[1],"hex"),!1);return{paymentKey:s,stakeKey:i}}},lr=t=>{let e=new Re(G(t.hex()));return h.newScriptPubkey(e)};import{Serialization as M}from"@cardano-sdk/core";import{Ed25519KeyHash as st}from"@cardano-sdk/crypto";import{HexBlob as it}from"@cardano-sdk/util";import{toBytes as Me}from"@meshsdk/common";import{TxCBOR as et}from"@cardano-sdk/core";import{Ed25519KeyHashHex as tt}from"@cardano-sdk/crypto";import{HexBlob as T}from"@cardano-sdk/util";import{toBytes as rt}from"@meshsdk/common";var Cr=t=>{let e=V.fromString(t);if(e===null)throw new Error("Invalid address");return e},Ir=t=>ve.fromBytes(rt(t)),De=t=>j.fromHexBlob(T(t)),ke=t=>P.fromCbor(T(t)),J=(t,e)=>{switch(e){case"V1":return A.fromCbor(T(t));case"V2":return H.fromCbor(T(t));case"V3":return E.fromCbor(T(t));default:throw new Error("Invalid Plutus script version")}},vr=t=>h.fromCbor(T(t)),Pr=t=>Ie.fromEd25519KeyHashHex(tt(t)),Ne=t=>S.fromCbor(T(t)),wr=t=>F.fromCbor(T(t)),Br=t=>I.fromCbor(T(t)),ze=t=>k.fromCbor(et(t)),Oe=t=>v.fromHexBlob(T(t));var D=t=>V.fromBech32(t),X=t=>Q.fromAddress(D(t)),oe=t=>z.fromAddress(D(t)),Le=t=>Y.fromAddress(D(t)),_r=t=>{let e=t.output().datum()?t.output().datum()?.toCbor().toString():void 0,r=t.output().scriptRef()?t.output().scriptRef()?.toCbor().toString():void 0,s=t.output().datum()?.asInlineData()?t.output().datum()?.asInlineData()?.toCbor().toString():void 0;return{input:{outputIndex:Number(t.input().index()),txHash:t.input().transactionId()},output:{address:t.output().address().toBech32(),amount:ot(t.output().amount()),dataHash:e,plutusData:s,scriptRef:r}}},Ur=t=>{let e=new x(Oe(t.input.txHash),BigInt(t.input.outputIndex)),r=new N(D(t.output.address),_(t.output.amount));if(t.output.dataHash!==void 0&&r.setDatum(W.fromCore(De(t.output.dataHash))),t.output.plutusData!==void 0){let s=ke(t.output.plutusData),i=new M.Datum(void 0,s);r.setDatum(i)}return t.output.scriptRef!==void 0&&r.setScriptRef(Ne(t.output.scriptRef)),new F(e,r)},Fr=t=>t.toBech32(),ot=t=>{let e=[{unit:"lovelace",quantity:t.coin().toString()}],r=t.multiasset();if(r!==void 0){let s=Array.from(r.keys());for(let i=0;i<s.length;i+=1){let o=s[i];if(o!==void 0){let a=r.get(o);a!==void 0&&e.push({unit:o,quantity:a.toString()})}}}return e},We=t=>{if("code"in t){let e=J(t.code,t.version);if(e instanceof A)return S.newPlutusV1Script(e);if(e instanceof H)return S.newPlutusV2Script(e);if(e instanceof E)return S.newPlutusV3Script(e)}return S.newNativeScript(q(t))},$r=t=>{let e=S.fromCbor(it(t)),r=e.asPlutusV3()?.toCbor().toString();if(r)return{code:r,version:"V3"};let s=e.asPlutusV2()?.toCbor().toString();if(s)return{code:s,version:"V2"};let i=e.asPlutusV1()?.toCbor().toString();if(i)return{code:i,version:"V1"};let o=e.asNative();if(!o)throw new Error("Invalid script");return qe(o)},qe=t=>{let e=r=>{let s=new Array;for(let i=0;i<r.length;i+=1){let o=r[i];o&&s.push(qe(o))}return s};switch(t.kind()){case Te:{let r=t.asScriptAll();return{type:"all",scripts:e(r.nativeScripts())}}case be:{let r=t.asScriptAny();return{type:"any",scripts:e(r.nativeScripts())}}case Ve:{let r=t.asScriptNOfK();return{type:"atLeast",required:r.required(),scripts:e(r.nativeScripts())}}case He:return{type:"after",slot:t.asTimelockStart().slot().toString()};case Ee:return{type:"before",slot:t.asTimelockExpiry().slot().toString()};case Ae:return{type:"sig",keyHash:t.asScriptPubkey().keyHash().toString()};default:throw new Error(`Script Kind: ${t.kind()}, is not supported`)}},q=t=>{let e=r=>{let s=[];return r.forEach(i=>{s.push(q(i))}),s};switch(t.type){case"all":return h.newScriptAll(new M.ScriptAll(e(t.scripts)));case"any":return h.newScriptAny(new M.ScriptAny(e(t.scripts)));case"atLeast":return h.newScriptNOfK(new M.ScriptNOfK(e(t.scripts),t.required));case"after":return h.newTimelockStart(new M.TimelockStart(L(parseInt(t.slot))));case"before":return h.newTimelockExpiry(new M.TimelockExpiry(L(parseInt(t.slot))));case"sig":return h.newScriptPubkey(new M.ScriptPubkey(st.fromBytes(Me(t.keyHash)).hex()))}},b=t=>{let e=r=>{let s=new xe;return r.forEach(i=>{s.add(b(i))}),s};switch(typeof t){case"string":return P.newBytes(Me(t));case"number":return P.newInteger(BigInt(t));case"bigint":return P.newInteger(BigInt(t));case"object":if(t instanceof Array){let r=e(t);return P.newList(r)}else if(t instanceof Map){let r=new Se;return t.forEach((s,i)=>{r.insert(b(i),b(s))}),P.newMap(r)}else return P.newConstrPlutusData(new we(BigInt(t.alternative),e(t.fields)))}},_=t=>{let e=new Map;t.filter(i=>i.unit!=="lovelace").forEach(i=>{e.set($(i.unit),BigInt(i.quantity))});let r=t.find(i=>i.unit==="lovelace"),s=new I(BigInt(r?r.quantity:0));return(t.length>1||!r)&&s.setMultiasset(e),s};function U(t,e){let r=t.multiasset()??new Map;return e.multiasset()?.forEach((s,i)=>{let o=(r.get(i)??0n)+s;o==0n?r.delete(i):r.set(i,o)}),new I(BigInt(t.coin())+BigInt(e.coin()),r.size>0?r:void 0)}function nt(t){let e=t.multiasset()?.entries(),r=new Map;if(e)for(let s of e)r.set(s[0],-s[1]);return new I(-t.coin(),r)}function _e(t,e){return U(t,nt(e))}function Ue(t){let e=t.multiasset()?.entries(),r=t.coin()<0n?t.coin():0n,s=new Map;if(e)for(let i of e)i[1]<0n&&s.set(i[0],i[1]);return new I(r,s)}function at(t){let e=t.coin()==0n?0:1,r=t.multiasset();return r&&r.forEach(()=>{e+=1}),e}function Fe(t){return at(t)==0}var $e=t=>Buffer.from(t,"hex");var ds=t=>b(t).hash().toString(),cs=(t,e=0)=>{let r=q(t);return z.fromCredentials(e,{hash:r.hash(),type:ne.CredentialType.ScriptHash}).toAddress().toBech32()},ls=t=>q(t).hash().toString(),fs=t=>{try{let e=[X(t)?.getPaymentCredential().hash,oe(t)?.getPaymentCredential().hash].find(r=>r!==void 0);if(e!==void 0)return e.toString();throw new Error(`Couldn't resolve payment key hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolvePaymentKeyHash: ${e}.`)}},xs=(t,e=0)=>{let r=J(t.code,t.version);return z.fromCredentials(e,{hash:r.hash(),type:ne.CredentialType.ScriptHash}).toAddress().toBech32()},Ss=t=>{try{let r=oe(t)?.getPaymentCredential().hash;if(r!==void 0)return r.toString();throw new Error(`Couldn't resolve script hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveScriptHash: ${e}.`)}},ys=t=>G(t).toString(),ms=t=>"not implemented",hs=t=>We(t).toCbor().toString(),gs=t=>{try{let e=D(t),s=X(t)?.getStakeCredential().hash;if(s!==void 0)return Ke(e.getNetworkId(),s).toAddress().toBech32();throw new Error(`Couldn't resolve reward address from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveRewardAddress: ${e}.`)}},Cs=t=>{try{let e=[X(t)?.getStakeCredential().hash,Le(t)?.getPaymentCredential().hash].find(r=>r!==void 0);if(e!==void 0)return e.toString();throw new Error(`Couldn't resolve stake key hash from address: ${t}`)}catch(e){throw new Error(`An error occurred during resolveStakeKeyHash: ${e}.`)}},Is=t=>{let e=ze(t).body(),r=Ye(Ye.BYTES).update($e(e.toCbor())).digest();return ne.TransactionId.fromHexBlob(pt.fromBytes(r))};import{Serialization as y,TxCBOR as Ze}from"@cardano-sdk/core";import{HexBlob as C}from"@cardano-sdk/util";import{DEFAULT_V1_COST_MODEL_LIST as ft,DEFAULT_V2_COST_MODEL_LIST as xt}from"@meshsdk/common";import{Serialization as Qe}from"@cardano-sdk/core";import*as pe from"@cardano-sdk/crypto";import{Hash32ByteBase16 as ut}from"@cardano-sdk/crypto";import{HexBlob as dt}from"@cardano-sdk/util";var ct=new Uint8Array([128]),lt=new Uint8Array([160]),ae=t=>{let e=new Qe.CborWriter;e.writeStartArray(t.length);for(let r of t)e.writeEncodedValue(Buffer.from(r.toCbor(),"hex"));return e.encode()},Ge=(t,e,r)=>{let s=new Qe.CborWriter;if(r&&r.length>0&&(!e||e.length===0))s.writeEncodedValue(ct),s.writeEncodedValue(ae(r)),s.writeEncodedValue(lt);else{if(!e||e.length===0)return;s.writeEncodedValue(ae(e)),r&&r.length>0&&s.writeEncodedValue(ae(r)),s.writeEncodedValue(Buffer.from(t.languageViewsEncoding(),"hex"))}return ut.fromHexBlob(dt.fromBytes(pe.blake2b(pe.blake2b.BYTES).update(s.encode()).digest()))};var je=class{txBody;txWitnessSet;utxoContext=new Map;redeemerContext=new Map;scriptsProvided=new Set;datumsProvided=new Set;usedLanguages={0:!1,1:!1,2:!1};constructor(){this.txBody=new fe(y.CborSet.fromCore([],x.fromCore),[],BigInt(0),void 0),this.txWitnessSet=new te}serializePoolId(e){throw new Error("Method not implemented.")}serializeAddress(e,r){throw new Error("Method not implemented.")}serializeData(e){throw new Error("Method not implemented.")}deserializer={key:{deserializeAddress:function(e){throw new Error("Function not implemented.")}},script:{deserializeNativeScript:function(e){throw new Error("Function not implemented.")},deserializePlutusScript:function(e){throw new Error("Function not implemented.")}},cert:{deserializePoolId:function(e){throw new Error("Function not implemented.")}}};resolver={keys:{resolveStakeKeyHash:function(e){let r=D(e);return r.asReward()?.getPaymentCredential().type===O.KeyHash?r.asReward().getPaymentCredential().hash:""},resolvePrivateKey:function(e){throw new Error("Function not implemented.")},resolveRewardAddress:function(e){throw new Error("Function not implemented.")},resolveEd25519KeyHash:function(e){throw new Error("Function not implemented.")}},tx:{resolveTxHash:function(e){return k.fromCbor(Ze(e)).getId()}},data:{resolveDataHash:function(e){throw new Error("Function not implemented.")}},script:{resolveScriptRef:function(e){throw new Error("Function not implemented.")}}};serializeTxBody=(e,r)=>{let{inputs:s,outputs:i,collaterals:o,referenceInputs:a,mints:l,changeAddress:d,certificates:R,validityRange:w,requiredSignatures:m,metadata:B}=e;return l.sort((p,c)=>p.policyId.localeCompare(c.policyId)),s.sort((p,c)=>p.txIn.txHash===c.txIn.txHash?p.txIn.txIndex-c.txIn.txIndex:p.txIn.txHash.localeCompare(c.txIn.txHash)),this.addAllInputs(s),this.addAllOutputs(i),this.addAllMints(l),this.addAllCollateralInputs(o),this.addAllReferenceInputs(a),this.setValidityInterval(w),this.buildWitnessSet(),this.balanceTx(d,m.length,r),new k(this.txBody,this.txWitnessSet).toCbor()};addSigningKeys=(e,r)=>{let s=k.fromCbor(Ze(e)),i=s.witnessSet(),o=i.vkeys(),a=o?[...o.values()]:[];for(let l=0;l<r.length;l++){let d=r[l];if(d){d.length===68&&d.substring(0,4)==="5820"&&(d=d.substring(4));let R=new K(Buffer.from(d,"hex"),!1),w=R.sign(Buffer.from(s.getId(),"hex"));a.push(new Z(re(R.toPublicKey().toBytes().toString("hex")),se(w.toString("hex"))))}}return i.setVkeys(y.CborSet.fromCore(a.map(l=>l.toCore()),Z.fromCore)),s.setWitnessSet(i),s.toCbor()};addAllInputs=e=>{for(let r=0;r<e.length;r+=1){let s=e[r];if(s)switch(s.type){case"PubKey":this.addTxIn(s);break;case"Script":this.addScriptTxIn(s);break;case"SimpleScript":this.addSimpleScriptTxIn(s)}}};addTxIn=e=>{let r=new x(v(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=this.txBody.inputs(),i=[...s.values()];if(i.find(a=>{a.index()==r.index()&&a.transactionId==r.transactionId}))throw new Error("Duplicate input added to tx body");i.push(r),s.setValues(i);let o=new N(V.fromBech32(e.txIn.address),_(e.txIn.amount));this.utxoContext.set(r,o),this.txBody.setInputs(s)};addScriptTxIn=e=>{if(this.addTxIn({type:"PubKey",txIn:e.txIn}),!e.scriptTxIn.scriptSource)throw new Error("A script input had no script source");if(!e.scriptTxIn.datumSource)throw new Error("A script input had no datum source");if(!e.scriptTxIn.redeemer)throw new Error("A script input had no redeemer");if(e.scriptTxIn.scriptSource.type==="Provided")switch(e.scriptTxIn.scriptSource.script.version){case"V1":{this.scriptsProvided.add(S.newPlutusV1Script(A.fromCbor(C(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[g.V1]=!0;break}case"V2":{this.scriptsProvided.add(S.newPlutusV2Script(H.fromCbor(C(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[g.V2]=!0;break}case"V3":{this.scriptsProvided.add(S.newPlutusV3Script(E.fromCbor(C(e.scriptTxIn.scriptSource.script.code)))),this.usedLanguages[g.V3]=!0;break}}else if(e.scriptTxIn.scriptSource.type==="Inline"){let i=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),o=[...i.values()];switch(o.push(new x(v(e.scriptTxIn.scriptSource.txHash),BigInt(e.scriptTxIn.scriptSource.txIndex))),i.setValues(o),this.txBody.setReferenceInputs(i),e.scriptTxIn.scriptSource.version){case"V1":{this.usedLanguages[g.V1]=!0;break}case"V2":{this.usedLanguages[g.V2]=!0;break}case"V3":{this.usedLanguages[g.V3]=!0;break}}}if(e.scriptTxIn.datumSource.type==="Provided")this.datumsProvided.add(b(e.scriptTxIn.datumSource.data.content));else if(e.scriptTxIn.datumSource.type==="Inline"){let i=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),o=[...i.values()];o.push(new x(v(e.txIn.txHash),BigInt(e.txIn.txIndex))),i.setValues(o),this.txBody.setReferenceInputs(i)}let r=new x(v(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=e.scriptTxIn.redeemer.exUnits;this.redeemerContext.set(r,new me(he.Spend,BigInt(0),b(e.scriptTxIn.redeemer.data.content),new Be(BigInt(s.mem),BigInt(s.steps))))};addSimpleScriptTxIn=e=>{if(this.addTxIn({type:"PubKey",txIn:e.txIn}),!e.simpleScriptTxIn.scriptSource)throw new Error("A native script input had no script source");if(e.simpleScriptTxIn.scriptSource.type==="Provided")this.scriptsProvided.add(S.newNativeScript(h.fromCbor(C(e.simpleScriptTxIn.scriptSource.script))));else if(e.simpleScriptTxIn.scriptSource.type==="Inline"&&e.simpleScriptTxIn.scriptSource.txInInfo.type==="Inline"){let r=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),s=[...r.values()];s.push(new x(v(e.simpleScriptTxIn.scriptSource.txInInfo.txHash),BigInt(e.simpleScriptTxIn.scriptSource.txInInfo.txIndex))),r.setValues(s),this.txBody.setReferenceInputs(r)}};addAllOutputs=e=>{for(let r=0;r<e.length;r++)this.addOutput(e[r])};addOutput=e=>{let r=this.txBody.outputs(),s=new N(V.fromBech32(e.address),_(e.amount));if(e.datum?.type==="Hash"?s.setDatum(W.newDataHash(j.fromHexBlob(C(b(e.datum.data.content).hash())))):e.datum?.type==="Inline"&&s.setDatum(W.newInlineData(b(e.datum.data.content))),e.referenceScript)switch(e.referenceScript.version){case"V1":{s.setScriptRef(S.newPlutusV1Script(A.fromCbor(C(e.referenceScript.code))));break}case"V2":{s.setScriptRef(S.newPlutusV2Script(H.fromCbor(C(e.referenceScript.code))));break}case"V3":{s.setScriptRef(S.newPlutusV3Script(E.fromCbor(C(e.referenceScript.code))));break}}r.push(s),this.txBody.setOutputs(r)};addAllReferenceInputs=e=>{for(let r=0;r<e.length;r++)this.addReferenceIput(e[r])};addReferenceIput=e=>{let r=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),s=[...r.values()];s.push(new x(v.fromHexBlob(C(e.txHash)),BigInt(e.txIndex))),r.setValues(s),this.txBody.setReferenceInputs(r)};addAllMints=e=>{for(let r=0;r<e.length;r++)this.addMint(e[r])};addMint=e=>{let r=this.txBody.mint()??new Map,s=e.policyId+e.assetName;for(let i of r.keys())if(i.toString()==s)throw new Error("The same asset is already in the mint field");if(r.set($.fromParts(ge(e.policyId),Ce(e.assetName)),BigInt(e.amount)),this.txBody.setMint(r),e.type==="Native"){if(!e.scriptSource)throw new Error("Script source not provided for native script mint");let i=e.scriptSource;if(!i)throw new Error("A script source for a native script was not a native script somehow");if(i.type==="Provided")this.scriptsProvided.add(S.newNativeScript(h.fromCbor(C(i.scriptCode))));else if(i.type==="Inline"){let o=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),a=[...o.values()];a.push(new x(v(i.txHash),BigInt(i.txIndex))),o.setValues(a),this.txBody.setReferenceInputs(o)}}else if(e.type==="Plutus"){if(!e.scriptSource)throw new Error("Script source not provided for plutus script mint");let i=e.scriptSource;if(!i)throw new Error("A script source for a plutus mint was not plutus script somehow");if(i.type==="Provided")switch(i.script.version){case"V1":this.scriptsProvided.add(S.newPlutusV1Script(A.fromCbor(C(i.script.code))));break;case"V2":this.scriptsProvided.add(S.newPlutusV2Script(H.fromCbor(C(i.script.code))));break;case"V3":this.scriptsProvided.add(S.newPlutusV3Script(E.fromCbor(C(i.script.code))));break}else if(i.type==="Inline"){let o=this.txBody.referenceInputs()??y.CborSet.fromCore([],x.fromCore),a=[...o.values()];switch(a.push(new x(v(i.txHash),BigInt(i.txIndex))),o.setValues(a),this.txBody.setReferenceInputs(o),i.version){case"V1":{this.usedLanguages[g.V1]=!0;break}case"V2":{this.usedLanguages[g.V2]=!0;break}case"V3":{this.usedLanguages[g.V3]=!0;break}}}}};addAllCollateralInputs=e=>{for(let r=0;r<e.length;r++)this.addCollateralInput(e[r])};addCollateralInput=e=>{let r=new x(v(e.txIn.txHash),BigInt(e.txIn.txIndex)),s=this.txBody.collateral()??y.CborSet.fromCore([],x.fromCore),i=[...s.values()];if(i.find(a=>{a.index()==r.index()&&a.transactionId==r.transactionId}))throw new Error("Duplicate input added to tx body");i.push(r),s.setValues(i);let o=new N(V.fromBech32(e.txIn.address),_(e.txIn.amount));this.utxoContext.set(r,o),this.txBody.setCollateral(s)};setValidityInterval=e=>{e.invalidBefore&&this.txBody.setValidityStartInterval(L(e.invalidBefore)),e.invalidHereafter&&this.txBody.setTtl(L(e.invalidHereafter))};buildWitnessSet=()=>{let e=this.txBody.inputs();for(let p=0;p<e.size();p+=1){let c=e.values().at(p);if(c){let ue=this.redeemerContext.get(c);ue&&ue.setIndex(BigInt(p))}}let r=this.txWitnessSet.redeemers()??ye.fromCore([]),s=[...r.values()];this.redeemerContext.forEach(p=>{s.push(p)}),r.setValues(s),this.txWitnessSet.setRedeemers(r);let i=this.txWitnessSet.nativeScripts()??y.CborSet.fromCore([],h.fromCore),o=this.txWitnessSet.plutusV1Scripts()??y.CborSet.fromCore([],A.fromCore),a=this.txWitnessSet.plutusV2Scripts()??y.CborSet.fromCore([],H.fromCore),l=this.txWitnessSet.plutusV3Scripts()??y.CborSet.fromCore([],E.fromCore);this.scriptsProvided.forEach(p=>{if(p.asNative()!==void 0){let c=[...i.values()];c.push(p.asNative()),i.setValues(c)}else if(p.asPlutusV1()!==void 0){let c=[...o.values()];c.push(p.asPlutusV1()),o.setValues(c)}else if(p.asPlutusV2()!==void 0){let c=[...a.values()];c.push(p.asPlutusV2()),a.setValues(c)}else if(p.asPlutusV3()!==void 0){let c=[...l.values()];c.push(p.asPlutusV3()),l.setValues(c)}this.txWitnessSet.setNativeScripts(i),this.txWitnessSet.setPlutusV1Scripts(o),this.txWitnessSet.setPlutusV2Scripts(a),this.txWitnessSet.setPlutusV3Scripts(l)});let d=this.txWitnessSet.plutusData()??y.CborSet.fromCore([],P.fromCore);this.datumsProvided.forEach(p=>{let c=[...d.values()];c.push(p),d.setValues(c)}),this.txWitnessSet.setPlutusData(d);let R=y.CostModel.newPlutusV1(ft),w=y.CostModel.newPlutusV2(xt),m=new y.Costmdls;this.usedLanguages[g.V1]&&m.insert(R),this.usedLanguages[g.V2]&&m.insert(w),this.usedLanguages[g.V3];let B=Ge(m,r.size()>0?[...r.values()]:void 0,d.size()>0?[...d.values()]:void 0);B&&this.txBody.setScriptDataHash(B)};balanceTx=(e,r,s)=>{if(e==="")throw new Error("Can't balance tx without a change address");let i=this.txBody.inputs().values(),o=new I(BigInt(0));for(let m=0;m<i.length;m++){let B=i[m];if(!B)throw new Error("Invalid input found");let p=this.utxoContext.get(B);if(!p)throw new Error(`Unable to resolve input: ${B.toCbor()}`);o=U(o,p.amount())}let a=this.txBody.withdrawals();a&&a.forEach(m=>{o=U(o,new I(m))}),o=U(o,new I(BigInt(0),this.txBody.mint()));let l=this.txBody.outputs();for(let m=0;m<l.length;m++){let B=l.at(m);B&&(o=_e(o,B.amount()))}if(o.coin()<0||!Fe(Ue(o)))throw new Error("Not enough funds to satisfy outputs");l.push(new N(V.fromBech32(e),o)),this.txBody.setOutputs(l),this.txBody.setFee(BigInt("10000000"));let d=this.createDummyTx(r),R=s.minFeeB+d.toCbor().length/2*Number(s.coinsPerUtxoSize);this.txBody.setFee(BigInt(R));let w=l.pop();if(!w)throw new Error("Somehow the output length was 0 after attempting to calculate fees");w.amount().setCoin(w.amount().coin()-BigInt(R)),l.push(w),this.txBody.setOutputs(l)};createDummyTx=e=>{let r=new te,s=[];for(let i=0;i<e;i++)s.push([re("0".repeat(64)),se("0".repeat(128))]);return r.setVkeys(y.CborSet.fromCore(s,Z.fromCore)),new k(this.txBody,r)}};import*as mi from"@cardano-sdk/util";import*as hi from"@cardano-sdk/crypto";import*as gi from"@cardano-sdk/core";export{V as Address,vt as AddressType,wt as AssetFingerprint,$ as AssetId,Ce as AssetName,Q as BaseAddress,Pe as Bip32PrivateKey,zt as Bip32PrivateKeyHex,pi as Cardano,gi as CardanoSDK,je as CardanoSDKSerializer,mi as CardanoSDKUtil,Ft as CborSet,Lt as CborWriter,Ht as Certificate,Dt as CertificateType,we as ConstrPlutusData,Mt as CostModel,Ot as Costmdls,Bt as Credential,O as CredentialType,hi as Crypto,W as Datum,j as DatumHash,Ut as DatumKind,ve as Ed25519KeyHash,G as Ed25519KeyHashHex,bt as Ed25519PrivateExtendedKeyHex,Tt as Ed25519PrivateNormalKeyHex,kt as Ed25519PublicKey,re as Ed25519PublicKeyHex,Nt as Ed25519Signature,se as Ed25519SignatureHex,z as EnterpriseAddress,Be as ExUnits,qt as Hash,Vt as Hash28ByteBase16,At as Hash32ByteBase16,h as NativeScript,_t as NetworkId,Pt as PaymentAddress,P as PlutusData,g as PlutusLanguageVersion,xe as PlutusList,Se as PlutusMap,A as PlutusV1Script,H as PlutusV2Script,E as PlutusV3Script,ge as PolicyId,Et as PoolId,K as PrivateKey,ee as PublicKey,me as Redeemer,It as RedeemerPurpose,he as RedeemerTag,ye as Redeemers,Te as RequireAllOf,be as RequireAnyOf,Ve as RequireNOf,Ae as RequireSignature,He as RequireTimeAfter,Ee as RequireTimeBefore,Wt as RewardAccount,Y as RewardAddress,S as Script,Ie as ScriptHash,Re as ScriptPubkey,ui as Serialization,L as Slot,Kt as StakeDelegation,Rt as StakeRegistration,k as Transaction,fe as TransactionBody,v as TransactionId,x as TransactionInput,N as TransactionOutput,F as TransactionUnspentOutput,te as TransactionWitnessSet,I as Value,Z as VkeyWitness,$t as VrfVkBech32,Fr as addressToBech32,at as assetTypes,pr as buildBaseAddress,dr as buildBip32PrivateKey,ur as buildEnterpriseAddress,cr as buildKeys,Ke as buildRewardAddress,lr as buildScriptPubkey,er as checkSignature,Cr as deserializeAddress,De as deserializeDataHash,Ir as deserializeEd25519KeyHash,vr as deserializeNativeScript,ke as deserializePlutusData,J as deserializePlutusScript,Pr as deserializeScriptHash,Ne as deserializeScriptRef,ze as deserializeTx,Oe as deserializeTxHash,wr as deserializeTxUnspentOutput,Br as deserializeValue,Fe as empty,qe as fromNativeScript,$r as fromScriptRef,_r as fromTxUnspentOutput,ot as fromValue,U as mergeValue,nt as negateValue,Ue as negatives,ds as resolveDataHash,cs as resolveNativeScriptAddress,ls as resolveNativeScriptHash,fs as resolvePaymentKeyHash,xs as resolvePlutusScriptAddress,Ss as resolvePlutusScriptHash,ys as resolvePoolId,ms as resolvePrivateKey,gs as resolveRewardAddress,hs as resolveScriptRef,Cs as resolveStakeKeyHash,Is as resolveTxHash,Xt as signData,_e as subValue,D as toAddress,X as toBaseAddress,oe as toEnterpriseAddress,q as toNativeScript,b as toPlutusData,Le as toRewardAddress,We as toScriptRef,Ur as toTxUnspentOutput,_ as toValue};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/core-cst",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "build:mesh": "tsup src/index.ts --format esm,cjs --dts --minify",
21
21
  "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
22
22
  "lint": "eslint",
23
- "test": "jest --verbose",
23
+ "test": "jest",
24
24
  "clean": "rm -rf .turbo && rm -rf dist && rm -rf node_modules",
25
25
  "format": "prettier --check . --ignore-path ../../.gitignore"
26
26
  },