@meshsdk/core-cst 1.6.0-alpha.20 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +310 -0
- package/dist/index.d.ts +310 -0
- package/dist/index.js +1 -0
- package/package.json +25 -9
- package/jest.config.js +0 -5
- package/src/cip8/index.ts +0 -24
- package/src/index.ts +0 -16
- package/src/resolvers/index.ts +0 -141
- package/src/serializer/index.ts +0 -678
- package/src/stricahq/index.ts +0 -24
- package/src/types/cardano-sdk.ts +0 -243
- package/src/types/index.ts +0 -2
- package/src/types/signer.ts +0 -7
- package/src/utils/builder.ts +0 -130
- package/src/utils/converter.ts +0 -371
- package/src/utils/deserializer.ts +0 -76
- package/src/utils/encoding.ts +0 -12
- package/src/utils/index.ts +0 -4
- package/src/utils/script-data-hash.ts +0 -87
- package/src/utils/value.ts +0 -61
- package/test/resolvers.test.ts +0 -140
- package/test/utils/converter.test.ts +0 -18
- package/tsconfig.json +0 -5
package/dist/index.cjs
ADDED
|
@@ -0,0 +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});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import * as _cardano_sdk_core from '@cardano-sdk/core';
|
|
2
|
+
import { Cardano, Serialization } from '@cardano-sdk/core';
|
|
3
|
+
export { _cardano_sdk_core as CardanoSDK };
|
|
4
|
+
export { Cardano, Serialization } from '@cardano-sdk/core';
|
|
5
|
+
import strica from '@stricahq/bip32ed25519';
|
|
6
|
+
import * as _cardano_sdk_util from '@cardano-sdk/util';
|
|
7
|
+
import { OpaqueString } from '@cardano-sdk/util';
|
|
8
|
+
export { _cardano_sdk_util as CardanoSDKUtil };
|
|
9
|
+
import * as Crypto from '@cardano-sdk/crypto';
|
|
10
|
+
export { Crypto };
|
|
11
|
+
import { DataSignature, Data, NativeScript as NativeScript$1, PlutusScript, IMeshTxSerializer, DeserializedAddress, BuilderData, IDeserializer, IResolver, MeshTxBuilderBody, Protocol, UTxO, Asset, LanguageVersion } from '@meshsdk/common';
|
|
12
|
+
|
|
13
|
+
declare class PrivateKey extends strica.PrivateKey {
|
|
14
|
+
constructor(privKey: Buffer, extended?: Boolean);
|
|
15
|
+
}
|
|
16
|
+
declare const PublicKey: typeof strica.PublicKey;
|
|
17
|
+
|
|
18
|
+
declare const Slot: (value: number) => Cardano.Slot;
|
|
19
|
+
type Slot = Cardano.Slot;
|
|
20
|
+
declare const Value: typeof Serialization.Value;
|
|
21
|
+
type Value = Serialization.Value;
|
|
22
|
+
type TokenMap = Cardano.TokenMap;
|
|
23
|
+
declare const Transaction: typeof Serialization.Transaction;
|
|
24
|
+
type Transaction = Serialization.Transaction;
|
|
25
|
+
declare const TransactionId: {
|
|
26
|
+
(value: string): Cardano.TransactionId;
|
|
27
|
+
fromHexBlob(value: _cardano_sdk_util.HexBlob): Cardano.TransactionId;
|
|
28
|
+
fromTxBodyCbor(bodyCbor: _cardano_sdk_core.TxBodyCBOR): Cardano.TransactionId;
|
|
29
|
+
};
|
|
30
|
+
type TransactionId = Cardano.TransactionId;
|
|
31
|
+
declare const TransactionBody: typeof Serialization.TransactionBody;
|
|
32
|
+
type TransactionBody = Serialization.TransactionBody;
|
|
33
|
+
declare const TransactionWitnessSet: typeof Serialization.TransactionWitnessSet;
|
|
34
|
+
type TransactionWitnessSet = Serialization.TransactionWitnessSet;
|
|
35
|
+
declare const TransactionUnspentOutput: typeof Serialization.TransactionUnspentOutput;
|
|
36
|
+
type TransactionUnspentOutput = Serialization.TransactionUnspentOutput;
|
|
37
|
+
declare const TransactionInput: typeof Serialization.TransactionInput;
|
|
38
|
+
type TransactionInput = Serialization.TransactionInput;
|
|
39
|
+
declare const TransactionOutput: typeof Serialization.TransactionOutput;
|
|
40
|
+
type TransactionOutput = Serialization.TransactionOutput;
|
|
41
|
+
type TransactionInputSet = Serialization.CborSet<ReturnType<TransactionInput["toCore"]>, TransactionInput>;
|
|
42
|
+
type TransactionWitnessPlutusData = Set<PlutusData>;
|
|
43
|
+
declare const PlutusData: typeof Serialization.PlutusData;
|
|
44
|
+
type PlutusData = Serialization.PlutusData;
|
|
45
|
+
declare const PlutusList: typeof Serialization.PlutusList;
|
|
46
|
+
type PlutusList = Serialization.PlutusList;
|
|
47
|
+
declare const PlutusMap: typeof Serialization.PlutusMap;
|
|
48
|
+
type PlutusMap = Serialization.PlutusMap;
|
|
49
|
+
declare const Redeemers: typeof Serialization.Redeemers;
|
|
50
|
+
type Redeemers = Serialization.Redeemers;
|
|
51
|
+
declare const Redeemer: typeof Serialization.Redeemer;
|
|
52
|
+
type Redeemer = Serialization.Redeemer;
|
|
53
|
+
declare const RedeemerPurpose: typeof Cardano.RedeemerPurpose;
|
|
54
|
+
type RedeemerPurpose = Cardano.RedeemerPurpose;
|
|
55
|
+
declare const RedeemerTag: typeof Serialization.RedeemerTag;
|
|
56
|
+
type RedeemerTag = Serialization.RedeemerTag;
|
|
57
|
+
declare const Script: typeof Serialization.Script;
|
|
58
|
+
type Script = Serialization.Script;
|
|
59
|
+
declare const PolicyId: (value: string) => Cardano.PolicyId;
|
|
60
|
+
type PolicyId = Cardano.PolicyId;
|
|
61
|
+
declare const AssetName: {
|
|
62
|
+
(value: string): Cardano.AssetName;
|
|
63
|
+
toUTF8(assetName: Cardano.AssetName, stripInvisibleCharacters?: boolean): string;
|
|
64
|
+
};
|
|
65
|
+
type AssetName = Cardano.AssetName;
|
|
66
|
+
declare const AssetId: {
|
|
67
|
+
(value: string): Cardano.AssetId;
|
|
68
|
+
getPolicyId(id: Cardano.AssetId): Cardano.PolicyId;
|
|
69
|
+
getAssetName(id: Cardano.AssetId): Cardano.AssetName;
|
|
70
|
+
fromParts(policyId: Cardano.PolicyId, assetName: Cardano.AssetName): Cardano.AssetId;
|
|
71
|
+
getAssetNameAsText(id: Cardano.AssetId): string;
|
|
72
|
+
};
|
|
73
|
+
type AssetId = Cardano.AssetId;
|
|
74
|
+
declare const ScriptHash: {
|
|
75
|
+
(value: string): Crypto.Hash28ByteBase16;
|
|
76
|
+
fromEd25519KeyHashHex(value: Crypto.Ed25519KeyHashHex): Crypto.Hash28ByteBase16;
|
|
77
|
+
};
|
|
78
|
+
type ScriptHash = Crypto.Hash28ByteBase16;
|
|
79
|
+
declare const Address: typeof Cardano.Address;
|
|
80
|
+
type Address = Cardano.Address;
|
|
81
|
+
declare const RewardAddress: typeof Cardano.RewardAddress;
|
|
82
|
+
type RewardAddress = Cardano.RewardAddress;
|
|
83
|
+
declare const AddressType: typeof Cardano.AddressType;
|
|
84
|
+
type AddressType = Cardano.AddressType;
|
|
85
|
+
declare const BaseAddress: typeof Cardano.BaseAddress;
|
|
86
|
+
type BaseAddress = Cardano.BaseAddress;
|
|
87
|
+
declare const EnterpriseAddress: typeof Cardano.EnterpriseAddress;
|
|
88
|
+
type EnterpriseAddress = Cardano.EnterpriseAddress;
|
|
89
|
+
declare const PaymentAddress: (value: string) => Cardano.PaymentAddress;
|
|
90
|
+
type PaymentAddress = Cardano.PaymentAddress;
|
|
91
|
+
declare const AssetFingerprint: {
|
|
92
|
+
(value: string): Cardano.AssetFingerprint;
|
|
93
|
+
fromParts(policyId: Cardano.PolicyId, assetName: Cardano.AssetName): Cardano.AssetFingerprint;
|
|
94
|
+
};
|
|
95
|
+
type AssetFingerprint = Cardano.AssetFingerprint;
|
|
96
|
+
declare const Credential: typeof Serialization.Credential;
|
|
97
|
+
type Credential = Serialization.Credential;
|
|
98
|
+
type CredentialCore = Cardano.Credential;
|
|
99
|
+
declare const Ed25519PublicKeyHex: (value: string) => Crypto.Ed25519PublicKeyHex;
|
|
100
|
+
type Ed25519PublicKeyHex = Crypto.Ed25519PublicKeyHex;
|
|
101
|
+
type Ed25519PrivateNormalKeyHex = OpaqueString<"Ed25519PrivateKeyHex">;
|
|
102
|
+
declare const Ed25519PrivateNormalKeyHex: (value: string) => Ed25519PrivateNormalKeyHex;
|
|
103
|
+
type Ed25519PrivateExtendedKeyHex = OpaqueString<"Ed25519PrivateKeyHex">;
|
|
104
|
+
declare const Ed25519PrivateExtendedKeyHex: (value: string) => Ed25519PrivateExtendedKeyHex;
|
|
105
|
+
declare const Ed25519KeyHash: typeof Crypto.Ed25519KeyHash;
|
|
106
|
+
type Ed25519KeyHash = Crypto.Ed25519KeyHash;
|
|
107
|
+
declare const Ed25519KeyHashHex: (value: string) => Crypto.Ed25519KeyHashHex;
|
|
108
|
+
type Ed25519KeyHashHex = Crypto.Ed25519KeyHashHex;
|
|
109
|
+
declare const Hash28ByteBase16: {
|
|
110
|
+
(value: string): Crypto.Hash28ByteBase16;
|
|
111
|
+
fromEd25519KeyHashHex(value: Crypto.Ed25519KeyHashHex): Crypto.Hash28ByteBase16;
|
|
112
|
+
};
|
|
113
|
+
type Hash28ByteBase16 = Crypto.Hash28ByteBase16;
|
|
114
|
+
declare const Hash32ByteBase16: {
|
|
115
|
+
(value: string): Crypto.Hash32ByteBase16;
|
|
116
|
+
fromHexBlob<T>(value: _cardano_sdk_util.HexBlob): T;
|
|
117
|
+
};
|
|
118
|
+
type Hash32ByteBase16 = Crypto.Hash32ByteBase16;
|
|
119
|
+
declare const CredentialType: typeof Cardano.CredentialType;
|
|
120
|
+
type CredentialType = Cardano.CredentialType;
|
|
121
|
+
declare const Certificate: typeof Serialization.Certificate;
|
|
122
|
+
type Certificate = Serialization.Certificate;
|
|
123
|
+
declare const PoolId: {
|
|
124
|
+
(value: string): Cardano.PoolId;
|
|
125
|
+
fromKeyHash(value: Crypto.Ed25519KeyHashHex): Cardano.PoolId;
|
|
126
|
+
toKeyHash(poolId: Cardano.PoolId): Crypto.Ed25519KeyHashHex;
|
|
127
|
+
};
|
|
128
|
+
type PoolId = Cardano.PoolId;
|
|
129
|
+
declare const StakeRegistration: typeof Serialization.StakeRegistration;
|
|
130
|
+
type StakeRegistration = Serialization.StakeRegistration;
|
|
131
|
+
declare const StakeDelegation: typeof Serialization.StakeDelegation;
|
|
132
|
+
type StakeDelegation = Serialization.StakeDelegation;
|
|
133
|
+
type StakeDelegationCertificate = Cardano.StakeDelegationCertificate;
|
|
134
|
+
declare const CertificateType: typeof Cardano.CertificateType;
|
|
135
|
+
type CertificateType = Cardano.CertificateType;
|
|
136
|
+
declare const VkeyWitness: typeof Serialization.VkeyWitness;
|
|
137
|
+
type VkeyWitness = Serialization.VkeyWitness;
|
|
138
|
+
declare const Ed25519SignatureHex: (value: string) => Crypto.Ed25519SignatureHex;
|
|
139
|
+
type Ed25519SignatureHex = Crypto.Ed25519SignatureHex;
|
|
140
|
+
declare const Ed25519PublicKey: typeof Crypto.Ed25519PublicKey;
|
|
141
|
+
type Ed25519PublicKey = Crypto.Ed25519PublicKey;
|
|
142
|
+
declare const Ed25519Signature: typeof Crypto.Ed25519Signature;
|
|
143
|
+
type Ed25519Signature = Crypto.Ed25519Signature;
|
|
144
|
+
declare const Bip32PrivateKey: typeof Crypto.Bip32PrivateKey;
|
|
145
|
+
type Bip32PrivateKey = Crypto.Bip32PrivateKey;
|
|
146
|
+
declare const Bip32PrivateKeyHex: (key: string) => Crypto.Bip32PrivateKeyHex;
|
|
147
|
+
type Bip32PrivateKeyHex = Crypto.Bip32PrivateKeyHex;
|
|
148
|
+
declare const PlutusLanguageVersion: typeof Cardano.PlutusLanguageVersion;
|
|
149
|
+
type PlutusLanguageVersion = Cardano.PlutusLanguageVersion;
|
|
150
|
+
declare const NativeScript: typeof Serialization.NativeScript;
|
|
151
|
+
type NativeScript = Serialization.NativeScript;
|
|
152
|
+
declare const PlutusV1Script: typeof Serialization.PlutusV1Script;
|
|
153
|
+
type PlutusV1Script = Serialization.PlutusV1Script;
|
|
154
|
+
declare const PlutusV2Script: typeof Serialization.PlutusV2Script;
|
|
155
|
+
type PlutusV2Script = Serialization.PlutusV2Script;
|
|
156
|
+
declare const PlutusV3Script: typeof Serialization.PlutusV3Script;
|
|
157
|
+
type PlutusV3Script = Serialization.PlutusV3Script;
|
|
158
|
+
declare const Costmdls: typeof Serialization.Costmdls;
|
|
159
|
+
type Costmdls = Serialization.Costmdls;
|
|
160
|
+
declare const CostModel: typeof Serialization.CostModel;
|
|
161
|
+
type CostModel = Serialization.CostModel;
|
|
162
|
+
declare const CborWriter: typeof Serialization.CborWriter;
|
|
163
|
+
type CborWriter = Serialization.CborWriter;
|
|
164
|
+
declare const ConstrPlutusData: typeof Serialization.ConstrPlutusData;
|
|
165
|
+
type ConstrPlutusData = Serialization.ConstrPlutusData;
|
|
166
|
+
declare const RewardAccount: {
|
|
167
|
+
(value: string): Cardano.RewardAccount;
|
|
168
|
+
toHash(rewardAccount: Cardano.RewardAccount): Crypto.Ed25519KeyHashHex;
|
|
169
|
+
fromCredential(credential: Cardano.Credential, networkId: Cardano.NetworkId): Cardano.RewardAccount;
|
|
170
|
+
toNetworkId(rewardAccount: Cardano.RewardAccount): Cardano.NetworkId;
|
|
171
|
+
};
|
|
172
|
+
type RewardAccount = Cardano.RewardAccount;
|
|
173
|
+
declare const Hash: typeof Serialization.Hash;
|
|
174
|
+
type Hash<T extends string> = Serialization.Hash<T>;
|
|
175
|
+
declare const DatumHash: {
|
|
176
|
+
(value: string): Crypto.Hash32ByteBase16;
|
|
177
|
+
fromHexBlob<T>(value: _cardano_sdk_util.HexBlob): T;
|
|
178
|
+
};
|
|
179
|
+
type DatumHash = Crypto.Hash32ByteBase16;
|
|
180
|
+
declare const Datum: typeof Serialization.Datum;
|
|
181
|
+
type Datum = PlutusData | DatumHash;
|
|
182
|
+
type CostModels = Cardano.CostModels;
|
|
183
|
+
type ExUnits = Serialization.ExUnits;
|
|
184
|
+
declare const ExUnits: typeof Serialization.ExUnits;
|
|
185
|
+
declare const NetworkId: typeof Cardano.NetworkId;
|
|
186
|
+
type NetworkId = Cardano.ChainId["networkId"];
|
|
187
|
+
declare const DatumKind: typeof Serialization.DatumKind;
|
|
188
|
+
declare const CborSet: typeof Serialization.CborSet;
|
|
189
|
+
type Witness = Cardano.Witness;
|
|
190
|
+
type Signatures = Cardano.Signatures;
|
|
191
|
+
type RequireAllOf = Cardano.NativeScriptKind.RequireAllOf;
|
|
192
|
+
declare const RequireAllOf = Cardano.NativeScriptKind.RequireAllOf;
|
|
193
|
+
type RequireAnyOf = Cardano.NativeScriptKind.RequireAnyOf;
|
|
194
|
+
declare const RequireAnyOf = Cardano.NativeScriptKind.RequireAnyOf;
|
|
195
|
+
type RequireNOf = Cardano.NativeScriptKind.RequireNOf;
|
|
196
|
+
declare const RequireNOf = Cardano.NativeScriptKind.RequireNOf;
|
|
197
|
+
type RequireSignature = Cardano.NativeScriptKind.RequireSignature;
|
|
198
|
+
declare const RequireSignature = Cardano.NativeScriptKind.RequireSignature;
|
|
199
|
+
type RequireTimeAfter = Cardano.NativeScriptKind.RequireTimeAfter;
|
|
200
|
+
declare const RequireTimeAfter = Cardano.NativeScriptKind.RequireTimeAfter;
|
|
201
|
+
type RequireTimeBefore = Cardano.NativeScriptKind.RequireTimeBefore;
|
|
202
|
+
declare const RequireTimeBefore = Cardano.NativeScriptKind.RequireTimeBefore;
|
|
203
|
+
type VrfVkBech32 = Cardano.VrfVkBech32;
|
|
204
|
+
declare const VrfVkBech32: {
|
|
205
|
+
(value: string): Cardano.VrfVkBech32;
|
|
206
|
+
fromHex(value: string): Cardano.VrfVkBech32;
|
|
207
|
+
};
|
|
208
|
+
type ScriptPubkey = Serialization.ScriptPubkey;
|
|
209
|
+
declare const ScriptPubkey: typeof Serialization.ScriptPubkey;
|
|
210
|
+
|
|
211
|
+
type Signer = {
|
|
212
|
+
address: Address;
|
|
213
|
+
key: PrivateKey;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
declare const signData: (data: string, privateKey: PrivateKey) => DataSignature;
|
|
217
|
+
declare const checkSignature: (data: string, { key, signature }: DataSignature) => any;
|
|
218
|
+
|
|
219
|
+
declare const resolveDataHash: (data: Data) => string;
|
|
220
|
+
declare const resolveNativeScriptAddress: (script: NativeScript$1, networkId?: number) => Cardano.PaymentAddress | Cardano.RewardAccount;
|
|
221
|
+
declare const resolveNativeScriptHash: (script: NativeScript$1) => string;
|
|
222
|
+
declare const resolvePaymentKeyHash: (bech32: string) => string;
|
|
223
|
+
declare const resolvePlutusScriptAddress: (script: PlutusScript, networkId?: number) => Cardano.PaymentAddress | Cardano.RewardAccount;
|
|
224
|
+
declare const resolvePlutusScriptHash: (bech32: string) => string;
|
|
225
|
+
declare const resolvePoolId: (hash: string) => string;
|
|
226
|
+
declare const resolvePrivateKey: (words: string[]) => string;
|
|
227
|
+
declare const resolveScriptRef: (script: PlutusScript | NativeScript$1) => string;
|
|
228
|
+
declare const resolveRewardAddress: (bech32: string) => Cardano.PaymentAddress | Cardano.RewardAccount;
|
|
229
|
+
declare const resolveStakeKeyHash: (bech32: string) => string;
|
|
230
|
+
declare const resolveTxHash: (txHex: string) => Cardano.TransactionId;
|
|
231
|
+
|
|
232
|
+
declare class CardanoSDKSerializer implements IMeshTxSerializer {
|
|
233
|
+
private txBody;
|
|
234
|
+
private txWitnessSet;
|
|
235
|
+
private utxoContext;
|
|
236
|
+
private redeemerContext;
|
|
237
|
+
private scriptsProvided;
|
|
238
|
+
private datumsProvided;
|
|
239
|
+
private usedLanguages;
|
|
240
|
+
constructor();
|
|
241
|
+
serializeAddress(address: DeserializedAddress, networkId?: 0 | 1): string;
|
|
242
|
+
serializeData(data: BuilderData): string;
|
|
243
|
+
deserializer: IDeserializer;
|
|
244
|
+
resolver: IResolver;
|
|
245
|
+
serializeTxBody: (txBuilderBody: MeshTxBuilderBody, protocolParams: Protocol) => string;
|
|
246
|
+
addSigningKeys: (txHex: string, signingKeys: string[]) => string;
|
|
247
|
+
private addAllInputs;
|
|
248
|
+
private addTxIn;
|
|
249
|
+
private addScriptTxIn;
|
|
250
|
+
private addSimpleScriptTxIn;
|
|
251
|
+
private addAllOutputs;
|
|
252
|
+
private addOutput;
|
|
253
|
+
private addAllReferenceInputs;
|
|
254
|
+
private addReferenceIput;
|
|
255
|
+
private addAllMints;
|
|
256
|
+
private addMint;
|
|
257
|
+
private addAllCollateralInputs;
|
|
258
|
+
private addCollateralInput;
|
|
259
|
+
private setValidityInterval;
|
|
260
|
+
private buildWitnessSet;
|
|
261
|
+
private balanceTx;
|
|
262
|
+
private createDummyTx;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
declare const buildBaseAddress: (networkId: number, paymentKeyHash: Hash28ByteBase16, stakeKeyHash: Hash28ByteBase16) => BaseAddress;
|
|
266
|
+
declare const buildEnterpriseAddress: (networkId: number, paymentKeyHash: Hash28ByteBase16) => EnterpriseAddress;
|
|
267
|
+
declare const buildBip32PrivateKey: (entropy: string, password?: string) => Bip32PrivateKey;
|
|
268
|
+
declare const buildRewardAddress: (networkId: number, stakeKeyHash: Hash28ByteBase16) => RewardAddress;
|
|
269
|
+
declare const buildKeys: (entropy: string | [string, string], accountIndex: number, keyIndex?: number) => {
|
|
270
|
+
paymentKey: PrivateKey;
|
|
271
|
+
stakeKey: PrivateKey;
|
|
272
|
+
};
|
|
273
|
+
declare const buildScriptPubkey: (keyHash: Ed25519KeyHash) => NativeScript;
|
|
274
|
+
|
|
275
|
+
declare const toAddress: (bech32: string) => Address;
|
|
276
|
+
declare const toBaseAddress: (bech32: string) => BaseAddress | undefined;
|
|
277
|
+
declare const toEnterpriseAddress: (bech32: string) => EnterpriseAddress | undefined;
|
|
278
|
+
declare const toRewardAddress: (bech32: string) => RewardAddress | undefined;
|
|
279
|
+
declare const fromTxUnspentOutput: (txUnspentOutput: TransactionUnspentOutput) => UTxO;
|
|
280
|
+
declare const toTxUnspentOutput: (utxo: UTxO) => Serialization.TransactionUnspentOutput;
|
|
281
|
+
declare const addressToBech32: (address: Address) => string;
|
|
282
|
+
declare const fromValue: (value: Value) => Asset[];
|
|
283
|
+
declare const toScriptRef: (script: PlutusScript | NativeScript$1) => Script;
|
|
284
|
+
declare const fromScriptRef: (scriptRef: string) => PlutusScript | NativeScript$1 | undefined;
|
|
285
|
+
declare const fromNativeScript: (script: NativeScript) => NativeScript$1;
|
|
286
|
+
declare const toNativeScript: (script: NativeScript$1) => Serialization.NativeScript;
|
|
287
|
+
declare const toPlutusData: (data: Data) => PlutusData;
|
|
288
|
+
declare const toValue: (assets: Asset[]) => Serialization.Value;
|
|
289
|
+
|
|
290
|
+
declare const deserializeAddress: (address: string) => Address;
|
|
291
|
+
declare const deserializeEd25519KeyHash: (ed25519KeyHash: string) => Crypto.Ed25519KeyHash;
|
|
292
|
+
declare const deserializeDataHash: (dataHash: string) => DatumHash;
|
|
293
|
+
declare const deserializePlutusData: (plutusData: string) => PlutusData;
|
|
294
|
+
declare const deserializePlutusScript: (plutusScript: string, version: LanguageVersion) => PlutusV1Script | PlutusV2Script | PlutusV3Script;
|
|
295
|
+
declare const deserializeNativeScript: (nativeScript: string) => NativeScript;
|
|
296
|
+
declare const deserializeScriptHash: (scriptHash: string) => Crypto.Hash28ByteBase16;
|
|
297
|
+
declare const deserializeScriptRef: (scriptRef: string) => Script;
|
|
298
|
+
declare const deserializeTxUnspentOutput: (txUnspentOutput: string) => TransactionUnspentOutput;
|
|
299
|
+
declare const deserializeValue: (value: string) => Value;
|
|
300
|
+
declare const deserializeTx: (tx: string) => Transaction;
|
|
301
|
+
declare const deserializeTxHash: (txHash: string) => TransactionId;
|
|
302
|
+
|
|
303
|
+
declare function mergeValue(a: Value, b: Value): Value;
|
|
304
|
+
declare function negateValue(v: Value): Value;
|
|
305
|
+
declare function subValue(a: Value, b: Value): Value;
|
|
306
|
+
declare function negatives(v: Value): Value;
|
|
307
|
+
declare function assetTypes(v: Value): number;
|
|
308
|
+
declare function empty(v: Value): boolean;
|
|
309
|
+
|
|
310
|
+
export { Address, AddressType, AssetFingerprint, AssetId, AssetName, BaseAddress, Bip32PrivateKey, Bip32PrivateKeyHex, CardanoSDKSerializer, CborSet, CborWriter, Certificate, CertificateType, ConstrPlutusData, CostModel, type CostModels, Costmdls, Credential, type CredentialCore, CredentialType, 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, type Signatures, type Signer, Slot, StakeDelegation, type StakeDelegationCertificate, StakeRegistration, type TokenMap, Transaction, TransactionBody, TransactionId, TransactionInput, type TransactionInputSet, TransactionOutput, TransactionUnspentOutput, type TransactionWitnessPlutusData, TransactionWitnessSet, Value, VkeyWitness, VrfVkBech32, type Witness, 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 };
|