@meshsdk/core-cst 1.6.2 → 1.6.4
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 +2839 -1
- package/dist/index.d.cts +63 -12
- package/dist/index.d.ts +63 -12
- package/dist/index.js +2690 -1
- package/package.json +10 -8
package/dist/index.cjs
CHANGED
|
@@ -1 +1,2839 @@
|
|
|
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});
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/blakejs/util.js
|
|
34
|
+
var require_util = __commonJS({
|
|
35
|
+
"../../node_modules/blakejs/util.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
var ERROR_MSG_INPUT = "Input must be an string, Buffer or Uint8Array";
|
|
38
|
+
function normalizeInput(input) {
|
|
39
|
+
let ret;
|
|
40
|
+
if (input instanceof Uint8Array) {
|
|
41
|
+
ret = input;
|
|
42
|
+
} else if (typeof input === "string") {
|
|
43
|
+
const encoder = new TextEncoder();
|
|
44
|
+
ret = encoder.encode(input);
|
|
45
|
+
} else {
|
|
46
|
+
throw new Error(ERROR_MSG_INPUT);
|
|
47
|
+
}
|
|
48
|
+
return ret;
|
|
49
|
+
}
|
|
50
|
+
function toHex(bytes) {
|
|
51
|
+
return Array.prototype.map.call(bytes, function(n) {
|
|
52
|
+
return (n < 16 ? "0" : "") + n.toString(16);
|
|
53
|
+
}).join("");
|
|
54
|
+
}
|
|
55
|
+
function uint32ToHex(val) {
|
|
56
|
+
return (4294967296 + val).toString(16).substring(1);
|
|
57
|
+
}
|
|
58
|
+
function debugPrint(label, arr, size) {
|
|
59
|
+
let msg = "\n" + label + " = ";
|
|
60
|
+
for (let i = 0; i < arr.length; i += 2) {
|
|
61
|
+
if (size === 32) {
|
|
62
|
+
msg += uint32ToHex(arr[i]).toUpperCase();
|
|
63
|
+
msg += " ";
|
|
64
|
+
msg += uint32ToHex(arr[i + 1]).toUpperCase();
|
|
65
|
+
} else if (size === 64) {
|
|
66
|
+
msg += uint32ToHex(arr[i + 1]).toUpperCase();
|
|
67
|
+
msg += uint32ToHex(arr[i]).toUpperCase();
|
|
68
|
+
} else throw new Error("Invalid size " + size);
|
|
69
|
+
if (i % 6 === 4) {
|
|
70
|
+
msg += "\n" + new Array(label.length + 4).join(" ");
|
|
71
|
+
} else if (i < arr.length - 2) {
|
|
72
|
+
msg += " ";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
console.log(msg);
|
|
76
|
+
}
|
|
77
|
+
function testSpeed(hashFn, N, M) {
|
|
78
|
+
let startMs = (/* @__PURE__ */ new Date()).getTime();
|
|
79
|
+
const input = new Uint8Array(N);
|
|
80
|
+
for (let i = 0; i < N; i++) {
|
|
81
|
+
input[i] = i % 256;
|
|
82
|
+
}
|
|
83
|
+
const genMs = (/* @__PURE__ */ new Date()).getTime();
|
|
84
|
+
console.log("Generated random input in " + (genMs - startMs) + "ms");
|
|
85
|
+
startMs = genMs;
|
|
86
|
+
for (let i = 0; i < M; i++) {
|
|
87
|
+
const hashHex = hashFn(input);
|
|
88
|
+
const hashMs = (/* @__PURE__ */ new Date()).getTime();
|
|
89
|
+
const ms = hashMs - startMs;
|
|
90
|
+
startMs = hashMs;
|
|
91
|
+
console.log("Hashed in " + ms + "ms: " + hashHex.substring(0, 20) + "...");
|
|
92
|
+
console.log(
|
|
93
|
+
Math.round(N / (1 << 20) / (ms / 1e3) * 100) / 100 + " MB PER SECOND"
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
module2.exports = {
|
|
98
|
+
normalizeInput,
|
|
99
|
+
toHex,
|
|
100
|
+
debugPrint,
|
|
101
|
+
testSpeed
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// ../../node_modules/blakejs/blake2b.js
|
|
107
|
+
var require_blake2b = __commonJS({
|
|
108
|
+
"../../node_modules/blakejs/blake2b.js"(exports2, module2) {
|
|
109
|
+
"use strict";
|
|
110
|
+
var util = require_util();
|
|
111
|
+
function ADD64AA(v2, a, b) {
|
|
112
|
+
const o0 = v2[a] + v2[b];
|
|
113
|
+
let o1 = v2[a + 1] + v2[b + 1];
|
|
114
|
+
if (o0 >= 4294967296) {
|
|
115
|
+
o1++;
|
|
116
|
+
}
|
|
117
|
+
v2[a] = o0;
|
|
118
|
+
v2[a + 1] = o1;
|
|
119
|
+
}
|
|
120
|
+
function ADD64AC(v2, a, b0, b1) {
|
|
121
|
+
let o0 = v2[a] + b0;
|
|
122
|
+
if (b0 < 0) {
|
|
123
|
+
o0 += 4294967296;
|
|
124
|
+
}
|
|
125
|
+
let o1 = v2[a + 1] + b1;
|
|
126
|
+
if (o0 >= 4294967296) {
|
|
127
|
+
o1++;
|
|
128
|
+
}
|
|
129
|
+
v2[a] = o0;
|
|
130
|
+
v2[a + 1] = o1;
|
|
131
|
+
}
|
|
132
|
+
function B2B_GET32(arr, i) {
|
|
133
|
+
return arr[i] ^ arr[i + 1] << 8 ^ arr[i + 2] << 16 ^ arr[i + 3] << 24;
|
|
134
|
+
}
|
|
135
|
+
function B2B_G(a, b, c, d, ix, iy) {
|
|
136
|
+
const x0 = m[ix];
|
|
137
|
+
const x1 = m[ix + 1];
|
|
138
|
+
const y0 = m[iy];
|
|
139
|
+
const y1 = m[iy + 1];
|
|
140
|
+
ADD64AA(v, a, b);
|
|
141
|
+
ADD64AC(v, a, x0, x1);
|
|
142
|
+
let xor0 = v[d] ^ v[a];
|
|
143
|
+
let xor1 = v[d + 1] ^ v[a + 1];
|
|
144
|
+
v[d] = xor1;
|
|
145
|
+
v[d + 1] = xor0;
|
|
146
|
+
ADD64AA(v, c, d);
|
|
147
|
+
xor0 = v[b] ^ v[c];
|
|
148
|
+
xor1 = v[b + 1] ^ v[c + 1];
|
|
149
|
+
v[b] = xor0 >>> 24 ^ xor1 << 8;
|
|
150
|
+
v[b + 1] = xor1 >>> 24 ^ xor0 << 8;
|
|
151
|
+
ADD64AA(v, a, b);
|
|
152
|
+
ADD64AC(v, a, y0, y1);
|
|
153
|
+
xor0 = v[d] ^ v[a];
|
|
154
|
+
xor1 = v[d + 1] ^ v[a + 1];
|
|
155
|
+
v[d] = xor0 >>> 16 ^ xor1 << 16;
|
|
156
|
+
v[d + 1] = xor1 >>> 16 ^ xor0 << 16;
|
|
157
|
+
ADD64AA(v, c, d);
|
|
158
|
+
xor0 = v[b] ^ v[c];
|
|
159
|
+
xor1 = v[b + 1] ^ v[c + 1];
|
|
160
|
+
v[b] = xor1 >>> 31 ^ xor0 << 1;
|
|
161
|
+
v[b + 1] = xor0 >>> 31 ^ xor1 << 1;
|
|
162
|
+
}
|
|
163
|
+
var BLAKE2B_IV32 = new Uint32Array([
|
|
164
|
+
4089235720,
|
|
165
|
+
1779033703,
|
|
166
|
+
2227873595,
|
|
167
|
+
3144134277,
|
|
168
|
+
4271175723,
|
|
169
|
+
1013904242,
|
|
170
|
+
1595750129,
|
|
171
|
+
2773480762,
|
|
172
|
+
2917565137,
|
|
173
|
+
1359893119,
|
|
174
|
+
725511199,
|
|
175
|
+
2600822924,
|
|
176
|
+
4215389547,
|
|
177
|
+
528734635,
|
|
178
|
+
327033209,
|
|
179
|
+
1541459225
|
|
180
|
+
]);
|
|
181
|
+
var SIGMA8 = [
|
|
182
|
+
0,
|
|
183
|
+
1,
|
|
184
|
+
2,
|
|
185
|
+
3,
|
|
186
|
+
4,
|
|
187
|
+
5,
|
|
188
|
+
6,
|
|
189
|
+
7,
|
|
190
|
+
8,
|
|
191
|
+
9,
|
|
192
|
+
10,
|
|
193
|
+
11,
|
|
194
|
+
12,
|
|
195
|
+
13,
|
|
196
|
+
14,
|
|
197
|
+
15,
|
|
198
|
+
14,
|
|
199
|
+
10,
|
|
200
|
+
4,
|
|
201
|
+
8,
|
|
202
|
+
9,
|
|
203
|
+
15,
|
|
204
|
+
13,
|
|
205
|
+
6,
|
|
206
|
+
1,
|
|
207
|
+
12,
|
|
208
|
+
0,
|
|
209
|
+
2,
|
|
210
|
+
11,
|
|
211
|
+
7,
|
|
212
|
+
5,
|
|
213
|
+
3,
|
|
214
|
+
11,
|
|
215
|
+
8,
|
|
216
|
+
12,
|
|
217
|
+
0,
|
|
218
|
+
5,
|
|
219
|
+
2,
|
|
220
|
+
15,
|
|
221
|
+
13,
|
|
222
|
+
10,
|
|
223
|
+
14,
|
|
224
|
+
3,
|
|
225
|
+
6,
|
|
226
|
+
7,
|
|
227
|
+
1,
|
|
228
|
+
9,
|
|
229
|
+
4,
|
|
230
|
+
7,
|
|
231
|
+
9,
|
|
232
|
+
3,
|
|
233
|
+
1,
|
|
234
|
+
13,
|
|
235
|
+
12,
|
|
236
|
+
11,
|
|
237
|
+
14,
|
|
238
|
+
2,
|
|
239
|
+
6,
|
|
240
|
+
5,
|
|
241
|
+
10,
|
|
242
|
+
4,
|
|
243
|
+
0,
|
|
244
|
+
15,
|
|
245
|
+
8,
|
|
246
|
+
9,
|
|
247
|
+
0,
|
|
248
|
+
5,
|
|
249
|
+
7,
|
|
250
|
+
2,
|
|
251
|
+
4,
|
|
252
|
+
10,
|
|
253
|
+
15,
|
|
254
|
+
14,
|
|
255
|
+
1,
|
|
256
|
+
11,
|
|
257
|
+
12,
|
|
258
|
+
6,
|
|
259
|
+
8,
|
|
260
|
+
3,
|
|
261
|
+
13,
|
|
262
|
+
2,
|
|
263
|
+
12,
|
|
264
|
+
6,
|
|
265
|
+
10,
|
|
266
|
+
0,
|
|
267
|
+
11,
|
|
268
|
+
8,
|
|
269
|
+
3,
|
|
270
|
+
4,
|
|
271
|
+
13,
|
|
272
|
+
7,
|
|
273
|
+
5,
|
|
274
|
+
15,
|
|
275
|
+
14,
|
|
276
|
+
1,
|
|
277
|
+
9,
|
|
278
|
+
12,
|
|
279
|
+
5,
|
|
280
|
+
1,
|
|
281
|
+
15,
|
|
282
|
+
14,
|
|
283
|
+
13,
|
|
284
|
+
4,
|
|
285
|
+
10,
|
|
286
|
+
0,
|
|
287
|
+
7,
|
|
288
|
+
6,
|
|
289
|
+
3,
|
|
290
|
+
9,
|
|
291
|
+
2,
|
|
292
|
+
8,
|
|
293
|
+
11,
|
|
294
|
+
13,
|
|
295
|
+
11,
|
|
296
|
+
7,
|
|
297
|
+
14,
|
|
298
|
+
12,
|
|
299
|
+
1,
|
|
300
|
+
3,
|
|
301
|
+
9,
|
|
302
|
+
5,
|
|
303
|
+
0,
|
|
304
|
+
15,
|
|
305
|
+
4,
|
|
306
|
+
8,
|
|
307
|
+
6,
|
|
308
|
+
2,
|
|
309
|
+
10,
|
|
310
|
+
6,
|
|
311
|
+
15,
|
|
312
|
+
14,
|
|
313
|
+
9,
|
|
314
|
+
11,
|
|
315
|
+
3,
|
|
316
|
+
0,
|
|
317
|
+
8,
|
|
318
|
+
12,
|
|
319
|
+
2,
|
|
320
|
+
13,
|
|
321
|
+
7,
|
|
322
|
+
1,
|
|
323
|
+
4,
|
|
324
|
+
10,
|
|
325
|
+
5,
|
|
326
|
+
10,
|
|
327
|
+
2,
|
|
328
|
+
8,
|
|
329
|
+
4,
|
|
330
|
+
7,
|
|
331
|
+
6,
|
|
332
|
+
1,
|
|
333
|
+
5,
|
|
334
|
+
15,
|
|
335
|
+
11,
|
|
336
|
+
9,
|
|
337
|
+
14,
|
|
338
|
+
3,
|
|
339
|
+
12,
|
|
340
|
+
13,
|
|
341
|
+
0,
|
|
342
|
+
0,
|
|
343
|
+
1,
|
|
344
|
+
2,
|
|
345
|
+
3,
|
|
346
|
+
4,
|
|
347
|
+
5,
|
|
348
|
+
6,
|
|
349
|
+
7,
|
|
350
|
+
8,
|
|
351
|
+
9,
|
|
352
|
+
10,
|
|
353
|
+
11,
|
|
354
|
+
12,
|
|
355
|
+
13,
|
|
356
|
+
14,
|
|
357
|
+
15,
|
|
358
|
+
14,
|
|
359
|
+
10,
|
|
360
|
+
4,
|
|
361
|
+
8,
|
|
362
|
+
9,
|
|
363
|
+
15,
|
|
364
|
+
13,
|
|
365
|
+
6,
|
|
366
|
+
1,
|
|
367
|
+
12,
|
|
368
|
+
0,
|
|
369
|
+
2,
|
|
370
|
+
11,
|
|
371
|
+
7,
|
|
372
|
+
5,
|
|
373
|
+
3
|
|
374
|
+
];
|
|
375
|
+
var SIGMA82 = new Uint8Array(
|
|
376
|
+
SIGMA8.map(function(x) {
|
|
377
|
+
return x * 2;
|
|
378
|
+
})
|
|
379
|
+
);
|
|
380
|
+
var v = new Uint32Array(32);
|
|
381
|
+
var m = new Uint32Array(32);
|
|
382
|
+
function blake2bCompress(ctx, last) {
|
|
383
|
+
let i = 0;
|
|
384
|
+
for (i = 0; i < 16; i++) {
|
|
385
|
+
v[i] = ctx.h[i];
|
|
386
|
+
v[i + 16] = BLAKE2B_IV32[i];
|
|
387
|
+
}
|
|
388
|
+
v[24] = v[24] ^ ctx.t;
|
|
389
|
+
v[25] = v[25] ^ ctx.t / 4294967296;
|
|
390
|
+
if (last) {
|
|
391
|
+
v[28] = ~v[28];
|
|
392
|
+
v[29] = ~v[29];
|
|
393
|
+
}
|
|
394
|
+
for (i = 0; i < 32; i++) {
|
|
395
|
+
m[i] = B2B_GET32(ctx.b, 4 * i);
|
|
396
|
+
}
|
|
397
|
+
for (i = 0; i < 12; i++) {
|
|
398
|
+
B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]);
|
|
399
|
+
B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]);
|
|
400
|
+
B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]);
|
|
401
|
+
B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]);
|
|
402
|
+
B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]);
|
|
403
|
+
B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]);
|
|
404
|
+
B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]);
|
|
405
|
+
B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]);
|
|
406
|
+
}
|
|
407
|
+
for (i = 0; i < 16; i++) {
|
|
408
|
+
ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16];
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
var parameterBlock = new Uint8Array([
|
|
412
|
+
0,
|
|
413
|
+
0,
|
|
414
|
+
0,
|
|
415
|
+
0,
|
|
416
|
+
// 0: outlen, keylen, fanout, depth
|
|
417
|
+
0,
|
|
418
|
+
0,
|
|
419
|
+
0,
|
|
420
|
+
0,
|
|
421
|
+
// 4: leaf length, sequential mode
|
|
422
|
+
0,
|
|
423
|
+
0,
|
|
424
|
+
0,
|
|
425
|
+
0,
|
|
426
|
+
// 8: node offset
|
|
427
|
+
0,
|
|
428
|
+
0,
|
|
429
|
+
0,
|
|
430
|
+
0,
|
|
431
|
+
// 12: node offset
|
|
432
|
+
0,
|
|
433
|
+
0,
|
|
434
|
+
0,
|
|
435
|
+
0,
|
|
436
|
+
// 16: node depth, inner length, rfu
|
|
437
|
+
0,
|
|
438
|
+
0,
|
|
439
|
+
0,
|
|
440
|
+
0,
|
|
441
|
+
// 20: rfu
|
|
442
|
+
0,
|
|
443
|
+
0,
|
|
444
|
+
0,
|
|
445
|
+
0,
|
|
446
|
+
// 24: rfu
|
|
447
|
+
0,
|
|
448
|
+
0,
|
|
449
|
+
0,
|
|
450
|
+
0,
|
|
451
|
+
// 28: rfu
|
|
452
|
+
0,
|
|
453
|
+
0,
|
|
454
|
+
0,
|
|
455
|
+
0,
|
|
456
|
+
// 32: salt
|
|
457
|
+
0,
|
|
458
|
+
0,
|
|
459
|
+
0,
|
|
460
|
+
0,
|
|
461
|
+
// 36: salt
|
|
462
|
+
0,
|
|
463
|
+
0,
|
|
464
|
+
0,
|
|
465
|
+
0,
|
|
466
|
+
// 40: salt
|
|
467
|
+
0,
|
|
468
|
+
0,
|
|
469
|
+
0,
|
|
470
|
+
0,
|
|
471
|
+
// 44: salt
|
|
472
|
+
0,
|
|
473
|
+
0,
|
|
474
|
+
0,
|
|
475
|
+
0,
|
|
476
|
+
// 48: personal
|
|
477
|
+
0,
|
|
478
|
+
0,
|
|
479
|
+
0,
|
|
480
|
+
0,
|
|
481
|
+
// 52: personal
|
|
482
|
+
0,
|
|
483
|
+
0,
|
|
484
|
+
0,
|
|
485
|
+
0,
|
|
486
|
+
// 56: personal
|
|
487
|
+
0,
|
|
488
|
+
0,
|
|
489
|
+
0,
|
|
490
|
+
0
|
|
491
|
+
// 60: personal
|
|
492
|
+
]);
|
|
493
|
+
function blake2bInit(outlen, key, salt, personal) {
|
|
494
|
+
if (outlen === 0 || outlen > 64) {
|
|
495
|
+
throw new Error("Illegal output length, expected 0 < length <= 64");
|
|
496
|
+
}
|
|
497
|
+
if (key && key.length > 64) {
|
|
498
|
+
throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");
|
|
499
|
+
}
|
|
500
|
+
if (salt && salt.length !== 16) {
|
|
501
|
+
throw new Error("Illegal salt, expected Uint8Array with length is 16");
|
|
502
|
+
}
|
|
503
|
+
if (personal && personal.length !== 16) {
|
|
504
|
+
throw new Error("Illegal personal, expected Uint8Array with length is 16");
|
|
505
|
+
}
|
|
506
|
+
const ctx = {
|
|
507
|
+
b: new Uint8Array(128),
|
|
508
|
+
h: new Uint32Array(16),
|
|
509
|
+
t: 0,
|
|
510
|
+
// input count
|
|
511
|
+
c: 0,
|
|
512
|
+
// pointer within buffer
|
|
513
|
+
outlen
|
|
514
|
+
// output length in bytes
|
|
515
|
+
};
|
|
516
|
+
parameterBlock.fill(0);
|
|
517
|
+
parameterBlock[0] = outlen;
|
|
518
|
+
if (key) parameterBlock[1] = key.length;
|
|
519
|
+
parameterBlock[2] = 1;
|
|
520
|
+
parameterBlock[3] = 1;
|
|
521
|
+
if (salt) parameterBlock.set(salt, 32);
|
|
522
|
+
if (personal) parameterBlock.set(personal, 48);
|
|
523
|
+
for (let i = 0; i < 16; i++) {
|
|
524
|
+
ctx.h[i] = BLAKE2B_IV32[i] ^ B2B_GET32(parameterBlock, i * 4);
|
|
525
|
+
}
|
|
526
|
+
if (key) {
|
|
527
|
+
blake2bUpdate(ctx, key);
|
|
528
|
+
ctx.c = 128;
|
|
529
|
+
}
|
|
530
|
+
return ctx;
|
|
531
|
+
}
|
|
532
|
+
function blake2bUpdate(ctx, input) {
|
|
533
|
+
for (let i = 0; i < input.length; i++) {
|
|
534
|
+
if (ctx.c === 128) {
|
|
535
|
+
ctx.t += ctx.c;
|
|
536
|
+
blake2bCompress(ctx, false);
|
|
537
|
+
ctx.c = 0;
|
|
538
|
+
}
|
|
539
|
+
ctx.b[ctx.c++] = input[i];
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
function blake2bFinal(ctx) {
|
|
543
|
+
ctx.t += ctx.c;
|
|
544
|
+
while (ctx.c < 128) {
|
|
545
|
+
ctx.b[ctx.c++] = 0;
|
|
546
|
+
}
|
|
547
|
+
blake2bCompress(ctx, true);
|
|
548
|
+
const out = new Uint8Array(ctx.outlen);
|
|
549
|
+
for (let i = 0; i < ctx.outlen; i++) {
|
|
550
|
+
out[i] = ctx.h[i >> 2] >> 8 * (i & 3);
|
|
551
|
+
}
|
|
552
|
+
return out;
|
|
553
|
+
}
|
|
554
|
+
function blake2b5(input, key, outlen, salt, personal) {
|
|
555
|
+
outlen = outlen || 64;
|
|
556
|
+
input = util.normalizeInput(input);
|
|
557
|
+
if (salt) {
|
|
558
|
+
salt = util.normalizeInput(salt);
|
|
559
|
+
}
|
|
560
|
+
if (personal) {
|
|
561
|
+
personal = util.normalizeInput(personal);
|
|
562
|
+
}
|
|
563
|
+
const ctx = blake2bInit(outlen, key, salt, personal);
|
|
564
|
+
blake2bUpdate(ctx, input);
|
|
565
|
+
return blake2bFinal(ctx);
|
|
566
|
+
}
|
|
567
|
+
function blake2bHex(input, key, outlen, salt, personal) {
|
|
568
|
+
const output = blake2b5(input, key, outlen, salt, personal);
|
|
569
|
+
return util.toHex(output);
|
|
570
|
+
}
|
|
571
|
+
module2.exports = {
|
|
572
|
+
blake2b: blake2b5,
|
|
573
|
+
blake2bHex,
|
|
574
|
+
blake2bInit,
|
|
575
|
+
blake2bUpdate,
|
|
576
|
+
blake2bFinal
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
// ../../node_modules/blakejs/blake2s.js
|
|
582
|
+
var require_blake2s = __commonJS({
|
|
583
|
+
"../../node_modules/blakejs/blake2s.js"(exports2, module2) {
|
|
584
|
+
"use strict";
|
|
585
|
+
var util = require_util();
|
|
586
|
+
function B2S_GET32(v2, i) {
|
|
587
|
+
return v2[i] ^ v2[i + 1] << 8 ^ v2[i + 2] << 16 ^ v2[i + 3] << 24;
|
|
588
|
+
}
|
|
589
|
+
function B2S_G(a, b, c, d, x, y) {
|
|
590
|
+
v[a] = v[a] + v[b] + x;
|
|
591
|
+
v[d] = ROTR32(v[d] ^ v[a], 16);
|
|
592
|
+
v[c] = v[c] + v[d];
|
|
593
|
+
v[b] = ROTR32(v[b] ^ v[c], 12);
|
|
594
|
+
v[a] = v[a] + v[b] + y;
|
|
595
|
+
v[d] = ROTR32(v[d] ^ v[a], 8);
|
|
596
|
+
v[c] = v[c] + v[d];
|
|
597
|
+
v[b] = ROTR32(v[b] ^ v[c], 7);
|
|
598
|
+
}
|
|
599
|
+
function ROTR32(x, y) {
|
|
600
|
+
return x >>> y ^ x << 32 - y;
|
|
601
|
+
}
|
|
602
|
+
var BLAKE2S_IV = new Uint32Array([
|
|
603
|
+
1779033703,
|
|
604
|
+
3144134277,
|
|
605
|
+
1013904242,
|
|
606
|
+
2773480762,
|
|
607
|
+
1359893119,
|
|
608
|
+
2600822924,
|
|
609
|
+
528734635,
|
|
610
|
+
1541459225
|
|
611
|
+
]);
|
|
612
|
+
var SIGMA = new Uint8Array([
|
|
613
|
+
0,
|
|
614
|
+
1,
|
|
615
|
+
2,
|
|
616
|
+
3,
|
|
617
|
+
4,
|
|
618
|
+
5,
|
|
619
|
+
6,
|
|
620
|
+
7,
|
|
621
|
+
8,
|
|
622
|
+
9,
|
|
623
|
+
10,
|
|
624
|
+
11,
|
|
625
|
+
12,
|
|
626
|
+
13,
|
|
627
|
+
14,
|
|
628
|
+
15,
|
|
629
|
+
14,
|
|
630
|
+
10,
|
|
631
|
+
4,
|
|
632
|
+
8,
|
|
633
|
+
9,
|
|
634
|
+
15,
|
|
635
|
+
13,
|
|
636
|
+
6,
|
|
637
|
+
1,
|
|
638
|
+
12,
|
|
639
|
+
0,
|
|
640
|
+
2,
|
|
641
|
+
11,
|
|
642
|
+
7,
|
|
643
|
+
5,
|
|
644
|
+
3,
|
|
645
|
+
11,
|
|
646
|
+
8,
|
|
647
|
+
12,
|
|
648
|
+
0,
|
|
649
|
+
5,
|
|
650
|
+
2,
|
|
651
|
+
15,
|
|
652
|
+
13,
|
|
653
|
+
10,
|
|
654
|
+
14,
|
|
655
|
+
3,
|
|
656
|
+
6,
|
|
657
|
+
7,
|
|
658
|
+
1,
|
|
659
|
+
9,
|
|
660
|
+
4,
|
|
661
|
+
7,
|
|
662
|
+
9,
|
|
663
|
+
3,
|
|
664
|
+
1,
|
|
665
|
+
13,
|
|
666
|
+
12,
|
|
667
|
+
11,
|
|
668
|
+
14,
|
|
669
|
+
2,
|
|
670
|
+
6,
|
|
671
|
+
5,
|
|
672
|
+
10,
|
|
673
|
+
4,
|
|
674
|
+
0,
|
|
675
|
+
15,
|
|
676
|
+
8,
|
|
677
|
+
9,
|
|
678
|
+
0,
|
|
679
|
+
5,
|
|
680
|
+
7,
|
|
681
|
+
2,
|
|
682
|
+
4,
|
|
683
|
+
10,
|
|
684
|
+
15,
|
|
685
|
+
14,
|
|
686
|
+
1,
|
|
687
|
+
11,
|
|
688
|
+
12,
|
|
689
|
+
6,
|
|
690
|
+
8,
|
|
691
|
+
3,
|
|
692
|
+
13,
|
|
693
|
+
2,
|
|
694
|
+
12,
|
|
695
|
+
6,
|
|
696
|
+
10,
|
|
697
|
+
0,
|
|
698
|
+
11,
|
|
699
|
+
8,
|
|
700
|
+
3,
|
|
701
|
+
4,
|
|
702
|
+
13,
|
|
703
|
+
7,
|
|
704
|
+
5,
|
|
705
|
+
15,
|
|
706
|
+
14,
|
|
707
|
+
1,
|
|
708
|
+
9,
|
|
709
|
+
12,
|
|
710
|
+
5,
|
|
711
|
+
1,
|
|
712
|
+
15,
|
|
713
|
+
14,
|
|
714
|
+
13,
|
|
715
|
+
4,
|
|
716
|
+
10,
|
|
717
|
+
0,
|
|
718
|
+
7,
|
|
719
|
+
6,
|
|
720
|
+
3,
|
|
721
|
+
9,
|
|
722
|
+
2,
|
|
723
|
+
8,
|
|
724
|
+
11,
|
|
725
|
+
13,
|
|
726
|
+
11,
|
|
727
|
+
7,
|
|
728
|
+
14,
|
|
729
|
+
12,
|
|
730
|
+
1,
|
|
731
|
+
3,
|
|
732
|
+
9,
|
|
733
|
+
5,
|
|
734
|
+
0,
|
|
735
|
+
15,
|
|
736
|
+
4,
|
|
737
|
+
8,
|
|
738
|
+
6,
|
|
739
|
+
2,
|
|
740
|
+
10,
|
|
741
|
+
6,
|
|
742
|
+
15,
|
|
743
|
+
14,
|
|
744
|
+
9,
|
|
745
|
+
11,
|
|
746
|
+
3,
|
|
747
|
+
0,
|
|
748
|
+
8,
|
|
749
|
+
12,
|
|
750
|
+
2,
|
|
751
|
+
13,
|
|
752
|
+
7,
|
|
753
|
+
1,
|
|
754
|
+
4,
|
|
755
|
+
10,
|
|
756
|
+
5,
|
|
757
|
+
10,
|
|
758
|
+
2,
|
|
759
|
+
8,
|
|
760
|
+
4,
|
|
761
|
+
7,
|
|
762
|
+
6,
|
|
763
|
+
1,
|
|
764
|
+
5,
|
|
765
|
+
15,
|
|
766
|
+
11,
|
|
767
|
+
9,
|
|
768
|
+
14,
|
|
769
|
+
3,
|
|
770
|
+
12,
|
|
771
|
+
13,
|
|
772
|
+
0
|
|
773
|
+
]);
|
|
774
|
+
var v = new Uint32Array(16);
|
|
775
|
+
var m = new Uint32Array(16);
|
|
776
|
+
function blake2sCompress(ctx, last) {
|
|
777
|
+
let i = 0;
|
|
778
|
+
for (i = 0; i < 8; i++) {
|
|
779
|
+
v[i] = ctx.h[i];
|
|
780
|
+
v[i + 8] = BLAKE2S_IV[i];
|
|
781
|
+
}
|
|
782
|
+
v[12] ^= ctx.t;
|
|
783
|
+
v[13] ^= ctx.t / 4294967296;
|
|
784
|
+
if (last) {
|
|
785
|
+
v[14] = ~v[14];
|
|
786
|
+
}
|
|
787
|
+
for (i = 0; i < 16; i++) {
|
|
788
|
+
m[i] = B2S_GET32(ctx.b, 4 * i);
|
|
789
|
+
}
|
|
790
|
+
for (i = 0; i < 10; i++) {
|
|
791
|
+
B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]);
|
|
792
|
+
B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]);
|
|
793
|
+
B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]);
|
|
794
|
+
B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]);
|
|
795
|
+
B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]);
|
|
796
|
+
B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]);
|
|
797
|
+
B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]);
|
|
798
|
+
B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]);
|
|
799
|
+
}
|
|
800
|
+
for (i = 0; i < 8; i++) {
|
|
801
|
+
ctx.h[i] ^= v[i] ^ v[i + 8];
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
function blake2sInit(outlen, key) {
|
|
805
|
+
if (!(outlen > 0 && outlen <= 32)) {
|
|
806
|
+
throw new Error("Incorrect output length, should be in [1, 32]");
|
|
807
|
+
}
|
|
808
|
+
const keylen = key ? key.length : 0;
|
|
809
|
+
if (key && !(keylen > 0 && keylen <= 32)) {
|
|
810
|
+
throw new Error("Incorrect key length, should be in [1, 32]");
|
|
811
|
+
}
|
|
812
|
+
const ctx = {
|
|
813
|
+
h: new Uint32Array(BLAKE2S_IV),
|
|
814
|
+
// hash state
|
|
815
|
+
b: new Uint8Array(64),
|
|
816
|
+
// input block
|
|
817
|
+
c: 0,
|
|
818
|
+
// pointer within block
|
|
819
|
+
t: 0,
|
|
820
|
+
// input count
|
|
821
|
+
outlen
|
|
822
|
+
// output length in bytes
|
|
823
|
+
};
|
|
824
|
+
ctx.h[0] ^= 16842752 ^ keylen << 8 ^ outlen;
|
|
825
|
+
if (keylen > 0) {
|
|
826
|
+
blake2sUpdate(ctx, key);
|
|
827
|
+
ctx.c = 64;
|
|
828
|
+
}
|
|
829
|
+
return ctx;
|
|
830
|
+
}
|
|
831
|
+
function blake2sUpdate(ctx, input) {
|
|
832
|
+
for (let i = 0; i < input.length; i++) {
|
|
833
|
+
if (ctx.c === 64) {
|
|
834
|
+
ctx.t += ctx.c;
|
|
835
|
+
blake2sCompress(ctx, false);
|
|
836
|
+
ctx.c = 0;
|
|
837
|
+
}
|
|
838
|
+
ctx.b[ctx.c++] = input[i];
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
function blake2sFinal(ctx) {
|
|
842
|
+
ctx.t += ctx.c;
|
|
843
|
+
while (ctx.c < 64) {
|
|
844
|
+
ctx.b[ctx.c++] = 0;
|
|
845
|
+
}
|
|
846
|
+
blake2sCompress(ctx, true);
|
|
847
|
+
const out = new Uint8Array(ctx.outlen);
|
|
848
|
+
for (let i = 0; i < ctx.outlen; i++) {
|
|
849
|
+
out[i] = ctx.h[i >> 2] >> 8 * (i & 3) & 255;
|
|
850
|
+
}
|
|
851
|
+
return out;
|
|
852
|
+
}
|
|
853
|
+
function blake2s(input, key, outlen) {
|
|
854
|
+
outlen = outlen || 32;
|
|
855
|
+
input = util.normalizeInput(input);
|
|
856
|
+
const ctx = blake2sInit(outlen, key);
|
|
857
|
+
blake2sUpdate(ctx, input);
|
|
858
|
+
return blake2sFinal(ctx);
|
|
859
|
+
}
|
|
860
|
+
function blake2sHex(input, key, outlen) {
|
|
861
|
+
const output = blake2s(input, key, outlen);
|
|
862
|
+
return util.toHex(output);
|
|
863
|
+
}
|
|
864
|
+
module2.exports = {
|
|
865
|
+
blake2s,
|
|
866
|
+
blake2sHex,
|
|
867
|
+
blake2sInit,
|
|
868
|
+
blake2sUpdate,
|
|
869
|
+
blake2sFinal
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
// ../../node_modules/blakejs/index.js
|
|
875
|
+
var require_blakejs = __commonJS({
|
|
876
|
+
"../../node_modules/blakejs/index.js"(exports2, module2) {
|
|
877
|
+
"use strict";
|
|
878
|
+
var b2b = require_blake2b();
|
|
879
|
+
var b2s = require_blake2s();
|
|
880
|
+
module2.exports = {
|
|
881
|
+
blake2b: b2b.blake2b,
|
|
882
|
+
blake2bHex: b2b.blake2bHex,
|
|
883
|
+
blake2bInit: b2b.blake2bInit,
|
|
884
|
+
blake2bUpdate: b2b.blake2bUpdate,
|
|
885
|
+
blake2bFinal: b2b.blake2bFinal,
|
|
886
|
+
blake2s: b2s.blake2s,
|
|
887
|
+
blake2sHex: b2s.blake2sHex,
|
|
888
|
+
blake2sInit: b2s.blake2sInit,
|
|
889
|
+
blake2sUpdate: b2s.blake2sUpdate,
|
|
890
|
+
blake2sFinal: b2s.blake2sFinal
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
|
|
895
|
+
// src/index.ts
|
|
896
|
+
var src_exports = {};
|
|
897
|
+
__export(src_exports, {
|
|
898
|
+
Address: () => Address,
|
|
899
|
+
AddressType: () => AddressType,
|
|
900
|
+
AssetFingerprint: () => AssetFingerprint,
|
|
901
|
+
AssetId: () => AssetId,
|
|
902
|
+
AssetName: () => AssetName,
|
|
903
|
+
BaseAddress: () => BaseAddress,
|
|
904
|
+
Bip32PrivateKey: () => Bip32PrivateKey2,
|
|
905
|
+
Bip32PrivateKeyHex: () => Bip32PrivateKeyHex2,
|
|
906
|
+
Cardano: () => import_core7.Cardano,
|
|
907
|
+
CardanoSDK: () => CardanoSDK,
|
|
908
|
+
CardanoSDKSerializer: () => CardanoSDKSerializer,
|
|
909
|
+
CardanoSDKUtil: () => CardanoSDKUtil,
|
|
910
|
+
CborSet: () => CborSet,
|
|
911
|
+
CborWriter: () => CborWriter,
|
|
912
|
+
Certificate: () => Certificate,
|
|
913
|
+
CertificateType: () => CertificateType,
|
|
914
|
+
ConstrPlutusData: () => ConstrPlutusData,
|
|
915
|
+
CoseSign1: () => CoseSign1,
|
|
916
|
+
CostModel: () => CostModel,
|
|
917
|
+
Costmdls: () => Costmdls,
|
|
918
|
+
Credential: () => Credential,
|
|
919
|
+
CredentialType: () => CredentialType,
|
|
920
|
+
Crypto: () => Crypto3,
|
|
921
|
+
DRepID: () => DRepID,
|
|
922
|
+
Datum: () => Datum,
|
|
923
|
+
DatumHash: () => DatumHash,
|
|
924
|
+
DatumKind: () => DatumKind,
|
|
925
|
+
Ed25519KeyHash: () => Ed25519KeyHash2,
|
|
926
|
+
Ed25519KeyHashHex: () => Ed25519KeyHashHex2,
|
|
927
|
+
Ed25519PrivateExtendedKeyHex: () => Ed25519PrivateExtendedKeyHex,
|
|
928
|
+
Ed25519PrivateNormalKeyHex: () => Ed25519PrivateNormalKeyHex,
|
|
929
|
+
Ed25519PublicKey: () => Ed25519PublicKey2,
|
|
930
|
+
Ed25519PublicKeyHex: () => Ed25519PublicKeyHex2,
|
|
931
|
+
Ed25519Signature: () => Ed25519Signature2,
|
|
932
|
+
Ed25519SignatureHex: () => Ed25519SignatureHex2,
|
|
933
|
+
EnterpriseAddress: () => EnterpriseAddress,
|
|
934
|
+
ExUnits: () => ExUnits,
|
|
935
|
+
Hash: () => Hash,
|
|
936
|
+
Hash28ByteBase16: () => Hash28ByteBase162,
|
|
937
|
+
Hash32ByteBase16: () => Hash32ByteBase162,
|
|
938
|
+
NativeScript: () => NativeScript,
|
|
939
|
+
NetworkId: () => NetworkId,
|
|
940
|
+
PaymentAddress: () => PaymentAddress,
|
|
941
|
+
PlutusData: () => PlutusData,
|
|
942
|
+
PlutusLanguageVersion: () => PlutusLanguageVersion,
|
|
943
|
+
PlutusList: () => PlutusList,
|
|
944
|
+
PlutusMap: () => PlutusMap,
|
|
945
|
+
PlutusV1Script: () => PlutusV1Script,
|
|
946
|
+
PlutusV2Script: () => PlutusV2Script,
|
|
947
|
+
PlutusV3Script: () => PlutusV3Script,
|
|
948
|
+
PolicyId: () => PolicyId,
|
|
949
|
+
PoolId: () => PoolId,
|
|
950
|
+
Redeemer: () => Redeemer,
|
|
951
|
+
RedeemerPurpose: () => RedeemerPurpose,
|
|
952
|
+
RedeemerTag: () => RedeemerTag,
|
|
953
|
+
Redeemers: () => Redeemers,
|
|
954
|
+
RequireAllOf: () => RequireAllOf,
|
|
955
|
+
RequireAnyOf: () => RequireAnyOf,
|
|
956
|
+
RequireNOf: () => RequireNOf,
|
|
957
|
+
RequireSignature: () => RequireSignature,
|
|
958
|
+
RequireTimeAfter: () => RequireTimeAfter,
|
|
959
|
+
RequireTimeBefore: () => RequireTimeBefore,
|
|
960
|
+
RewardAccount: () => RewardAccount,
|
|
961
|
+
RewardAddress: () => RewardAddress,
|
|
962
|
+
Script: () => Script,
|
|
963
|
+
ScriptHash: () => ScriptHash,
|
|
964
|
+
ScriptPubkey: () => ScriptPubkey,
|
|
965
|
+
Serialization: () => import_core7.Serialization,
|
|
966
|
+
Slot: () => Slot,
|
|
967
|
+
StakeDelegation: () => StakeDelegation,
|
|
968
|
+
StakeRegistration: () => StakeRegistration,
|
|
969
|
+
StricaBip32PrivateKey: () => Bip32PrivateKey3,
|
|
970
|
+
StricaBip32PublicKey: () => Bip32PublicKey,
|
|
971
|
+
StricaDecoder: () => Decoder,
|
|
972
|
+
StricaEncoder: () => Encoder,
|
|
973
|
+
StricaPrivateKey: () => PrivateKey,
|
|
974
|
+
StricaPublicKey: () => PublicKey,
|
|
975
|
+
Transaction: () => Transaction,
|
|
976
|
+
TransactionBody: () => TransactionBody,
|
|
977
|
+
TransactionId: () => TransactionId,
|
|
978
|
+
TransactionInput: () => TransactionInput,
|
|
979
|
+
TransactionOutput: () => TransactionOutput,
|
|
980
|
+
TransactionUnspentOutput: () => TransactionUnspentOutput,
|
|
981
|
+
TransactionWitnessSet: () => TransactionWitnessSet,
|
|
982
|
+
Value: () => Value,
|
|
983
|
+
VkeyWitness: () => VkeyWitness,
|
|
984
|
+
VrfVkBech32: () => VrfVkBech32,
|
|
985
|
+
addressToBech32: () => addressToBech32,
|
|
986
|
+
assetTypes: () => assetTypes,
|
|
987
|
+
buildBaseAddress: () => buildBaseAddress,
|
|
988
|
+
buildBip32PrivateKey: () => buildBip32PrivateKey,
|
|
989
|
+
buildDRepID: () => buildDRepID,
|
|
990
|
+
buildEnterpriseAddress: () => buildEnterpriseAddress,
|
|
991
|
+
buildKeys: () => buildKeys,
|
|
992
|
+
buildRewardAddress: () => buildRewardAddress,
|
|
993
|
+
buildScriptPubkey: () => buildScriptPubkey,
|
|
994
|
+
checkSignature: () => checkSignature,
|
|
995
|
+
deserializeAddress: () => deserializeAddress,
|
|
996
|
+
deserializeDataHash: () => deserializeDataHash,
|
|
997
|
+
deserializeEd25519KeyHash: () => deserializeEd25519KeyHash,
|
|
998
|
+
deserializeNativeScript: () => deserializeNativeScript,
|
|
999
|
+
deserializePlutusData: () => deserializePlutusData,
|
|
1000
|
+
deserializePlutusScript: () => deserializePlutusScript,
|
|
1001
|
+
deserializeScriptHash: () => deserializeScriptHash,
|
|
1002
|
+
deserializeScriptRef: () => deserializeScriptRef,
|
|
1003
|
+
deserializeTx: () => deserializeTx,
|
|
1004
|
+
deserializeTxHash: () => deserializeTxHash,
|
|
1005
|
+
deserializeTxUnspentOutput: () => deserializeTxUnspentOutput,
|
|
1006
|
+
deserializeValue: () => deserializeValue,
|
|
1007
|
+
empty: () => empty,
|
|
1008
|
+
fromNativeScript: () => fromNativeScript,
|
|
1009
|
+
fromScriptRef: () => fromScriptRef,
|
|
1010
|
+
fromTxUnspentOutput: () => fromTxUnspentOutput,
|
|
1011
|
+
fromValue: () => fromValue,
|
|
1012
|
+
generateNonce: () => generateNonce,
|
|
1013
|
+
getCoseKeyFromPublicKey: () => getCoseKeyFromPublicKey,
|
|
1014
|
+
getPublicKeyFromCoseKey: () => getPublicKeyFromCoseKey,
|
|
1015
|
+
mergeValue: () => mergeValue,
|
|
1016
|
+
negateValue: () => negateValue,
|
|
1017
|
+
negatives: () => negatives,
|
|
1018
|
+
resolveDataHash: () => resolveDataHash,
|
|
1019
|
+
resolveNativeScriptAddress: () => resolveNativeScriptAddress,
|
|
1020
|
+
resolveNativeScriptHash: () => resolveNativeScriptHash,
|
|
1021
|
+
resolvePaymentKeyHash: () => resolvePaymentKeyHash,
|
|
1022
|
+
resolvePlutusScriptAddress: () => resolvePlutusScriptAddress,
|
|
1023
|
+
resolvePlutusScriptHash: () => resolvePlutusScriptHash,
|
|
1024
|
+
resolvePoolId: () => resolvePoolId,
|
|
1025
|
+
resolvePrivateKey: () => resolvePrivateKey,
|
|
1026
|
+
resolveRewardAddress: () => resolveRewardAddress,
|
|
1027
|
+
resolveScriptRef: () => resolveScriptRef,
|
|
1028
|
+
resolveStakeKeyHash: () => resolveStakeKeyHash,
|
|
1029
|
+
resolveTxHash: () => resolveTxHash,
|
|
1030
|
+
signData: () => signData,
|
|
1031
|
+
subValue: () => subValue,
|
|
1032
|
+
toAddress: () => toAddress,
|
|
1033
|
+
toBaseAddress: () => toBaseAddress,
|
|
1034
|
+
toEnterpriseAddress: () => toEnterpriseAddress,
|
|
1035
|
+
toNativeScript: () => toNativeScript,
|
|
1036
|
+
toPlutusData: () => toPlutusData,
|
|
1037
|
+
toRewardAddress: () => toRewardAddress,
|
|
1038
|
+
toScriptRef: () => toScriptRef,
|
|
1039
|
+
toTxUnspentOutput: () => toTxUnspentOutput,
|
|
1040
|
+
toValue: () => toValue
|
|
1041
|
+
});
|
|
1042
|
+
module.exports = __toCommonJS(src_exports);
|
|
1043
|
+
var import_core7 = require("@cardano-sdk/core");
|
|
1044
|
+
|
|
1045
|
+
// src/types/cardano-sdk.ts
|
|
1046
|
+
var import_core = require("@cardano-sdk/core");
|
|
1047
|
+
var Crypto = __toESM(require("@cardano-sdk/crypto"), 1);
|
|
1048
|
+
var import_util = require("@cardano-sdk/util");
|
|
1049
|
+
var Slot = import_core.Cardano.Slot;
|
|
1050
|
+
var Value = import_core.Serialization.Value;
|
|
1051
|
+
var Transaction = import_core.Serialization.Transaction;
|
|
1052
|
+
var TransactionId = import_core.Cardano.TransactionId;
|
|
1053
|
+
var TransactionBody = import_core.Serialization.TransactionBody;
|
|
1054
|
+
var TransactionWitnessSet = import_core.Serialization.TransactionWitnessSet;
|
|
1055
|
+
var TransactionUnspentOutput = import_core.Serialization.TransactionUnspentOutput;
|
|
1056
|
+
var TransactionInput = import_core.Serialization.TransactionInput;
|
|
1057
|
+
var TransactionOutput = import_core.Serialization.TransactionOutput;
|
|
1058
|
+
var PlutusData = import_core.Serialization.PlutusData;
|
|
1059
|
+
var PlutusList = import_core.Serialization.PlutusList;
|
|
1060
|
+
var PlutusMap = import_core.Serialization.PlutusMap;
|
|
1061
|
+
var Redeemers = import_core.Serialization.Redeemers;
|
|
1062
|
+
var Redeemer = import_core.Serialization.Redeemer;
|
|
1063
|
+
var RedeemerPurpose = import_core.Cardano.RedeemerPurpose;
|
|
1064
|
+
var RedeemerTag = import_core.Serialization.RedeemerTag;
|
|
1065
|
+
var Script = import_core.Serialization.Script;
|
|
1066
|
+
var PolicyId = import_core.Cardano.PolicyId;
|
|
1067
|
+
var AssetName = import_core.Cardano.AssetName;
|
|
1068
|
+
var AssetId = import_core.Cardano.AssetId;
|
|
1069
|
+
var ScriptHash = Crypto.Hash28ByteBase16;
|
|
1070
|
+
var Address = import_core.Cardano.Address;
|
|
1071
|
+
var RewardAddress = import_core.Cardano.RewardAddress;
|
|
1072
|
+
var AddressType = import_core.Cardano.AddressType;
|
|
1073
|
+
var BaseAddress = import_core.Cardano.BaseAddress;
|
|
1074
|
+
var EnterpriseAddress = import_core.Cardano.EnterpriseAddress;
|
|
1075
|
+
var PaymentAddress = import_core.Cardano.PaymentAddress;
|
|
1076
|
+
var AssetFingerprint = import_core.Cardano.AssetFingerprint;
|
|
1077
|
+
var Credential = import_core.Serialization.Credential;
|
|
1078
|
+
var Ed25519PublicKeyHex2 = Crypto.Ed25519PublicKeyHex;
|
|
1079
|
+
var Ed25519PrivateNormalKeyHex = (value) => (0, import_util.typedHex)(value, 64);
|
|
1080
|
+
var Ed25519PrivateExtendedKeyHex = (value) => (0, import_util.typedHex)(value, 128);
|
|
1081
|
+
var Ed25519KeyHash2 = Crypto.Ed25519KeyHash;
|
|
1082
|
+
var Ed25519KeyHashHex2 = Crypto.Ed25519KeyHashHex;
|
|
1083
|
+
var Hash28ByteBase162 = Crypto.Hash28ByteBase16;
|
|
1084
|
+
var Hash32ByteBase162 = Crypto.Hash32ByteBase16;
|
|
1085
|
+
var CredentialType = import_core.Cardano.CredentialType;
|
|
1086
|
+
var Certificate = import_core.Serialization.Certificate;
|
|
1087
|
+
var PoolId = import_core.Cardano.PoolId;
|
|
1088
|
+
var StakeRegistration = import_core.Serialization.StakeRegistration;
|
|
1089
|
+
var StakeDelegation = import_core.Serialization.StakeDelegation;
|
|
1090
|
+
var CertificateType = import_core.Cardano.CertificateType;
|
|
1091
|
+
var VkeyWitness = import_core.Serialization.VkeyWitness;
|
|
1092
|
+
var Ed25519SignatureHex2 = Crypto.Ed25519SignatureHex;
|
|
1093
|
+
var Ed25519PublicKey2 = Crypto.Ed25519PublicKey;
|
|
1094
|
+
var Ed25519Signature2 = Crypto.Ed25519Signature;
|
|
1095
|
+
var Bip32PrivateKey2 = Crypto.Bip32PrivateKey;
|
|
1096
|
+
var Bip32PrivateKeyHex2 = Crypto.Bip32PrivateKeyHex;
|
|
1097
|
+
var PlutusLanguageVersion = import_core.Cardano.PlutusLanguageVersion;
|
|
1098
|
+
var NativeScript = import_core.Serialization.NativeScript;
|
|
1099
|
+
var PlutusV1Script = import_core.Serialization.PlutusV1Script;
|
|
1100
|
+
var PlutusV2Script = import_core.Serialization.PlutusV2Script;
|
|
1101
|
+
var PlutusV3Script = import_core.Serialization.PlutusV3Script;
|
|
1102
|
+
var Costmdls = import_core.Serialization.Costmdls;
|
|
1103
|
+
var CostModel = import_core.Serialization.CostModel;
|
|
1104
|
+
var CborWriter = import_core.Serialization.CborWriter;
|
|
1105
|
+
var ConstrPlutusData = import_core.Serialization.ConstrPlutusData;
|
|
1106
|
+
var RewardAccount = import_core.Cardano.RewardAccount;
|
|
1107
|
+
var Hash = import_core.Serialization.Hash;
|
|
1108
|
+
var DatumHash = Crypto.Hash32ByteBase16;
|
|
1109
|
+
var Datum = import_core.Serialization.Datum;
|
|
1110
|
+
var ExUnits = import_core.Serialization.ExUnits;
|
|
1111
|
+
var NetworkId = import_core.Cardano.NetworkId;
|
|
1112
|
+
var DatumKind = import_core.Serialization.DatumKind;
|
|
1113
|
+
var CborSet = import_core.Serialization.CborSet;
|
|
1114
|
+
var RequireAllOf = import_core.Cardano.NativeScriptKind.RequireAllOf;
|
|
1115
|
+
var RequireAnyOf = import_core.Cardano.NativeScriptKind.RequireAnyOf;
|
|
1116
|
+
var RequireNOf = import_core.Cardano.NativeScriptKind.RequireNOf;
|
|
1117
|
+
var RequireSignature = import_core.Cardano.NativeScriptKind.RequireSignature;
|
|
1118
|
+
var RequireTimeAfter = import_core.Cardano.NativeScriptKind.RequireTimeAfter;
|
|
1119
|
+
var RequireTimeBefore = import_core.Cardano.NativeScriptKind.RequireTimeBefore;
|
|
1120
|
+
var VrfVkBech32 = import_core.Cardano.VrfVkBech32;
|
|
1121
|
+
var ScriptPubkey = import_core.Serialization.ScriptPubkey;
|
|
1122
|
+
var DRepID = import_core.Cardano.DRepID;
|
|
1123
|
+
|
|
1124
|
+
// src/message-signing/cose-sign1.ts
|
|
1125
|
+
var import_buffer = require("buffer");
|
|
1126
|
+
var import_blakejs = __toESM(require_blakejs(), 1);
|
|
1127
|
+
|
|
1128
|
+
// src/stricahq/bip32ed25519/index.ts
|
|
1129
|
+
var import_bip32ed255192 = __toESM(require("@stricahq/bip32ed25519"), 1);
|
|
1130
|
+
|
|
1131
|
+
// src/stricahq/bip32ed25519/privateKey.ts
|
|
1132
|
+
var import_bip32ed25519 = __toESM(require("@stricahq/bip32ed25519"), 1);
|
|
1133
|
+
var import_hash = __toESM(require("hash.js"), 1);
|
|
1134
|
+
var PrivateKey = class extends import_bip32ed25519.default.PrivateKey {
|
|
1135
|
+
constructor(privKey, extended = true) {
|
|
1136
|
+
if (!extended) {
|
|
1137
|
+
let extendedSecret = import_hash.default.sha512().update(privKey).digest();
|
|
1138
|
+
if (extendedSecret[0] && extendedSecret[31]) {
|
|
1139
|
+
extendedSecret[0] &= 248;
|
|
1140
|
+
extendedSecret[31] &= 63;
|
|
1141
|
+
extendedSecret[31] |= 64;
|
|
1142
|
+
}
|
|
1143
|
+
privKey = Buffer.from(extendedSecret);
|
|
1144
|
+
}
|
|
1145
|
+
super(privKey);
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
// src/stricahq/bip32ed25519/index.ts
|
|
1150
|
+
var { PublicKey, Bip32PrivateKey: Bip32PrivateKey3, Bip32PublicKey } = import_bip32ed255192.default;
|
|
1151
|
+
|
|
1152
|
+
// src/stricahq/cbors/index.ts
|
|
1153
|
+
var import_cbors = __toESM(require("@stricahq/cbors"), 1);
|
|
1154
|
+
var { Encoder, Decoder } = import_cbors.default;
|
|
1155
|
+
|
|
1156
|
+
// src/message-signing/cose-sign1.ts
|
|
1157
|
+
var CoseSign1 = class _CoseSign1 {
|
|
1158
|
+
protectedMap;
|
|
1159
|
+
unProtectedMap;
|
|
1160
|
+
payload;
|
|
1161
|
+
signature;
|
|
1162
|
+
constructor(payload) {
|
|
1163
|
+
this.protectedMap = payload.protectedMap;
|
|
1164
|
+
this.unProtectedMap = payload.unProtectedMap;
|
|
1165
|
+
this.payload = payload.payload;
|
|
1166
|
+
if (this.unProtectedMap.get("hashed") == null) {
|
|
1167
|
+
this.unProtectedMap.set("hashed", false);
|
|
1168
|
+
}
|
|
1169
|
+
this.signature = payload.signature;
|
|
1170
|
+
}
|
|
1171
|
+
static fromCbor(cbor) {
|
|
1172
|
+
const decoded = Decoder.decode(import_buffer.Buffer.from(cbor, "hex"));
|
|
1173
|
+
if (!(decoded.value instanceof Array)) throw Error("Invalid CBOR");
|
|
1174
|
+
if (decoded.value.length !== 4) throw Error("Invalid COSE_SIGN1");
|
|
1175
|
+
let protectedMap;
|
|
1176
|
+
const protectedSerialized = decoded.value[0];
|
|
1177
|
+
try {
|
|
1178
|
+
protectedMap = Decoder.decode(protectedSerialized).value;
|
|
1179
|
+
if (!(protectedMap instanceof Map)) {
|
|
1180
|
+
throw Error();
|
|
1181
|
+
}
|
|
1182
|
+
} catch (error) {
|
|
1183
|
+
throw Error("Invalid protected");
|
|
1184
|
+
}
|
|
1185
|
+
const unProtectedMap = decoded.value[1];
|
|
1186
|
+
if (!(unProtectedMap instanceof Map)) throw Error("Invalid unprotected");
|
|
1187
|
+
const payload = decoded.value[2];
|
|
1188
|
+
const signature = decoded.value[3];
|
|
1189
|
+
return new _CoseSign1({
|
|
1190
|
+
protectedMap,
|
|
1191
|
+
unProtectedMap,
|
|
1192
|
+
payload,
|
|
1193
|
+
signature
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
createSigStructure(externalAad = import_buffer.Buffer.alloc(0)) {
|
|
1197
|
+
let protectedSerialized = import_buffer.Buffer.alloc(0);
|
|
1198
|
+
if (this.protectedMap.size !== 0) {
|
|
1199
|
+
protectedSerialized = Encoder.encode(this.protectedMap);
|
|
1200
|
+
}
|
|
1201
|
+
const structure = [
|
|
1202
|
+
"Signature1",
|
|
1203
|
+
protectedSerialized,
|
|
1204
|
+
externalAad,
|
|
1205
|
+
this.payload
|
|
1206
|
+
];
|
|
1207
|
+
return Encoder.encode(structure);
|
|
1208
|
+
}
|
|
1209
|
+
buildMessage(signature) {
|
|
1210
|
+
this.signature = signature;
|
|
1211
|
+
let protectedSerialized = import_buffer.Buffer.alloc(0);
|
|
1212
|
+
if (this.protectedMap.size !== 0) {
|
|
1213
|
+
protectedSerialized = Encoder.encode(this.protectedMap);
|
|
1214
|
+
}
|
|
1215
|
+
const coseSign1 = [
|
|
1216
|
+
protectedSerialized,
|
|
1217
|
+
this.unProtectedMap,
|
|
1218
|
+
this.payload,
|
|
1219
|
+
this.signature
|
|
1220
|
+
];
|
|
1221
|
+
return Encoder.encode(coseSign1);
|
|
1222
|
+
}
|
|
1223
|
+
verifySignature({
|
|
1224
|
+
externalAad = import_buffer.Buffer.alloc(0),
|
|
1225
|
+
publicKeyBuffer
|
|
1226
|
+
} = {}) {
|
|
1227
|
+
if (!publicKeyBuffer) {
|
|
1228
|
+
publicKeyBuffer = this.getPublicKey();
|
|
1229
|
+
}
|
|
1230
|
+
if (!publicKeyBuffer) throw Error("Public key not found");
|
|
1231
|
+
if (!this.signature) throw Error("Signature not found");
|
|
1232
|
+
const publicKey = new PublicKey(publicKeyBuffer);
|
|
1233
|
+
return publicKey.verify(
|
|
1234
|
+
this.signature,
|
|
1235
|
+
this.createSigStructure(externalAad)
|
|
1236
|
+
);
|
|
1237
|
+
}
|
|
1238
|
+
hashPayload() {
|
|
1239
|
+
if (!this.unProtectedMap) throw Error("Invalid unprotected map");
|
|
1240
|
+
if (!this.payload) throw Error("Invalid payload");
|
|
1241
|
+
if (this.unProtectedMap.get("hashed"))
|
|
1242
|
+
throw Error("Payload already hashed");
|
|
1243
|
+
if (this.unProtectedMap.get("hashed") != false)
|
|
1244
|
+
throw Error("Invalid unprotected map");
|
|
1245
|
+
this.unProtectedMap.set("hashed", true);
|
|
1246
|
+
const hash2 = (0, import_blakejs.blake2b)(this.payload, void 0, 24);
|
|
1247
|
+
this.payload = import_buffer.Buffer.from(hash2);
|
|
1248
|
+
}
|
|
1249
|
+
getAddress() {
|
|
1250
|
+
return this.protectedMap.get("address");
|
|
1251
|
+
}
|
|
1252
|
+
getPublicKey() {
|
|
1253
|
+
return this.protectedMap.get(4);
|
|
1254
|
+
}
|
|
1255
|
+
getSignature() {
|
|
1256
|
+
return this.signature;
|
|
1257
|
+
}
|
|
1258
|
+
getPayload() {
|
|
1259
|
+
return this.payload;
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
var getPublicKeyFromCoseKey = (cbor) => {
|
|
1263
|
+
const decodedCoseKey = Decoder.decode(import_buffer.Buffer.from(cbor, "hex"));
|
|
1264
|
+
const publicKeyBuffer = decodedCoseKey.value.get(-2);
|
|
1265
|
+
if (publicKeyBuffer) {
|
|
1266
|
+
return publicKeyBuffer;
|
|
1267
|
+
}
|
|
1268
|
+
throw Error("Public key not found");
|
|
1269
|
+
};
|
|
1270
|
+
var getCoseKeyFromPublicKey = (cbor) => {
|
|
1271
|
+
const coseKeyMap = /* @__PURE__ */ new Map();
|
|
1272
|
+
coseKeyMap.set(1, 1);
|
|
1273
|
+
coseKeyMap.set(3, -8);
|
|
1274
|
+
coseKeyMap.set(6, -2);
|
|
1275
|
+
coseKeyMap.set(-2, import_buffer.Buffer.from(cbor, "hex"));
|
|
1276
|
+
return Encoder.encode(coseKeyMap);
|
|
1277
|
+
};
|
|
1278
|
+
|
|
1279
|
+
// src/message-signing/check-signature.ts
|
|
1280
|
+
var checkSignature = (data, { key, signature }) => {
|
|
1281
|
+
const builder = CoseSign1.fromCbor(signature);
|
|
1282
|
+
if (builder.getPayload() === null) {
|
|
1283
|
+
return false;
|
|
1284
|
+
}
|
|
1285
|
+
if (Buffer.from(data, "hex").compare(builder.getPayload()) !== 0) {
|
|
1286
|
+
return false;
|
|
1287
|
+
}
|
|
1288
|
+
return builder.verifySignature({
|
|
1289
|
+
publicKeyBuffer: getPublicKeyFromCoseKey(key)
|
|
1290
|
+
});
|
|
1291
|
+
};
|
|
1292
|
+
|
|
1293
|
+
// ../../node_modules/nanoid/index.js
|
|
1294
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
1295
|
+
var POOL_SIZE_MULTIPLIER = 128;
|
|
1296
|
+
var pool;
|
|
1297
|
+
var poolOffset;
|
|
1298
|
+
var fillPool = (bytes) => {
|
|
1299
|
+
if (!pool || pool.length < bytes) {
|
|
1300
|
+
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
|
1301
|
+
import_crypto.default.randomFillSync(pool);
|
|
1302
|
+
poolOffset = 0;
|
|
1303
|
+
} else if (poolOffset + bytes > pool.length) {
|
|
1304
|
+
import_crypto.default.randomFillSync(pool);
|
|
1305
|
+
poolOffset = 0;
|
|
1306
|
+
}
|
|
1307
|
+
poolOffset += bytes;
|
|
1308
|
+
};
|
|
1309
|
+
var random = (bytes) => {
|
|
1310
|
+
fillPool(bytes -= 0);
|
|
1311
|
+
return pool.subarray(poolOffset - bytes, poolOffset);
|
|
1312
|
+
};
|
|
1313
|
+
var customRandom = (alphabet, defaultSize, getRandom) => {
|
|
1314
|
+
let mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
|
|
1315
|
+
let step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
|
|
1316
|
+
return (size = defaultSize) => {
|
|
1317
|
+
let id = "";
|
|
1318
|
+
while (true) {
|
|
1319
|
+
let bytes = getRandom(step);
|
|
1320
|
+
let i = step;
|
|
1321
|
+
while (i--) {
|
|
1322
|
+
id += alphabet[bytes[i] & mask] || "";
|
|
1323
|
+
if (id.length === size) return id;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
};
|
|
1328
|
+
var customAlphabet = (alphabet, size = 21) => customRandom(alphabet, size, random);
|
|
1329
|
+
|
|
1330
|
+
// src/message-signing/generate-nonce.ts
|
|
1331
|
+
var import_common = require("@meshsdk/common");
|
|
1332
|
+
var generateNonce = (label = "", length = 32) => {
|
|
1333
|
+
if (length <= 0 || length > 2048) {
|
|
1334
|
+
throw new Error("Length must be bewteen 1 and 2048");
|
|
1335
|
+
}
|
|
1336
|
+
const randomString = customAlphabet(
|
|
1337
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
1338
|
+
);
|
|
1339
|
+
const payload = randomString(length);
|
|
1340
|
+
return (0, import_common.stringToHex)(`${label}${payload}`);
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
// src/message-signing/sign-data.ts
|
|
1344
|
+
var signData = (data, signer) => {
|
|
1345
|
+
const payload = Buffer.from(data, "hex");
|
|
1346
|
+
const publicKey = signer.key.toPublicKey().toBytes();
|
|
1347
|
+
const protectedMap = /* @__PURE__ */ new Map();
|
|
1348
|
+
protectedMap.set(1, -8);
|
|
1349
|
+
protectedMap.set(4, publicKey);
|
|
1350
|
+
protectedMap.set("address", Buffer.from(signer.address.toBytes(), "hex"));
|
|
1351
|
+
const coseSign1Builder = new CoseSign1({
|
|
1352
|
+
protectedMap,
|
|
1353
|
+
unProtectedMap: /* @__PURE__ */ new Map(),
|
|
1354
|
+
payload
|
|
1355
|
+
});
|
|
1356
|
+
const signature = signer.key.sign(coseSign1Builder.createSigStructure());
|
|
1357
|
+
const coseSignature = coseSign1Builder.buildMessage(signature).toString("hex");
|
|
1358
|
+
return {
|
|
1359
|
+
key: getCoseKeyFromPublicKey(publicKey.toString("hex")).toString("hex"),
|
|
1360
|
+
signature: coseSignature
|
|
1361
|
+
};
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
// src/resolvers/index.ts
|
|
1365
|
+
var import_core4 = require("@cardano-sdk/core");
|
|
1366
|
+
var import_crypto5 = require("@cardano-sdk/crypto");
|
|
1367
|
+
var import_util5 = require("@cardano-sdk/util");
|
|
1368
|
+
|
|
1369
|
+
// src/utils/builder.ts
|
|
1370
|
+
var import_crypto2 = require("@cardano-sdk/crypto");
|
|
1371
|
+
var import_util2 = require("@cardano-sdk/util");
|
|
1372
|
+
var import_pbkdf2 = require("pbkdf2");
|
|
1373
|
+
var import_common2 = require("@meshsdk/common");
|
|
1374
|
+
var buildBaseAddress = (networkId, paymentKeyHash, stakeKeyHash) => {
|
|
1375
|
+
return BaseAddress.fromCredentials(
|
|
1376
|
+
networkId,
|
|
1377
|
+
{
|
|
1378
|
+
hash: paymentKeyHash,
|
|
1379
|
+
type: CredentialType.KeyHash
|
|
1380
|
+
},
|
|
1381
|
+
{
|
|
1382
|
+
hash: stakeKeyHash,
|
|
1383
|
+
type: CredentialType.KeyHash
|
|
1384
|
+
}
|
|
1385
|
+
);
|
|
1386
|
+
};
|
|
1387
|
+
var buildEnterpriseAddress = (networkId, paymentKeyHash) => {
|
|
1388
|
+
return EnterpriseAddress.fromCredentials(networkId, {
|
|
1389
|
+
hash: paymentKeyHash,
|
|
1390
|
+
type: CredentialType.KeyHash
|
|
1391
|
+
});
|
|
1392
|
+
};
|
|
1393
|
+
var buildBip32PrivateKey = (entropy, password = "") => {
|
|
1394
|
+
const PBKDF2_ITERATIONS = 4096;
|
|
1395
|
+
const PBKDF2_KEY_SIZE = 96;
|
|
1396
|
+
const PBKDF2_DIGEST_ALGORITHM = "sha512";
|
|
1397
|
+
const clampScalar = (scalar) => {
|
|
1398
|
+
if (scalar[0] !== void 0) {
|
|
1399
|
+
scalar[0] &= 248;
|
|
1400
|
+
}
|
|
1401
|
+
if (scalar[31] !== void 0) {
|
|
1402
|
+
scalar[31] &= 31;
|
|
1403
|
+
scalar[31] |= 64;
|
|
1404
|
+
}
|
|
1405
|
+
return scalar;
|
|
1406
|
+
};
|
|
1407
|
+
const _entropy = Buffer.from(entropy, "hex");
|
|
1408
|
+
const xprv = (0, import_pbkdf2.pbkdf2Sync)(
|
|
1409
|
+
password,
|
|
1410
|
+
_entropy,
|
|
1411
|
+
PBKDF2_ITERATIONS,
|
|
1412
|
+
PBKDF2_KEY_SIZE,
|
|
1413
|
+
PBKDF2_DIGEST_ALGORITHM
|
|
1414
|
+
);
|
|
1415
|
+
return Bip32PrivateKey2.fromBytes(clampScalar(xprv));
|
|
1416
|
+
};
|
|
1417
|
+
var buildRewardAddress = (networkId, stakeKeyHash) => {
|
|
1418
|
+
const cred = {
|
|
1419
|
+
type: CredentialType.KeyHash,
|
|
1420
|
+
hash: stakeKeyHash
|
|
1421
|
+
};
|
|
1422
|
+
return RewardAddress.fromCredentials(networkId, cred);
|
|
1423
|
+
};
|
|
1424
|
+
var buildKeys = (entropy, accountIndex, keyIndex = 0) => {
|
|
1425
|
+
if (typeof entropy === "string") {
|
|
1426
|
+
const rootKey = new Bip32PrivateKey3(Buffer.from(entropy, "hex"));
|
|
1427
|
+
const accountKey = rootKey.derive(import_common2.HARDENED_KEY_START + 1852).derive(import_common2.HARDENED_KEY_START + 1815).derive(import_common2.HARDENED_KEY_START + accountIndex);
|
|
1428
|
+
const paymentKey = accountKey.derive(0).derive(keyIndex).toPrivateKey();
|
|
1429
|
+
const stakeKey = accountKey.derive(2).derive(0).toPrivateKey();
|
|
1430
|
+
return { paymentKey, stakeKey };
|
|
1431
|
+
} else {
|
|
1432
|
+
const paymentKey = new PrivateKey(
|
|
1433
|
+
Buffer.from(entropy[0], "hex"),
|
|
1434
|
+
false
|
|
1435
|
+
);
|
|
1436
|
+
const stakeKey = new PrivateKey(
|
|
1437
|
+
Buffer.from(entropy[1], "hex"),
|
|
1438
|
+
false
|
|
1439
|
+
);
|
|
1440
|
+
return { paymentKey, stakeKey };
|
|
1441
|
+
}
|
|
1442
|
+
};
|
|
1443
|
+
var buildScriptPubkey = (keyHash) => {
|
|
1444
|
+
const scriptPubkey = new ScriptPubkey(Ed25519KeyHashHex2(keyHash.hex()));
|
|
1445
|
+
return NativeScript.newScriptPubkey(scriptPubkey);
|
|
1446
|
+
};
|
|
1447
|
+
var buildDRepID = (dRepKey, networkId = NetworkId.Testnet, addressType = AddressType.EnterpriseKey) => {
|
|
1448
|
+
const dRepKeyBytes = Buffer.from(dRepKey, "hex");
|
|
1449
|
+
const dRepIdHex = (0, import_crypto2.blake2b)(28).update(dRepKeyBytes).digest("hex");
|
|
1450
|
+
const paymentAddress = EnterpriseAddress.packParts({
|
|
1451
|
+
networkId,
|
|
1452
|
+
paymentPart: {
|
|
1453
|
+
hash: Hash28ByteBase162(dRepIdHex),
|
|
1454
|
+
type: CredentialType.KeyHash
|
|
1455
|
+
},
|
|
1456
|
+
type: addressType
|
|
1457
|
+
});
|
|
1458
|
+
return import_util2.HexBlob.toTypedBech32(
|
|
1459
|
+
"drep",
|
|
1460
|
+
import_util2.HexBlob.fromBytes(paymentAddress)
|
|
1461
|
+
);
|
|
1462
|
+
};
|
|
1463
|
+
|
|
1464
|
+
// src/utils/converter.ts
|
|
1465
|
+
var import_core3 = require("@cardano-sdk/core");
|
|
1466
|
+
var import_crypto4 = require("@cardano-sdk/crypto");
|
|
1467
|
+
var import_util4 = require("@cardano-sdk/util");
|
|
1468
|
+
var import_common4 = require("@meshsdk/common");
|
|
1469
|
+
|
|
1470
|
+
// src/utils/deserializer.ts
|
|
1471
|
+
var import_core2 = require("@cardano-sdk/core");
|
|
1472
|
+
var import_crypto3 = require("@cardano-sdk/crypto");
|
|
1473
|
+
var import_util3 = require("@cardano-sdk/util");
|
|
1474
|
+
var import_common3 = require("@meshsdk/common");
|
|
1475
|
+
var deserializeAddress = (address) => {
|
|
1476
|
+
const _address = Address.fromString(address);
|
|
1477
|
+
if (_address === null) throw new Error("Invalid address");
|
|
1478
|
+
return _address;
|
|
1479
|
+
};
|
|
1480
|
+
var deserializeEd25519KeyHash = (ed25519KeyHash) => Ed25519KeyHash2.fromBytes((0, import_common3.toBytes)(ed25519KeyHash));
|
|
1481
|
+
var deserializeDataHash = (dataHash) => DatumHash.fromHexBlob((0, import_util3.HexBlob)(dataHash));
|
|
1482
|
+
var deserializePlutusData = (plutusData) => PlutusData.fromCbor((0, import_util3.HexBlob)(plutusData));
|
|
1483
|
+
var deserializePlutusScript = (plutusScript, version) => {
|
|
1484
|
+
switch (version) {
|
|
1485
|
+
case "V1":
|
|
1486
|
+
return PlutusV1Script.fromCbor((0, import_util3.HexBlob)(plutusScript));
|
|
1487
|
+
case "V2":
|
|
1488
|
+
return PlutusV2Script.fromCbor((0, import_util3.HexBlob)(plutusScript));
|
|
1489
|
+
case "V3":
|
|
1490
|
+
return PlutusV3Script.fromCbor((0, import_util3.HexBlob)(plutusScript));
|
|
1491
|
+
default:
|
|
1492
|
+
throw new Error("Invalid Plutus script version");
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
var deserializeNativeScript = (nativeScript) => NativeScript.fromCbor((0, import_util3.HexBlob)(nativeScript));
|
|
1496
|
+
var deserializeScriptHash = (scriptHash) => ScriptHash.fromEd25519KeyHashHex((0, import_crypto3.Ed25519KeyHashHex)(scriptHash));
|
|
1497
|
+
var deserializeScriptRef = (scriptRef) => Script.fromCbor((0, import_util3.HexBlob)(scriptRef));
|
|
1498
|
+
var deserializeTxUnspentOutput = (txUnspentOutput) => TransactionUnspentOutput.fromCbor((0, import_util3.HexBlob)(txUnspentOutput));
|
|
1499
|
+
var deserializeValue = (value) => Value.fromCbor((0, import_util3.HexBlob)(value));
|
|
1500
|
+
var deserializeTx = (tx) => Transaction.fromCbor((0, import_core2.TxCBOR)(tx));
|
|
1501
|
+
var deserializeTxHash = (txHash) => TransactionId.fromHexBlob((0, import_util3.HexBlob)(txHash));
|
|
1502
|
+
|
|
1503
|
+
// src/utils/converter.ts
|
|
1504
|
+
var toAddress = (bech32) => Address.fromBech32(bech32);
|
|
1505
|
+
var toBaseAddress = (bech32) => {
|
|
1506
|
+
return BaseAddress.fromAddress(toAddress(bech32));
|
|
1507
|
+
};
|
|
1508
|
+
var toEnterpriseAddress = (bech32) => {
|
|
1509
|
+
return EnterpriseAddress.fromAddress(toAddress(bech32));
|
|
1510
|
+
};
|
|
1511
|
+
var toRewardAddress = (bech32) => RewardAddress.fromAddress(toAddress(bech32));
|
|
1512
|
+
var fromTxUnspentOutput = (txUnspentOutput) => {
|
|
1513
|
+
const dataHash = txUnspentOutput.output().datum() ? txUnspentOutput.output().datum()?.toCbor().toString() : void 0;
|
|
1514
|
+
const scriptRef = txUnspentOutput.output().scriptRef() ? txUnspentOutput.output().scriptRef()?.toCbor().toString() : void 0;
|
|
1515
|
+
const plutusData = txUnspentOutput.output().datum()?.asInlineData() ? txUnspentOutput.output().datum()?.asInlineData()?.toCbor().toString() : void 0;
|
|
1516
|
+
return {
|
|
1517
|
+
input: {
|
|
1518
|
+
outputIndex: Number(txUnspentOutput.input().index()),
|
|
1519
|
+
txHash: txUnspentOutput.input().transactionId()
|
|
1520
|
+
},
|
|
1521
|
+
output: {
|
|
1522
|
+
address: txUnspentOutput.output().address().toBech32(),
|
|
1523
|
+
amount: fromValue(txUnspentOutput.output().amount()),
|
|
1524
|
+
dataHash,
|
|
1525
|
+
// todo not sure if correct
|
|
1526
|
+
plutusData,
|
|
1527
|
+
// todo not sure if correct
|
|
1528
|
+
scriptRef
|
|
1529
|
+
// todo not sure if correct
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1532
|
+
};
|
|
1533
|
+
var toTxUnspentOutput = (utxo) => {
|
|
1534
|
+
const txInput = new TransactionInput(
|
|
1535
|
+
deserializeTxHash(utxo.input.txHash),
|
|
1536
|
+
BigInt(utxo.input.outputIndex)
|
|
1537
|
+
);
|
|
1538
|
+
const txOutput = new TransactionOutput(
|
|
1539
|
+
toAddress(utxo.output.address),
|
|
1540
|
+
toValue(utxo.output.amount)
|
|
1541
|
+
);
|
|
1542
|
+
if (utxo.output.dataHash !== void 0) {
|
|
1543
|
+
txOutput.setDatum(
|
|
1544
|
+
Datum.fromCore(deserializeDataHash(utxo.output.dataHash))
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1547
|
+
if (utxo.output.plutusData !== void 0) {
|
|
1548
|
+
const plutusData = deserializePlutusData(utxo.output.plutusData);
|
|
1549
|
+
const datum = new import_core3.Serialization.Datum(void 0, plutusData);
|
|
1550
|
+
txOutput.setDatum(datum);
|
|
1551
|
+
}
|
|
1552
|
+
if (utxo.output.scriptRef !== void 0) {
|
|
1553
|
+
txOutput.setScriptRef(deserializeScriptRef(utxo.output.scriptRef));
|
|
1554
|
+
}
|
|
1555
|
+
return new TransactionUnspentOutput(txInput, txOutput);
|
|
1556
|
+
};
|
|
1557
|
+
var addressToBech32 = (address) => {
|
|
1558
|
+
return address.toBech32();
|
|
1559
|
+
};
|
|
1560
|
+
var fromValue = (value) => {
|
|
1561
|
+
const assets = [
|
|
1562
|
+
{ unit: "lovelace", quantity: value.coin().toString() }
|
|
1563
|
+
];
|
|
1564
|
+
const multiAsset = value.multiasset();
|
|
1565
|
+
if (multiAsset !== void 0) {
|
|
1566
|
+
const _assets = Array.from(multiAsset.keys());
|
|
1567
|
+
for (let i = 0; i < _assets.length; i += 1) {
|
|
1568
|
+
const assetId = _assets[i];
|
|
1569
|
+
if (assetId !== void 0) {
|
|
1570
|
+
const assetQuantity = multiAsset.get(assetId);
|
|
1571
|
+
if (assetQuantity !== void 0) {
|
|
1572
|
+
assets.push({
|
|
1573
|
+
unit: assetId,
|
|
1574
|
+
quantity: assetQuantity.toString()
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
return assets;
|
|
1581
|
+
};
|
|
1582
|
+
var toScriptRef = (script) => {
|
|
1583
|
+
if ("code" in script) {
|
|
1584
|
+
const plutusScript = deserializePlutusScript(script.code, script.version);
|
|
1585
|
+
if (plutusScript instanceof PlutusV1Script)
|
|
1586
|
+
return Script.newPlutusV1Script(plutusScript);
|
|
1587
|
+
if (plutusScript instanceof PlutusV2Script)
|
|
1588
|
+
return Script.newPlutusV2Script(plutusScript);
|
|
1589
|
+
if (plutusScript instanceof PlutusV3Script)
|
|
1590
|
+
return Script.newPlutusV3Script(plutusScript);
|
|
1591
|
+
}
|
|
1592
|
+
return Script.newNativeScript(toNativeScript(script));
|
|
1593
|
+
};
|
|
1594
|
+
var fromScriptRef = (scriptRef) => {
|
|
1595
|
+
const script = Script.fromCbor((0, import_util4.HexBlob)(scriptRef));
|
|
1596
|
+
const plutusScriptCodeV3 = script.asPlutusV3()?.toCbor().toString();
|
|
1597
|
+
if (plutusScriptCodeV3) {
|
|
1598
|
+
return {
|
|
1599
|
+
code: plutusScriptCodeV3,
|
|
1600
|
+
version: "V3"
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1603
|
+
const plutusScriptCodeV2 = script.asPlutusV2()?.toCbor().toString();
|
|
1604
|
+
if (plutusScriptCodeV2) {
|
|
1605
|
+
return {
|
|
1606
|
+
code: plutusScriptCodeV2,
|
|
1607
|
+
version: "V2"
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
const plutusScriptCodeV1 = script.asPlutusV1()?.toCbor().toString();
|
|
1611
|
+
if (plutusScriptCodeV1) {
|
|
1612
|
+
return {
|
|
1613
|
+
code: plutusScriptCodeV1,
|
|
1614
|
+
version: "V1"
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
const nativeScript = script.asNative();
|
|
1618
|
+
if (!nativeScript) {
|
|
1619
|
+
throw new Error("Invalid script");
|
|
1620
|
+
}
|
|
1621
|
+
return fromNativeScript(nativeScript);
|
|
1622
|
+
};
|
|
1623
|
+
var fromNativeScript = (script) => {
|
|
1624
|
+
const fromNativeScripts = (scripts) => {
|
|
1625
|
+
const nativeScripts = new Array();
|
|
1626
|
+
for (let index = 0; index < scripts.length; index += 1) {
|
|
1627
|
+
const script2 = scripts[index];
|
|
1628
|
+
if (script2) {
|
|
1629
|
+
nativeScripts.push(fromNativeScript(script2));
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
return nativeScripts;
|
|
1633
|
+
};
|
|
1634
|
+
switch (script.kind()) {
|
|
1635
|
+
case RequireAllOf: {
|
|
1636
|
+
const scriptAll = script.asScriptAll();
|
|
1637
|
+
return {
|
|
1638
|
+
type: "all",
|
|
1639
|
+
scripts: fromNativeScripts(scriptAll.nativeScripts())
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
case RequireAnyOf: {
|
|
1643
|
+
const scriptAny = script.asScriptAny();
|
|
1644
|
+
return {
|
|
1645
|
+
type: "any",
|
|
1646
|
+
scripts: fromNativeScripts(scriptAny.nativeScripts())
|
|
1647
|
+
};
|
|
1648
|
+
}
|
|
1649
|
+
case RequireNOf: {
|
|
1650
|
+
const scriptNOfK = script.asScriptNOfK();
|
|
1651
|
+
return {
|
|
1652
|
+
type: "atLeast",
|
|
1653
|
+
required: scriptNOfK.required(),
|
|
1654
|
+
scripts: fromNativeScripts(scriptNOfK.nativeScripts())
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
case RequireTimeAfter: {
|
|
1658
|
+
const timelockStart = script.asTimelockStart();
|
|
1659
|
+
return {
|
|
1660
|
+
type: "after",
|
|
1661
|
+
slot: timelockStart.slot().toString()
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
case RequireTimeBefore: {
|
|
1665
|
+
const timelockExpiry = script.asTimelockExpiry();
|
|
1666
|
+
return {
|
|
1667
|
+
type: "before",
|
|
1668
|
+
slot: timelockExpiry.slot().toString()
|
|
1669
|
+
};
|
|
1670
|
+
}
|
|
1671
|
+
case RequireSignature: {
|
|
1672
|
+
const scriptPubkey = script.asScriptPubkey();
|
|
1673
|
+
return {
|
|
1674
|
+
type: "sig",
|
|
1675
|
+
keyHash: scriptPubkey.keyHash().toString()
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
default:
|
|
1679
|
+
throw new Error(`Script Kind: ${script.kind()}, is not supported`);
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
var toNativeScript = (script) => {
|
|
1683
|
+
const toNativeScripts = (scripts) => {
|
|
1684
|
+
const nativeScripts = [];
|
|
1685
|
+
scripts.forEach((script2) => {
|
|
1686
|
+
nativeScripts.push(toNativeScript(script2));
|
|
1687
|
+
});
|
|
1688
|
+
return nativeScripts;
|
|
1689
|
+
};
|
|
1690
|
+
switch (script.type) {
|
|
1691
|
+
case "all":
|
|
1692
|
+
return NativeScript.newScriptAll(
|
|
1693
|
+
new import_core3.Serialization.ScriptAll(toNativeScripts(script.scripts))
|
|
1694
|
+
);
|
|
1695
|
+
case "any":
|
|
1696
|
+
return NativeScript.newScriptAny(
|
|
1697
|
+
new import_core3.Serialization.ScriptAny(toNativeScripts(script.scripts))
|
|
1698
|
+
);
|
|
1699
|
+
case "atLeast":
|
|
1700
|
+
return NativeScript.newScriptNOfK(
|
|
1701
|
+
new import_core3.Serialization.ScriptNOfK(
|
|
1702
|
+
toNativeScripts(script.scripts),
|
|
1703
|
+
script.required
|
|
1704
|
+
)
|
|
1705
|
+
);
|
|
1706
|
+
case "after":
|
|
1707
|
+
return NativeScript.newTimelockStart(
|
|
1708
|
+
new import_core3.Serialization.TimelockStart(Slot(parseInt(script.slot)))
|
|
1709
|
+
);
|
|
1710
|
+
case "before":
|
|
1711
|
+
return NativeScript.newTimelockExpiry(
|
|
1712
|
+
new import_core3.Serialization.TimelockExpiry(Slot(parseInt(script.slot)))
|
|
1713
|
+
);
|
|
1714
|
+
case "sig":
|
|
1715
|
+
return NativeScript.newScriptPubkey(
|
|
1716
|
+
new import_core3.Serialization.ScriptPubkey(
|
|
1717
|
+
import_crypto4.Ed25519KeyHash.fromBytes((0, import_common4.toBytes)(script.keyHash)).hex()
|
|
1718
|
+
)
|
|
1719
|
+
);
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
var toPlutusData = (data) => {
|
|
1723
|
+
const toPlutusList = (data2) => {
|
|
1724
|
+
const plutusList = new PlutusList();
|
|
1725
|
+
data2.forEach((element) => {
|
|
1726
|
+
plutusList.add(toPlutusData(element));
|
|
1727
|
+
});
|
|
1728
|
+
return plutusList;
|
|
1729
|
+
};
|
|
1730
|
+
switch (typeof data) {
|
|
1731
|
+
case "string":
|
|
1732
|
+
return PlutusData.newBytes((0, import_common4.toBytes)(data));
|
|
1733
|
+
case "number":
|
|
1734
|
+
return PlutusData.newInteger(BigInt(data));
|
|
1735
|
+
case "bigint":
|
|
1736
|
+
return PlutusData.newInteger(BigInt(data));
|
|
1737
|
+
case "object":
|
|
1738
|
+
if (data instanceof Array) {
|
|
1739
|
+
const plutusList = toPlutusList(data);
|
|
1740
|
+
return PlutusData.newList(plutusList);
|
|
1741
|
+
} else if (data instanceof Map) {
|
|
1742
|
+
const plutusMap = new PlutusMap();
|
|
1743
|
+
data.forEach((value, key) => {
|
|
1744
|
+
plutusMap.insert(toPlutusData(key), toPlutusData(value));
|
|
1745
|
+
});
|
|
1746
|
+
return PlutusData.newMap(plutusMap);
|
|
1747
|
+
} else {
|
|
1748
|
+
return PlutusData.newConstrPlutusData(
|
|
1749
|
+
new ConstrPlutusData(
|
|
1750
|
+
BigInt(data.alternative),
|
|
1751
|
+
toPlutusList(data.fields)
|
|
1752
|
+
)
|
|
1753
|
+
);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
};
|
|
1757
|
+
var toValue = (assets) => {
|
|
1758
|
+
const multiAsset = /* @__PURE__ */ new Map();
|
|
1759
|
+
assets.filter((asset) => asset.unit !== "lovelace").forEach((asset) => {
|
|
1760
|
+
multiAsset.set(AssetId(asset.unit), BigInt(asset.quantity));
|
|
1761
|
+
});
|
|
1762
|
+
const lovelace = assets.find((asset) => asset.unit === "lovelace");
|
|
1763
|
+
const value = new Value(BigInt(lovelace ? lovelace.quantity : 0));
|
|
1764
|
+
if (assets.length > 1 || !lovelace) {
|
|
1765
|
+
value.setMultiasset(multiAsset);
|
|
1766
|
+
}
|
|
1767
|
+
return value;
|
|
1768
|
+
};
|
|
1769
|
+
|
|
1770
|
+
// src/utils/value.ts
|
|
1771
|
+
function mergeValue(a, b) {
|
|
1772
|
+
const ma = a.multiasset() ?? /* @__PURE__ */ new Map();
|
|
1773
|
+
b.multiasset()?.forEach((v, k) => {
|
|
1774
|
+
const newVal = (ma.get(k) ?? 0n) + v;
|
|
1775
|
+
if (newVal == 0n) {
|
|
1776
|
+
ma.delete(k);
|
|
1777
|
+
} else {
|
|
1778
|
+
ma.set(k, newVal);
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1781
|
+
return new Value(
|
|
1782
|
+
BigInt(a.coin()) + BigInt(b.coin()),
|
|
1783
|
+
ma.size > 0 ? ma : void 0
|
|
1784
|
+
);
|
|
1785
|
+
}
|
|
1786
|
+
function negateValue(v) {
|
|
1787
|
+
const entries = v.multiasset()?.entries();
|
|
1788
|
+
const tokenMap = /* @__PURE__ */ new Map();
|
|
1789
|
+
if (entries) {
|
|
1790
|
+
for (const entry of entries) {
|
|
1791
|
+
tokenMap.set(entry[0], -entry[1]);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
return new Value(-v.coin(), tokenMap);
|
|
1795
|
+
}
|
|
1796
|
+
function subValue(a, b) {
|
|
1797
|
+
return mergeValue(a, negateValue(b));
|
|
1798
|
+
}
|
|
1799
|
+
function negatives(v) {
|
|
1800
|
+
const entries = v.multiasset()?.entries();
|
|
1801
|
+
const coin = v.coin() < 0n ? v.coin() : 0n;
|
|
1802
|
+
const tokenMap = /* @__PURE__ */ new Map();
|
|
1803
|
+
if (entries) {
|
|
1804
|
+
for (const entry of entries) {
|
|
1805
|
+
if (entry[1] < 0n) {
|
|
1806
|
+
tokenMap.set(entry[0], entry[1]);
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
return new Value(coin, tokenMap);
|
|
1811
|
+
}
|
|
1812
|
+
function assetTypes(v) {
|
|
1813
|
+
let count = v.coin() == 0n ? 0 : 1;
|
|
1814
|
+
const entries = v.multiasset();
|
|
1815
|
+
if (entries) {
|
|
1816
|
+
entries.forEach(() => {
|
|
1817
|
+
count += 1;
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
return count;
|
|
1821
|
+
}
|
|
1822
|
+
function empty(v) {
|
|
1823
|
+
return assetTypes(v) == 0;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
// src/utils/encoding.ts
|
|
1827
|
+
var hexToBytes = (hex) => Buffer.from(hex, "hex");
|
|
1828
|
+
|
|
1829
|
+
// src/resolvers/index.ts
|
|
1830
|
+
var resolveDataHash = (data) => {
|
|
1831
|
+
const plutusData = toPlutusData(data);
|
|
1832
|
+
return plutusData.hash().toString();
|
|
1833
|
+
};
|
|
1834
|
+
var resolveNativeScriptAddress = (script, networkId = 0) => {
|
|
1835
|
+
const nativeScript = toNativeScript(script);
|
|
1836
|
+
const enterpriseAddress = EnterpriseAddress.fromCredentials(networkId, {
|
|
1837
|
+
hash: nativeScript.hash(),
|
|
1838
|
+
type: import_core4.Cardano.CredentialType.ScriptHash
|
|
1839
|
+
});
|
|
1840
|
+
return enterpriseAddress.toAddress().toBech32();
|
|
1841
|
+
};
|
|
1842
|
+
var resolveNativeScriptHash = (script) => {
|
|
1843
|
+
return toNativeScript(script).hash().toString();
|
|
1844
|
+
};
|
|
1845
|
+
var resolvePaymentKeyHash = (bech32) => {
|
|
1846
|
+
try {
|
|
1847
|
+
const paymentKeyHash = [
|
|
1848
|
+
toBaseAddress(bech32)?.getPaymentCredential().hash,
|
|
1849
|
+
toEnterpriseAddress(bech32)?.getPaymentCredential().hash
|
|
1850
|
+
].find((kh) => kh !== void 0);
|
|
1851
|
+
if (paymentKeyHash !== void 0) return paymentKeyHash.toString();
|
|
1852
|
+
throw new Error(
|
|
1853
|
+
`Couldn't resolve payment key hash from address: ${bech32}`
|
|
1854
|
+
);
|
|
1855
|
+
} catch (error) {
|
|
1856
|
+
throw new Error(
|
|
1857
|
+
`An error occurred during resolvePaymentKeyHash: ${error}.`
|
|
1858
|
+
);
|
|
1859
|
+
}
|
|
1860
|
+
};
|
|
1861
|
+
var resolvePlutusScriptAddress = (script, networkId = 0) => {
|
|
1862
|
+
const plutusScript = deserializePlutusScript(script.code, script.version);
|
|
1863
|
+
const enterpriseAddress = EnterpriseAddress.fromCredentials(networkId, {
|
|
1864
|
+
hash: plutusScript.hash(),
|
|
1865
|
+
type: import_core4.Cardano.CredentialType.ScriptHash
|
|
1866
|
+
});
|
|
1867
|
+
return enterpriseAddress.toAddress().toBech32();
|
|
1868
|
+
};
|
|
1869
|
+
var resolvePlutusScriptHash = (bech32) => {
|
|
1870
|
+
try {
|
|
1871
|
+
const enterpriseAddress = toEnterpriseAddress(bech32);
|
|
1872
|
+
const scriptHash = enterpriseAddress?.getPaymentCredential().hash;
|
|
1873
|
+
if (scriptHash !== void 0) return scriptHash.toString();
|
|
1874
|
+
throw new Error(`Couldn't resolve script hash from address: ${bech32}`);
|
|
1875
|
+
} catch (error) {
|
|
1876
|
+
throw new Error(`An error occurred during resolveScriptHash: ${error}.`);
|
|
1877
|
+
}
|
|
1878
|
+
};
|
|
1879
|
+
var resolvePoolId = (hash2) => {
|
|
1880
|
+
return Ed25519KeyHashHex2(hash2).toString();
|
|
1881
|
+
};
|
|
1882
|
+
var resolvePrivateKey = (words) => {
|
|
1883
|
+
return "not implemented";
|
|
1884
|
+
};
|
|
1885
|
+
var resolveScriptRef = (script) => {
|
|
1886
|
+
return toScriptRef(script).toCbor().toString();
|
|
1887
|
+
};
|
|
1888
|
+
var resolveRewardAddress = (bech32) => {
|
|
1889
|
+
try {
|
|
1890
|
+
const address = toAddress(bech32);
|
|
1891
|
+
const baseAddress = toBaseAddress(bech32);
|
|
1892
|
+
const stakeKeyHash = baseAddress?.getStakeCredential().hash;
|
|
1893
|
+
if (stakeKeyHash !== void 0)
|
|
1894
|
+
return buildRewardAddress(address.getNetworkId(), stakeKeyHash).toAddress().toBech32();
|
|
1895
|
+
throw new Error(`Couldn't resolve reward address from address: ${bech32}`);
|
|
1896
|
+
} catch (error) {
|
|
1897
|
+
throw new Error(`An error occurred during resolveRewardAddress: ${error}.`);
|
|
1898
|
+
}
|
|
1899
|
+
};
|
|
1900
|
+
var resolveStakeKeyHash = (bech32) => {
|
|
1901
|
+
try {
|
|
1902
|
+
const stakeKeyHash = [
|
|
1903
|
+
toBaseAddress(bech32)?.getStakeCredential().hash,
|
|
1904
|
+
toRewardAddress(bech32)?.getPaymentCredential().hash
|
|
1905
|
+
].find((kh) => kh !== void 0);
|
|
1906
|
+
if (stakeKeyHash !== void 0) return stakeKeyHash.toString();
|
|
1907
|
+
throw new Error(`Couldn't resolve stake key hash from address: ${bech32}`);
|
|
1908
|
+
} catch (error) {
|
|
1909
|
+
throw new Error(`An error occurred during resolveStakeKeyHash: ${error}.`);
|
|
1910
|
+
}
|
|
1911
|
+
};
|
|
1912
|
+
var resolveTxHash = (txHex) => {
|
|
1913
|
+
const txBody = deserializeTx(txHex).body();
|
|
1914
|
+
const hash2 = (0, import_crypto5.blake2b)(import_crypto5.blake2b.BYTES).update(hexToBytes(txBody.toCbor())).digest();
|
|
1915
|
+
return import_core4.Cardano.TransactionId.fromHexBlob(import_util5.HexBlob.fromBytes(hash2));
|
|
1916
|
+
};
|
|
1917
|
+
|
|
1918
|
+
// src/serializer/index.ts
|
|
1919
|
+
var import_core6 = require("@cardano-sdk/core");
|
|
1920
|
+
var import_util7 = require("@cardano-sdk/util");
|
|
1921
|
+
var import_common5 = require("@meshsdk/common");
|
|
1922
|
+
|
|
1923
|
+
// src/utils/script-data-hash.ts
|
|
1924
|
+
var import_core5 = require("@cardano-sdk/core");
|
|
1925
|
+
var Crypto2 = __toESM(require("@cardano-sdk/crypto"), 1);
|
|
1926
|
+
var import_crypto6 = require("@cardano-sdk/crypto");
|
|
1927
|
+
var import_util6 = require("@cardano-sdk/util");
|
|
1928
|
+
var CBOR_EMPTY_LIST = new Uint8Array([128]);
|
|
1929
|
+
var CBOR_EMPTY_MAP = new Uint8Array([160]);
|
|
1930
|
+
var getCborEncodedArray = (items) => {
|
|
1931
|
+
const writer = new import_core5.Serialization.CborWriter();
|
|
1932
|
+
writer.writeStartArray(items.length);
|
|
1933
|
+
for (const item of items) {
|
|
1934
|
+
writer.writeEncodedValue(Buffer.from(item.toCbor(), "hex"));
|
|
1935
|
+
}
|
|
1936
|
+
return writer.encode();
|
|
1937
|
+
};
|
|
1938
|
+
var hashScriptData = (costModels, redemeers, datums) => {
|
|
1939
|
+
const writer = new import_core5.Serialization.CborWriter();
|
|
1940
|
+
if (datums && datums.length > 0 && (!redemeers || redemeers.length === 0)) {
|
|
1941
|
+
writer.writeEncodedValue(CBOR_EMPTY_LIST);
|
|
1942
|
+
writer.writeEncodedValue(getCborEncodedArray(datums));
|
|
1943
|
+
writer.writeEncodedValue(CBOR_EMPTY_MAP);
|
|
1944
|
+
} else {
|
|
1945
|
+
if (!redemeers || redemeers.length === 0) return void 0;
|
|
1946
|
+
writer.writeEncodedValue(getCborEncodedArray(redemeers));
|
|
1947
|
+
if (datums && datums.length > 0)
|
|
1948
|
+
writer.writeEncodedValue(getCborEncodedArray(datums));
|
|
1949
|
+
writer.writeEncodedValue(
|
|
1950
|
+
Buffer.from(costModels.languageViewsEncoding(), "hex")
|
|
1951
|
+
);
|
|
1952
|
+
}
|
|
1953
|
+
return import_crypto6.Hash32ByteBase16.fromHexBlob(
|
|
1954
|
+
import_util6.HexBlob.fromBytes(
|
|
1955
|
+
Crypto2.blake2b(Crypto2.blake2b.BYTES).update(writer.encode()).digest()
|
|
1956
|
+
)
|
|
1957
|
+
);
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1960
|
+
// src/serializer/index.ts
|
|
1961
|
+
var CardanoSDKSerializer = class {
|
|
1962
|
+
txBody;
|
|
1963
|
+
txWitnessSet;
|
|
1964
|
+
utxoContext = /* @__PURE__ */ new Map();
|
|
1965
|
+
redeemerContext = /* @__PURE__ */ new Map();
|
|
1966
|
+
scriptsProvided = /* @__PURE__ */ new Set();
|
|
1967
|
+
datumsProvided = /* @__PURE__ */ new Set();
|
|
1968
|
+
usedLanguages = {
|
|
1969
|
+
[0]: false,
|
|
1970
|
+
[1]: false,
|
|
1971
|
+
[2]: false
|
|
1972
|
+
};
|
|
1973
|
+
constructor() {
|
|
1974
|
+
this.txBody = new TransactionBody(
|
|
1975
|
+
import_core6.Serialization.CborSet.fromCore([], TransactionInput.fromCore),
|
|
1976
|
+
[],
|
|
1977
|
+
BigInt(0),
|
|
1978
|
+
void 0
|
|
1979
|
+
);
|
|
1980
|
+
this.txWitnessSet = new TransactionWitnessSet();
|
|
1981
|
+
}
|
|
1982
|
+
serializeRewardAddress(stakeKeyHash, isScriptHash, network_id) {
|
|
1983
|
+
throw new Error("Method not implemented.");
|
|
1984
|
+
}
|
|
1985
|
+
serializePoolId(hash2) {
|
|
1986
|
+
throw new Error("Method not implemented.");
|
|
1987
|
+
}
|
|
1988
|
+
serializeAddress(address, networkId) {
|
|
1989
|
+
throw new Error("Method not implemented.");
|
|
1990
|
+
}
|
|
1991
|
+
serializeData(data) {
|
|
1992
|
+
throw new Error("Method not implemented.");
|
|
1993
|
+
}
|
|
1994
|
+
deserializer = {
|
|
1995
|
+
key: {
|
|
1996
|
+
deserializeAddress: function(bech32) {
|
|
1997
|
+
throw new Error("Function not implemented.");
|
|
1998
|
+
}
|
|
1999
|
+
},
|
|
2000
|
+
script: {
|
|
2001
|
+
deserializeNativeScript: function(script) {
|
|
2002
|
+
throw new Error("Function not implemented.");
|
|
2003
|
+
},
|
|
2004
|
+
deserializePlutusScript: function(script) {
|
|
2005
|
+
throw new Error("Function not implemented.");
|
|
2006
|
+
}
|
|
2007
|
+
},
|
|
2008
|
+
cert: {
|
|
2009
|
+
deserializePoolId: function(poolId) {
|
|
2010
|
+
throw new Error("Function not implemented.");
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
resolver = {
|
|
2015
|
+
keys: {
|
|
2016
|
+
// resolvePaymentKeyHash: function (bech32: string): string {
|
|
2017
|
+
// const cardanoAddress = toAddress(bech32);
|
|
2018
|
+
// return cardanoAddress.asEnterprise()?.getPaymentCredential().type ===
|
|
2019
|
+
// CredentialType.KeyHash
|
|
2020
|
+
// ? cardanoAddress.asEnterprise()!.getPaymentCredential().hash
|
|
2021
|
+
// : "";
|
|
2022
|
+
// },
|
|
2023
|
+
// resolvePlutusScriptHash: function (bech32: string): string {
|
|
2024
|
+
// const cardanoAddress = toAddress(bech32);
|
|
2025
|
+
// return cardanoAddress.asEnterprise()?.getPaymentCredential().type ===
|
|
2026
|
+
// CredentialType.ScriptHash
|
|
2027
|
+
// ? cardanoAddress.asEnterprise()!.getPaymentCredential().hash
|
|
2028
|
+
// : "";
|
|
2029
|
+
// },
|
|
2030
|
+
resolveStakeKeyHash: function(bech32) {
|
|
2031
|
+
const cardanoAddress = toAddress(bech32);
|
|
2032
|
+
return cardanoAddress.asReward()?.getPaymentCredential().type === CredentialType.KeyHash ? cardanoAddress.asReward().getPaymentCredential().hash : "";
|
|
2033
|
+
},
|
|
2034
|
+
// resolveStakeScriptHash(bech32: string): string {
|
|
2035
|
+
// const cardanoAddress = toAddress(bech32);
|
|
2036
|
+
// return cardanoAddress.asReward()?.getPaymentCredential().type ===
|
|
2037
|
+
// CredentialType.ScriptHash
|
|
2038
|
+
// ? cardanoAddress.asReward()!.getPaymentCredential().hash
|
|
2039
|
+
// : "";
|
|
2040
|
+
// },
|
|
2041
|
+
resolvePrivateKey: function(words) {
|
|
2042
|
+
throw new Error("Function not implemented.");
|
|
2043
|
+
},
|
|
2044
|
+
resolveRewardAddress: function(bech32) {
|
|
2045
|
+
throw new Error("Function not implemented.");
|
|
2046
|
+
},
|
|
2047
|
+
resolveEd25519KeyHash: function(bech32) {
|
|
2048
|
+
throw new Error("Function not implemented.");
|
|
2049
|
+
}
|
|
2050
|
+
},
|
|
2051
|
+
tx: {
|
|
2052
|
+
resolveTxHash: function(txHex) {
|
|
2053
|
+
return Transaction.fromCbor((0, import_core6.TxCBOR)(txHex)).getId();
|
|
2054
|
+
}
|
|
2055
|
+
},
|
|
2056
|
+
data: {
|
|
2057
|
+
resolveDataHash: function(data) {
|
|
2058
|
+
throw new Error("Function not implemented.");
|
|
2059
|
+
}
|
|
2060
|
+
},
|
|
2061
|
+
script: {
|
|
2062
|
+
// resolveNativeScript: function (script: CommonNativeScript): string {
|
|
2063
|
+
// return toNativeScript(script).toCbor();
|
|
2064
|
+
// },
|
|
2065
|
+
resolveScriptRef: function(script) {
|
|
2066
|
+
throw new Error("Function not implemented.");
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
};
|
|
2070
|
+
serializeTxBody = (txBuilderBody, protocolParams) => {
|
|
2071
|
+
const {
|
|
2072
|
+
inputs,
|
|
2073
|
+
outputs,
|
|
2074
|
+
collaterals,
|
|
2075
|
+
referenceInputs,
|
|
2076
|
+
mints,
|
|
2077
|
+
changeAddress,
|
|
2078
|
+
// certificates,
|
|
2079
|
+
validityRange,
|
|
2080
|
+
requiredSignatures
|
|
2081
|
+
// metadata,
|
|
2082
|
+
} = txBuilderBody;
|
|
2083
|
+
mints.sort((a, b) => a.policyId.localeCompare(b.policyId));
|
|
2084
|
+
inputs.sort((a, b) => {
|
|
2085
|
+
if (a.txIn.txHash === b.txIn.txHash) {
|
|
2086
|
+
return a.txIn.txIndex - b.txIn.txIndex;
|
|
2087
|
+
} else {
|
|
2088
|
+
return a.txIn.txHash.localeCompare(b.txIn.txHash);
|
|
2089
|
+
}
|
|
2090
|
+
});
|
|
2091
|
+
this.addAllInputs(inputs);
|
|
2092
|
+
this.addAllOutputs(outputs);
|
|
2093
|
+
this.addAllMints(mints);
|
|
2094
|
+
this.addAllCollateralInputs(collaterals);
|
|
2095
|
+
this.addAllReferenceInputs(referenceInputs);
|
|
2096
|
+
this.setValidityInterval(validityRange);
|
|
2097
|
+
this.buildWitnessSet();
|
|
2098
|
+
this.balanceTx(changeAddress, requiredSignatures.length, protocolParams);
|
|
2099
|
+
return new Transaction(this.txBody, this.txWitnessSet).toCbor();
|
|
2100
|
+
};
|
|
2101
|
+
addSigningKeys = (txHex, signingKeys) => {
|
|
2102
|
+
let cardanoTx = Transaction.fromCbor((0, import_core6.TxCBOR)(txHex));
|
|
2103
|
+
let currentWitnessSet = cardanoTx.witnessSet();
|
|
2104
|
+
let currentWitnessSetVkeys = currentWitnessSet.vkeys();
|
|
2105
|
+
let currentWitnessSetVkeysValues = currentWitnessSetVkeys ? [...currentWitnessSetVkeys.values()] : [];
|
|
2106
|
+
for (let i = 0; i < signingKeys.length; i++) {
|
|
2107
|
+
let keyHex = signingKeys[i];
|
|
2108
|
+
if (keyHex) {
|
|
2109
|
+
if (keyHex.length === 68 && keyHex.substring(0, 4) === "5820") {
|
|
2110
|
+
keyHex = keyHex.substring(4);
|
|
2111
|
+
}
|
|
2112
|
+
const cardanoSigner = new PrivateKey(
|
|
2113
|
+
Buffer.from(keyHex, "hex"),
|
|
2114
|
+
false
|
|
2115
|
+
);
|
|
2116
|
+
const signature = cardanoSigner.sign(
|
|
2117
|
+
Buffer.from(cardanoTx.getId(), "hex")
|
|
2118
|
+
);
|
|
2119
|
+
currentWitnessSetVkeysValues.push(
|
|
2120
|
+
new VkeyWitness(
|
|
2121
|
+
Ed25519PublicKeyHex2(
|
|
2122
|
+
cardanoSigner.toPublicKey().toBytes().toString("hex")
|
|
2123
|
+
),
|
|
2124
|
+
Ed25519SignatureHex2(signature.toString("hex"))
|
|
2125
|
+
)
|
|
2126
|
+
);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
currentWitnessSet.setVkeys(
|
|
2130
|
+
import_core6.Serialization.CborSet.fromCore(
|
|
2131
|
+
currentWitnessSetVkeysValues.map((vkw) => vkw.toCore()),
|
|
2132
|
+
VkeyWitness.fromCore
|
|
2133
|
+
)
|
|
2134
|
+
);
|
|
2135
|
+
cardanoTx.setWitnessSet(currentWitnessSet);
|
|
2136
|
+
return cardanoTx.toCbor();
|
|
2137
|
+
};
|
|
2138
|
+
addAllInputs = (inputs) => {
|
|
2139
|
+
for (let i = 0; i < inputs.length; i += 1) {
|
|
2140
|
+
const currentTxIn = inputs[i];
|
|
2141
|
+
if (!currentTxIn) continue;
|
|
2142
|
+
switch (currentTxIn.type) {
|
|
2143
|
+
case "PubKey":
|
|
2144
|
+
this.addTxIn(currentTxIn);
|
|
2145
|
+
break;
|
|
2146
|
+
case "Script":
|
|
2147
|
+
this.addScriptTxIn(
|
|
2148
|
+
currentTxIn
|
|
2149
|
+
);
|
|
2150
|
+
break;
|
|
2151
|
+
case "SimpleScript":
|
|
2152
|
+
this.addSimpleScriptTxIn(
|
|
2153
|
+
currentTxIn
|
|
2154
|
+
);
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
};
|
|
2158
|
+
addTxIn = (currentTxIn) => {
|
|
2159
|
+
let cardanoTxIn = new TransactionInput(
|
|
2160
|
+
TransactionId(currentTxIn.txIn.txHash),
|
|
2161
|
+
BigInt(currentTxIn.txIn.txIndex)
|
|
2162
|
+
);
|
|
2163
|
+
const inputs = this.txBody.inputs();
|
|
2164
|
+
const txInputsList = [...inputs.values()];
|
|
2165
|
+
if (txInputsList.find((input) => {
|
|
2166
|
+
input.index() == cardanoTxIn.index() && input.transactionId == cardanoTxIn.transactionId;
|
|
2167
|
+
})) {
|
|
2168
|
+
throw new Error("Duplicate input added to tx body");
|
|
2169
|
+
}
|
|
2170
|
+
txInputsList.push(cardanoTxIn);
|
|
2171
|
+
inputs.setValues(txInputsList);
|
|
2172
|
+
const cardanoTxOut = new TransactionOutput(
|
|
2173
|
+
Address.fromBech32(currentTxIn.txIn.address),
|
|
2174
|
+
toValue(currentTxIn.txIn.amount)
|
|
2175
|
+
);
|
|
2176
|
+
this.utxoContext.set(cardanoTxIn, cardanoTxOut);
|
|
2177
|
+
this.txBody.setInputs(inputs);
|
|
2178
|
+
};
|
|
2179
|
+
addScriptTxIn = (currentTxIn) => {
|
|
2180
|
+
this.addTxIn({
|
|
2181
|
+
type: "PubKey",
|
|
2182
|
+
txIn: currentTxIn.txIn
|
|
2183
|
+
});
|
|
2184
|
+
if (!currentTxIn.scriptTxIn.scriptSource) {
|
|
2185
|
+
throw new Error("A script input had no script source");
|
|
2186
|
+
}
|
|
2187
|
+
if (!currentTxIn.scriptTxIn.datumSource) {
|
|
2188
|
+
throw new Error("A script input had no datum source");
|
|
2189
|
+
}
|
|
2190
|
+
if (!currentTxIn.scriptTxIn.redeemer) {
|
|
2191
|
+
throw new Error("A script input had no redeemer");
|
|
2192
|
+
}
|
|
2193
|
+
if (currentTxIn.scriptTxIn.scriptSource.type === "Provided") {
|
|
2194
|
+
switch (currentTxIn.scriptTxIn.scriptSource.script.version) {
|
|
2195
|
+
case "V1": {
|
|
2196
|
+
this.scriptsProvided.add(
|
|
2197
|
+
Script.newPlutusV1Script(
|
|
2198
|
+
PlutusV1Script.fromCbor(
|
|
2199
|
+
(0, import_util7.HexBlob)(currentTxIn.scriptTxIn.scriptSource.script.code)
|
|
2200
|
+
)
|
|
2201
|
+
)
|
|
2202
|
+
);
|
|
2203
|
+
this.usedLanguages[PlutusLanguageVersion.V1] = true;
|
|
2204
|
+
break;
|
|
2205
|
+
}
|
|
2206
|
+
case "V2": {
|
|
2207
|
+
this.scriptsProvided.add(
|
|
2208
|
+
Script.newPlutusV2Script(
|
|
2209
|
+
PlutusV2Script.fromCbor(
|
|
2210
|
+
(0, import_util7.HexBlob)(currentTxIn.scriptTxIn.scriptSource.script.code)
|
|
2211
|
+
)
|
|
2212
|
+
)
|
|
2213
|
+
);
|
|
2214
|
+
this.usedLanguages[PlutusLanguageVersion.V2] = true;
|
|
2215
|
+
break;
|
|
2216
|
+
}
|
|
2217
|
+
case "V3": {
|
|
2218
|
+
this.scriptsProvided.add(
|
|
2219
|
+
Script.newPlutusV3Script(
|
|
2220
|
+
PlutusV3Script.fromCbor(
|
|
2221
|
+
(0, import_util7.HexBlob)(currentTxIn.scriptTxIn.scriptSource.script.code)
|
|
2222
|
+
)
|
|
2223
|
+
)
|
|
2224
|
+
);
|
|
2225
|
+
this.usedLanguages[PlutusLanguageVersion.V3] = true;
|
|
2226
|
+
break;
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
} else if (currentTxIn.scriptTxIn.scriptSource.type === "Inline") {
|
|
2230
|
+
let referenceInputs = this.txBody.referenceInputs() ?? import_core6.Serialization.CborSet.fromCore([], TransactionInput.fromCore);
|
|
2231
|
+
let referenceInputsList = [...referenceInputs.values()];
|
|
2232
|
+
referenceInputsList.push(
|
|
2233
|
+
new TransactionInput(
|
|
2234
|
+
TransactionId(currentTxIn.scriptTxIn.scriptSource.txHash),
|
|
2235
|
+
BigInt(currentTxIn.scriptTxIn.scriptSource.txIndex)
|
|
2236
|
+
)
|
|
2237
|
+
);
|
|
2238
|
+
referenceInputs.setValues(referenceInputsList);
|
|
2239
|
+
this.txBody.setReferenceInputs(referenceInputs);
|
|
2240
|
+
switch (currentTxIn.scriptTxIn.scriptSource.version) {
|
|
2241
|
+
case "V1": {
|
|
2242
|
+
this.usedLanguages[PlutusLanguageVersion.V1] = true;
|
|
2243
|
+
break;
|
|
2244
|
+
}
|
|
2245
|
+
case "V2": {
|
|
2246
|
+
this.usedLanguages[PlutusLanguageVersion.V2] = true;
|
|
2247
|
+
break;
|
|
2248
|
+
}
|
|
2249
|
+
case "V3": {
|
|
2250
|
+
this.usedLanguages[PlutusLanguageVersion.V3] = true;
|
|
2251
|
+
break;
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
if (currentTxIn.scriptTxIn.datumSource.type === "Provided") {
|
|
2256
|
+
this.datumsProvided.add(
|
|
2257
|
+
toPlutusData(currentTxIn.scriptTxIn.datumSource.data.content)
|
|
2258
|
+
// TODO: handle json / raw datum
|
|
2259
|
+
);
|
|
2260
|
+
} else if (currentTxIn.scriptTxIn.datumSource.type === "Inline") {
|
|
2261
|
+
let referenceInputs = this.txBody.referenceInputs() ?? import_core6.Serialization.CborSet.fromCore([], TransactionInput.fromCore);
|
|
2262
|
+
let referenceInputsList = [...referenceInputs.values()];
|
|
2263
|
+
referenceInputsList.push(
|
|
2264
|
+
new TransactionInput(
|
|
2265
|
+
TransactionId(currentTxIn.txIn.txHash),
|
|
2266
|
+
BigInt(currentTxIn.txIn.txIndex)
|
|
2267
|
+
)
|
|
2268
|
+
);
|
|
2269
|
+
referenceInputs.setValues(referenceInputsList);
|
|
2270
|
+
this.txBody.setReferenceInputs(referenceInputs);
|
|
2271
|
+
}
|
|
2272
|
+
let cardanoTxIn = new TransactionInput(
|
|
2273
|
+
TransactionId(currentTxIn.txIn.txHash),
|
|
2274
|
+
BigInt(currentTxIn.txIn.txIndex)
|
|
2275
|
+
);
|
|
2276
|
+
let exUnits = currentTxIn.scriptTxIn.redeemer.exUnits;
|
|
2277
|
+
this.redeemerContext.set(
|
|
2278
|
+
cardanoTxIn,
|
|
2279
|
+
new Redeemer(
|
|
2280
|
+
RedeemerTag.Spend,
|
|
2281
|
+
BigInt(0),
|
|
2282
|
+
toPlutusData(currentTxIn.scriptTxIn.redeemer.data.content),
|
|
2283
|
+
// TODO: handle json / raw datum
|
|
2284
|
+
new ExUnits(BigInt(exUnits.mem), BigInt(exUnits.steps))
|
|
2285
|
+
)
|
|
2286
|
+
);
|
|
2287
|
+
};
|
|
2288
|
+
addSimpleScriptTxIn = (currentTxIn) => {
|
|
2289
|
+
this.addTxIn({
|
|
2290
|
+
type: "PubKey",
|
|
2291
|
+
txIn: currentTxIn.txIn
|
|
2292
|
+
});
|
|
2293
|
+
if (!currentTxIn.simpleScriptTxIn.scriptSource) {
|
|
2294
|
+
throw new Error("A native script input had no script source");
|
|
2295
|
+
}
|
|
2296
|
+
if (currentTxIn.simpleScriptTxIn.scriptSource.type === "Provided") {
|
|
2297
|
+
this.scriptsProvided.add(
|
|
2298
|
+
Script.newNativeScript(
|
|
2299
|
+
NativeScript.fromCbor(
|
|
2300
|
+
(0, import_util7.HexBlob)(currentTxIn.simpleScriptTxIn.scriptSource.script)
|
|
2301
|
+
)
|
|
2302
|
+
)
|
|
2303
|
+
);
|
|
2304
|
+
} else if (currentTxIn.simpleScriptTxIn.scriptSource.type === "Inline" && currentTxIn.simpleScriptTxIn.scriptSource.txInInfo.type === "Inline") {
|
|
2305
|
+
let referenceInputs = this.txBody.referenceInputs() ?? import_core6.Serialization.CborSet.fromCore([], TransactionInput.fromCore);
|
|
2306
|
+
let referenceInputsList = [...referenceInputs.values()];
|
|
2307
|
+
referenceInputsList.push(
|
|
2308
|
+
new TransactionInput(
|
|
2309
|
+
TransactionId(
|
|
2310
|
+
currentTxIn.simpleScriptTxIn.scriptSource.txInInfo.txHash
|
|
2311
|
+
),
|
|
2312
|
+
BigInt(currentTxIn.simpleScriptTxIn.scriptSource.txInInfo.txIndex)
|
|
2313
|
+
)
|
|
2314
|
+
);
|
|
2315
|
+
referenceInputs.setValues(referenceInputsList);
|
|
2316
|
+
this.txBody.setReferenceInputs(referenceInputs);
|
|
2317
|
+
}
|
|
2318
|
+
};
|
|
2319
|
+
addAllOutputs = (outputs) => {
|
|
2320
|
+
for (let i = 0; i < outputs.length; i++) {
|
|
2321
|
+
this.addOutput(outputs[i]);
|
|
2322
|
+
}
|
|
2323
|
+
};
|
|
2324
|
+
addOutput = (output) => {
|
|
2325
|
+
const currentOutputs = this.txBody.outputs();
|
|
2326
|
+
const cardanoOutput = new TransactionOutput(
|
|
2327
|
+
Address.fromBech32(output.address),
|
|
2328
|
+
toValue(output.amount)
|
|
2329
|
+
);
|
|
2330
|
+
if (output.datum?.type === "Hash") {
|
|
2331
|
+
cardanoOutput.setDatum(
|
|
2332
|
+
Datum.newDataHash(
|
|
2333
|
+
DatumHash.fromHexBlob(
|
|
2334
|
+
(0, import_util7.HexBlob)(toPlutusData(output.datum.data.content).hash())
|
|
2335
|
+
)
|
|
2336
|
+
)
|
|
2337
|
+
);
|
|
2338
|
+
} else if (output.datum?.type === "Inline") {
|
|
2339
|
+
cardanoOutput.setDatum(
|
|
2340
|
+
Datum.newInlineData(
|
|
2341
|
+
toPlutusData(output.datum.data.content)
|
|
2342
|
+
// TODO: handle json / raw datum
|
|
2343
|
+
)
|
|
2344
|
+
);
|
|
2345
|
+
}
|
|
2346
|
+
if (output.referenceScript) {
|
|
2347
|
+
switch (output.referenceScript.version) {
|
|
2348
|
+
case "V1": {
|
|
2349
|
+
cardanoOutput.setScriptRef(
|
|
2350
|
+
Script.newPlutusV1Script(
|
|
2351
|
+
PlutusV1Script.fromCbor((0, import_util7.HexBlob)(output.referenceScript.code))
|
|
2352
|
+
)
|
|
2353
|
+
);
|
|
2354
|
+
break;
|
|
2355
|
+
}
|
|
2356
|
+
case "V2": {
|
|
2357
|
+
cardanoOutput.setScriptRef(
|
|
2358
|
+
Script.newPlutusV2Script(
|
|
2359
|
+
PlutusV2Script.fromCbor((0, import_util7.HexBlob)(output.referenceScript.code))
|
|
2360
|
+
)
|
|
2361
|
+
);
|
|
2362
|
+
break;
|
|
2363
|
+
}
|
|
2364
|
+
case "V3": {
|
|
2365
|
+
cardanoOutput.setScriptRef(
|
|
2366
|
+
Script.newPlutusV3Script(
|
|
2367
|
+
PlutusV3Script.fromCbor((0, import_util7.HexBlob)(output.referenceScript.code))
|
|
2368
|
+
)
|
|
2369
|
+
);
|
|
2370
|
+
break;
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
currentOutputs.push(cardanoOutput);
|
|
2375
|
+
this.txBody.setOutputs(currentOutputs);
|
|
2376
|
+
};
|
|
2377
|
+
addAllReferenceInputs = (refInputs) => {
|
|
2378
|
+
for (let i = 0; i < refInputs.length; i++) {
|
|
2379
|
+
this.addReferenceIput(refInputs[i]);
|
|
2380
|
+
}
|
|
2381
|
+
};
|
|
2382
|
+
addReferenceIput = (refInput) => {
|
|
2383
|
+
let referenceInputs = this.txBody.referenceInputs() ?? import_core6.Serialization.CborSet.fromCore([], TransactionInput.fromCore);
|
|
2384
|
+
let referenceInputsList = [...referenceInputs.values()];
|
|
2385
|
+
referenceInputsList.push(
|
|
2386
|
+
new TransactionInput(
|
|
2387
|
+
TransactionId.fromHexBlob((0, import_util7.HexBlob)(refInput.txHash)),
|
|
2388
|
+
BigInt(refInput.txIndex)
|
|
2389
|
+
)
|
|
2390
|
+
);
|
|
2391
|
+
referenceInputs.setValues(referenceInputsList);
|
|
2392
|
+
this.txBody.setReferenceInputs(referenceInputs);
|
|
2393
|
+
};
|
|
2394
|
+
addAllMints = (mints) => {
|
|
2395
|
+
for (let i = 0; i < mints.length; i++) {
|
|
2396
|
+
this.addMint(mints[i]);
|
|
2397
|
+
}
|
|
2398
|
+
};
|
|
2399
|
+
addMint = (mint) => {
|
|
2400
|
+
const currentMint = this.txBody.mint() ?? /* @__PURE__ */ new Map();
|
|
2401
|
+
const mintAssetId = mint.policyId + mint.assetName;
|
|
2402
|
+
for (const asset of currentMint.keys()) {
|
|
2403
|
+
if (asset.toString() == mintAssetId) {
|
|
2404
|
+
throw new Error("The same asset is already in the mint field");
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
currentMint.set(
|
|
2408
|
+
AssetId.fromParts(PolicyId(mint.policyId), AssetName(mint.assetName)),
|
|
2409
|
+
BigInt(mint.amount)
|
|
2410
|
+
);
|
|
2411
|
+
this.txBody.setMint(currentMint);
|
|
2412
|
+
if (mint.type === "Native") {
|
|
2413
|
+
if (!mint.scriptSource)
|
|
2414
|
+
throw new Error("Script source not provided for native script mint");
|
|
2415
|
+
const nativeScriptSource = mint.scriptSource;
|
|
2416
|
+
if (!nativeScriptSource)
|
|
2417
|
+
throw new Error(
|
|
2418
|
+
"A script source for a native script was not a native script somehow"
|
|
2419
|
+
);
|
|
2420
|
+
if (nativeScriptSource.type === "Provided") {
|
|
2421
|
+
this.scriptsProvided.add(
|
|
2422
|
+
Script.newNativeScript(
|
|
2423
|
+
NativeScript.fromCbor((0, import_util7.HexBlob)(nativeScriptSource.scriptCode))
|
|
2424
|
+
)
|
|
2425
|
+
);
|
|
2426
|
+
} else if (nativeScriptSource.type === "Inline") {
|
|
2427
|
+
let referenceInputs = this.txBody.referenceInputs() ?? import_core6.Serialization.CborSet.fromCore([], TransactionInput.fromCore);
|
|
2428
|
+
let referenceInputsList = [...referenceInputs.values()];
|
|
2429
|
+
referenceInputsList.push(
|
|
2430
|
+
new TransactionInput(
|
|
2431
|
+
TransactionId(nativeScriptSource.txHash),
|
|
2432
|
+
BigInt(nativeScriptSource.txIndex)
|
|
2433
|
+
)
|
|
2434
|
+
);
|
|
2435
|
+
referenceInputs.setValues(referenceInputsList);
|
|
2436
|
+
this.txBody.setReferenceInputs(referenceInputs);
|
|
2437
|
+
}
|
|
2438
|
+
} else if (mint.type === "Plutus") {
|
|
2439
|
+
if (!mint.scriptSource)
|
|
2440
|
+
throw new Error("Script source not provided for plutus script mint");
|
|
2441
|
+
const plutusScriptSource = mint.scriptSource;
|
|
2442
|
+
if (!plutusScriptSource) {
|
|
2443
|
+
throw new Error(
|
|
2444
|
+
"A script source for a plutus mint was not plutus script somehow"
|
|
2445
|
+
);
|
|
2446
|
+
}
|
|
2447
|
+
if (plutusScriptSource.type === "Provided") {
|
|
2448
|
+
switch (plutusScriptSource.script.version) {
|
|
2449
|
+
case "V1":
|
|
2450
|
+
this.scriptsProvided.add(
|
|
2451
|
+
Script.newPlutusV1Script(
|
|
2452
|
+
PlutusV1Script.fromCbor(
|
|
2453
|
+
(0, import_util7.HexBlob)(plutusScriptSource.script.code)
|
|
2454
|
+
)
|
|
2455
|
+
)
|
|
2456
|
+
);
|
|
2457
|
+
break;
|
|
2458
|
+
case "V2":
|
|
2459
|
+
this.scriptsProvided.add(
|
|
2460
|
+
Script.newPlutusV2Script(
|
|
2461
|
+
PlutusV2Script.fromCbor(
|
|
2462
|
+
(0, import_util7.HexBlob)(plutusScriptSource.script.code)
|
|
2463
|
+
)
|
|
2464
|
+
)
|
|
2465
|
+
);
|
|
2466
|
+
break;
|
|
2467
|
+
case "V3":
|
|
2468
|
+
this.scriptsProvided.add(
|
|
2469
|
+
Script.newPlutusV3Script(
|
|
2470
|
+
PlutusV3Script.fromCbor(
|
|
2471
|
+
(0, import_util7.HexBlob)(plutusScriptSource.script.code)
|
|
2472
|
+
)
|
|
2473
|
+
)
|
|
2474
|
+
);
|
|
2475
|
+
break;
|
|
2476
|
+
}
|
|
2477
|
+
} else if (plutusScriptSource.type === "Inline") {
|
|
2478
|
+
let referenceInputs = this.txBody.referenceInputs() ?? import_core6.Serialization.CborSet.fromCore([], TransactionInput.fromCore);
|
|
2479
|
+
let referenceInputsList = [...referenceInputs.values()];
|
|
2480
|
+
referenceInputsList.push(
|
|
2481
|
+
new TransactionInput(
|
|
2482
|
+
TransactionId(plutusScriptSource.txHash),
|
|
2483
|
+
BigInt(plutusScriptSource.txIndex)
|
|
2484
|
+
)
|
|
2485
|
+
);
|
|
2486
|
+
referenceInputs.setValues(referenceInputsList);
|
|
2487
|
+
this.txBody.setReferenceInputs(referenceInputs);
|
|
2488
|
+
switch (plutusScriptSource.version) {
|
|
2489
|
+
case "V1": {
|
|
2490
|
+
this.usedLanguages[PlutusLanguageVersion.V1] = true;
|
|
2491
|
+
break;
|
|
2492
|
+
}
|
|
2493
|
+
case "V2": {
|
|
2494
|
+
this.usedLanguages[PlutusLanguageVersion.V2] = true;
|
|
2495
|
+
break;
|
|
2496
|
+
}
|
|
2497
|
+
case "V3": {
|
|
2498
|
+
this.usedLanguages[PlutusLanguageVersion.V3] = true;
|
|
2499
|
+
break;
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
};
|
|
2505
|
+
addAllCollateralInputs = (collaterals) => {
|
|
2506
|
+
for (let i = 0; i < collaterals.length; i++) {
|
|
2507
|
+
this.addCollateralInput(
|
|
2508
|
+
collaterals[i]
|
|
2509
|
+
);
|
|
2510
|
+
}
|
|
2511
|
+
};
|
|
2512
|
+
addCollateralInput = (collateral) => {
|
|
2513
|
+
let cardanoTxIn = new TransactionInput(
|
|
2514
|
+
TransactionId(collateral.txIn.txHash),
|
|
2515
|
+
BigInt(collateral.txIn.txIndex)
|
|
2516
|
+
);
|
|
2517
|
+
const collateralInputs = this.txBody.collateral() ?? import_core6.Serialization.CborSet.fromCore([], TransactionInput.fromCore);
|
|
2518
|
+
const collateralInputsList = [
|
|
2519
|
+
...collateralInputs.values()
|
|
2520
|
+
];
|
|
2521
|
+
if (collateralInputsList.find((input) => {
|
|
2522
|
+
input.index() == cardanoTxIn.index() && input.transactionId == cardanoTxIn.transactionId;
|
|
2523
|
+
})) {
|
|
2524
|
+
throw new Error("Duplicate input added to tx body");
|
|
2525
|
+
}
|
|
2526
|
+
collateralInputsList.push(cardanoTxIn);
|
|
2527
|
+
collateralInputs.setValues(collateralInputsList);
|
|
2528
|
+
const cardanoTxOut = new TransactionOutput(
|
|
2529
|
+
Address.fromBech32(collateral.txIn.address),
|
|
2530
|
+
toValue(collateral.txIn.amount)
|
|
2531
|
+
);
|
|
2532
|
+
this.utxoContext.set(cardanoTxIn, cardanoTxOut);
|
|
2533
|
+
this.txBody.setCollateral(collateralInputs);
|
|
2534
|
+
};
|
|
2535
|
+
setValidityInterval = (validity) => {
|
|
2536
|
+
if (validity.invalidBefore) {
|
|
2537
|
+
this.txBody.setValidityStartInterval(Slot(validity.invalidBefore));
|
|
2538
|
+
}
|
|
2539
|
+
if (validity.invalidHereafter) {
|
|
2540
|
+
this.txBody.setTtl(Slot(validity.invalidHereafter));
|
|
2541
|
+
}
|
|
2542
|
+
};
|
|
2543
|
+
buildWitnessSet = () => {
|
|
2544
|
+
const inputs = this.txBody.inputs();
|
|
2545
|
+
for (let i = 0; i < inputs.size(); i += 1) {
|
|
2546
|
+
const input = inputs.values().at(i);
|
|
2547
|
+
if (input) {
|
|
2548
|
+
let redeemer = this.redeemerContext.get(input);
|
|
2549
|
+
if (redeemer) {
|
|
2550
|
+
redeemer.setIndex(BigInt(i));
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
let redeemers = this.txWitnessSet.redeemers() ?? Redeemers.fromCore([]);
|
|
2555
|
+
let redeemersList = [...redeemers.values()];
|
|
2556
|
+
this.redeemerContext.forEach((redeemer) => {
|
|
2557
|
+
redeemersList.push(redeemer);
|
|
2558
|
+
});
|
|
2559
|
+
redeemers.setValues(redeemersList);
|
|
2560
|
+
this.txWitnessSet.setRedeemers(redeemers);
|
|
2561
|
+
let nativeScripts = this.txWitnessSet.nativeScripts() ?? import_core6.Serialization.CborSet.fromCore([], NativeScript.fromCore);
|
|
2562
|
+
let v1Scripts = this.txWitnessSet.plutusV1Scripts() ?? import_core6.Serialization.CborSet.fromCore([], PlutusV1Script.fromCore);
|
|
2563
|
+
let v2Scripts = this.txWitnessSet.plutusV2Scripts() ?? import_core6.Serialization.CborSet.fromCore([], PlutusV2Script.fromCore);
|
|
2564
|
+
let v3Scripts = this.txWitnessSet.plutusV3Scripts() ?? import_core6.Serialization.CborSet.fromCore([], PlutusV3Script.fromCore);
|
|
2565
|
+
this.scriptsProvided.forEach((script) => {
|
|
2566
|
+
if (script.asNative() !== void 0) {
|
|
2567
|
+
let nativeScriptsList = [...nativeScripts.values()];
|
|
2568
|
+
nativeScriptsList.push(script.asNative());
|
|
2569
|
+
nativeScripts.setValues(nativeScriptsList);
|
|
2570
|
+
} else if (script.asPlutusV1() !== void 0) {
|
|
2571
|
+
let v1ScriptsList = [...v1Scripts.values()];
|
|
2572
|
+
v1ScriptsList.push(script.asPlutusV1());
|
|
2573
|
+
v1Scripts.setValues(v1ScriptsList);
|
|
2574
|
+
} else if (script.asPlutusV2() !== void 0) {
|
|
2575
|
+
let v2ScriptsList = [...v2Scripts.values()];
|
|
2576
|
+
v2ScriptsList.push(script.asPlutusV2());
|
|
2577
|
+
v2Scripts.setValues(v2ScriptsList);
|
|
2578
|
+
} else if (script.asPlutusV3() !== void 0) {
|
|
2579
|
+
let v3ScriptsList = [...v3Scripts.values()];
|
|
2580
|
+
v3ScriptsList.push(script.asPlutusV3());
|
|
2581
|
+
v3Scripts.setValues(v3ScriptsList);
|
|
2582
|
+
}
|
|
2583
|
+
this.txWitnessSet.setNativeScripts(nativeScripts);
|
|
2584
|
+
this.txWitnessSet.setPlutusV1Scripts(v1Scripts);
|
|
2585
|
+
this.txWitnessSet.setPlutusV2Scripts(v2Scripts);
|
|
2586
|
+
this.txWitnessSet.setPlutusV3Scripts(v3Scripts);
|
|
2587
|
+
});
|
|
2588
|
+
let datums = this.txWitnessSet.plutusData() ?? import_core6.Serialization.CborSet.fromCore([], PlutusData.fromCore);
|
|
2589
|
+
this.datumsProvided.forEach((datum) => {
|
|
2590
|
+
let datumsList = [...datums.values()];
|
|
2591
|
+
datumsList.push(datum);
|
|
2592
|
+
datums.setValues(datumsList);
|
|
2593
|
+
});
|
|
2594
|
+
this.txWitnessSet.setPlutusData(datums);
|
|
2595
|
+
let costModelV1 = import_core6.Serialization.CostModel.newPlutusV1(
|
|
2596
|
+
import_common5.DEFAULT_V1_COST_MODEL_LIST
|
|
2597
|
+
);
|
|
2598
|
+
let costModelV2 = import_core6.Serialization.CostModel.newPlutusV2(
|
|
2599
|
+
import_common5.DEFAULT_V2_COST_MODEL_LIST
|
|
2600
|
+
);
|
|
2601
|
+
let costModels = new import_core6.Serialization.Costmdls();
|
|
2602
|
+
if (this.usedLanguages[PlutusLanguageVersion.V1]) {
|
|
2603
|
+
costModels.insert(costModelV1);
|
|
2604
|
+
}
|
|
2605
|
+
if (this.usedLanguages[PlutusLanguageVersion.V2]) {
|
|
2606
|
+
costModels.insert(costModelV2);
|
|
2607
|
+
}
|
|
2608
|
+
if (this.usedLanguages[PlutusLanguageVersion.V3]) {
|
|
2609
|
+
}
|
|
2610
|
+
let scriptDataHash = hashScriptData(
|
|
2611
|
+
costModels,
|
|
2612
|
+
redeemers.size() > 0 ? [...redeemers.values()] : void 0,
|
|
2613
|
+
datums.size() > 0 ? [...datums.values()] : void 0
|
|
2614
|
+
);
|
|
2615
|
+
if (scriptDataHash) {
|
|
2616
|
+
this.txBody.setScriptDataHash(scriptDataHash);
|
|
2617
|
+
}
|
|
2618
|
+
};
|
|
2619
|
+
balanceTx = (changeAddress, numberOfRequiredWitnesses, protocolParams) => {
|
|
2620
|
+
if (changeAddress === "") {
|
|
2621
|
+
throw new Error("Can't balance tx without a change address");
|
|
2622
|
+
}
|
|
2623
|
+
const inputs = this.txBody.inputs().values();
|
|
2624
|
+
let remainingValue = new Value(BigInt(0));
|
|
2625
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
2626
|
+
let input = inputs[i];
|
|
2627
|
+
if (!input) {
|
|
2628
|
+
throw new Error("Invalid input found");
|
|
2629
|
+
}
|
|
2630
|
+
const output = this.utxoContext.get(input);
|
|
2631
|
+
if (!output) {
|
|
2632
|
+
throw new Error(`Unable to resolve input: ${input.toCbor()}`);
|
|
2633
|
+
}
|
|
2634
|
+
remainingValue = mergeValue(remainingValue, output.amount());
|
|
2635
|
+
}
|
|
2636
|
+
const withdrawals = this.txBody.withdrawals();
|
|
2637
|
+
if (withdrawals) {
|
|
2638
|
+
withdrawals.forEach((coin) => {
|
|
2639
|
+
remainingValue = mergeValue(remainingValue, new Value(coin));
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
remainingValue = mergeValue(
|
|
2643
|
+
remainingValue,
|
|
2644
|
+
new Value(BigInt(0), this.txBody.mint())
|
|
2645
|
+
);
|
|
2646
|
+
const currentOutputs = this.txBody.outputs();
|
|
2647
|
+
for (let i = 0; i < currentOutputs.length; i++) {
|
|
2648
|
+
let output = currentOutputs.at(i);
|
|
2649
|
+
if (output) {
|
|
2650
|
+
remainingValue = subValue(remainingValue, output.amount());
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
if (remainingValue.coin() < 0 || !empty(negatives(remainingValue))) {
|
|
2654
|
+
throw new Error(`Not enough funds to satisfy outputs`);
|
|
2655
|
+
}
|
|
2656
|
+
currentOutputs.push(
|
|
2657
|
+
new TransactionOutput(Address.fromBech32(changeAddress), remainingValue)
|
|
2658
|
+
);
|
|
2659
|
+
this.txBody.setOutputs(currentOutputs);
|
|
2660
|
+
this.txBody.setFee(BigInt("10000000"));
|
|
2661
|
+
const dummyTx = this.createDummyTx(numberOfRequiredWitnesses);
|
|
2662
|
+
const fee = protocolParams.minFeeB + dummyTx.toCbor().length / 2 * Number(protocolParams.coinsPerUtxoSize);
|
|
2663
|
+
this.txBody.setFee(BigInt(fee));
|
|
2664
|
+
const changeOutput = currentOutputs.pop();
|
|
2665
|
+
if (!changeOutput) {
|
|
2666
|
+
throw new Error(
|
|
2667
|
+
"Somehow the output length was 0 after attempting to calculate fees"
|
|
2668
|
+
);
|
|
2669
|
+
}
|
|
2670
|
+
changeOutput.amount().setCoin(changeOutput.amount().coin() - BigInt(fee));
|
|
2671
|
+
currentOutputs.push(changeOutput);
|
|
2672
|
+
this.txBody.setOutputs(currentOutputs);
|
|
2673
|
+
};
|
|
2674
|
+
createDummyTx = (numberOfRequiredWitnesses) => {
|
|
2675
|
+
let dummyWitnessSet = new TransactionWitnessSet();
|
|
2676
|
+
const dummyVkeyWitnesses = [];
|
|
2677
|
+
for (let i = 0; i < numberOfRequiredWitnesses; i++) {
|
|
2678
|
+
dummyVkeyWitnesses.push([
|
|
2679
|
+
Ed25519PublicKeyHex2("0".repeat(64)),
|
|
2680
|
+
Ed25519SignatureHex2("0".repeat(128))
|
|
2681
|
+
]);
|
|
2682
|
+
}
|
|
2683
|
+
dummyWitnessSet.setVkeys(
|
|
2684
|
+
import_core6.Serialization.CborSet.fromCore(dummyVkeyWitnesses, VkeyWitness.fromCore)
|
|
2685
|
+
);
|
|
2686
|
+
return new Transaction(this.txBody, dummyWitnessSet);
|
|
2687
|
+
};
|
|
2688
|
+
};
|
|
2689
|
+
|
|
2690
|
+
// src/index.ts
|
|
2691
|
+
var CardanoSDKUtil = __toESM(require("@cardano-sdk/util"), 1);
|
|
2692
|
+
var Crypto3 = __toESM(require("@cardano-sdk/crypto"), 1);
|
|
2693
|
+
var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
|
|
2694
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2695
|
+
0 && (module.exports = {
|
|
2696
|
+
Address,
|
|
2697
|
+
AddressType,
|
|
2698
|
+
AssetFingerprint,
|
|
2699
|
+
AssetId,
|
|
2700
|
+
AssetName,
|
|
2701
|
+
BaseAddress,
|
|
2702
|
+
Bip32PrivateKey,
|
|
2703
|
+
Bip32PrivateKeyHex,
|
|
2704
|
+
Cardano,
|
|
2705
|
+
CardanoSDK,
|
|
2706
|
+
CardanoSDKSerializer,
|
|
2707
|
+
CardanoSDKUtil,
|
|
2708
|
+
CborSet,
|
|
2709
|
+
CborWriter,
|
|
2710
|
+
Certificate,
|
|
2711
|
+
CertificateType,
|
|
2712
|
+
ConstrPlutusData,
|
|
2713
|
+
CoseSign1,
|
|
2714
|
+
CostModel,
|
|
2715
|
+
Costmdls,
|
|
2716
|
+
Credential,
|
|
2717
|
+
CredentialType,
|
|
2718
|
+
Crypto,
|
|
2719
|
+
DRepID,
|
|
2720
|
+
Datum,
|
|
2721
|
+
DatumHash,
|
|
2722
|
+
DatumKind,
|
|
2723
|
+
Ed25519KeyHash,
|
|
2724
|
+
Ed25519KeyHashHex,
|
|
2725
|
+
Ed25519PrivateExtendedKeyHex,
|
|
2726
|
+
Ed25519PrivateNormalKeyHex,
|
|
2727
|
+
Ed25519PublicKey,
|
|
2728
|
+
Ed25519PublicKeyHex,
|
|
2729
|
+
Ed25519Signature,
|
|
2730
|
+
Ed25519SignatureHex,
|
|
2731
|
+
EnterpriseAddress,
|
|
2732
|
+
ExUnits,
|
|
2733
|
+
Hash,
|
|
2734
|
+
Hash28ByteBase16,
|
|
2735
|
+
Hash32ByteBase16,
|
|
2736
|
+
NativeScript,
|
|
2737
|
+
NetworkId,
|
|
2738
|
+
PaymentAddress,
|
|
2739
|
+
PlutusData,
|
|
2740
|
+
PlutusLanguageVersion,
|
|
2741
|
+
PlutusList,
|
|
2742
|
+
PlutusMap,
|
|
2743
|
+
PlutusV1Script,
|
|
2744
|
+
PlutusV2Script,
|
|
2745
|
+
PlutusV3Script,
|
|
2746
|
+
PolicyId,
|
|
2747
|
+
PoolId,
|
|
2748
|
+
Redeemer,
|
|
2749
|
+
RedeemerPurpose,
|
|
2750
|
+
RedeemerTag,
|
|
2751
|
+
Redeemers,
|
|
2752
|
+
RequireAllOf,
|
|
2753
|
+
RequireAnyOf,
|
|
2754
|
+
RequireNOf,
|
|
2755
|
+
RequireSignature,
|
|
2756
|
+
RequireTimeAfter,
|
|
2757
|
+
RequireTimeBefore,
|
|
2758
|
+
RewardAccount,
|
|
2759
|
+
RewardAddress,
|
|
2760
|
+
Script,
|
|
2761
|
+
ScriptHash,
|
|
2762
|
+
ScriptPubkey,
|
|
2763
|
+
Serialization,
|
|
2764
|
+
Slot,
|
|
2765
|
+
StakeDelegation,
|
|
2766
|
+
StakeRegistration,
|
|
2767
|
+
StricaBip32PrivateKey,
|
|
2768
|
+
StricaBip32PublicKey,
|
|
2769
|
+
StricaDecoder,
|
|
2770
|
+
StricaEncoder,
|
|
2771
|
+
StricaPrivateKey,
|
|
2772
|
+
StricaPublicKey,
|
|
2773
|
+
Transaction,
|
|
2774
|
+
TransactionBody,
|
|
2775
|
+
TransactionId,
|
|
2776
|
+
TransactionInput,
|
|
2777
|
+
TransactionOutput,
|
|
2778
|
+
TransactionUnspentOutput,
|
|
2779
|
+
TransactionWitnessSet,
|
|
2780
|
+
Value,
|
|
2781
|
+
VkeyWitness,
|
|
2782
|
+
VrfVkBech32,
|
|
2783
|
+
addressToBech32,
|
|
2784
|
+
assetTypes,
|
|
2785
|
+
buildBaseAddress,
|
|
2786
|
+
buildBip32PrivateKey,
|
|
2787
|
+
buildDRepID,
|
|
2788
|
+
buildEnterpriseAddress,
|
|
2789
|
+
buildKeys,
|
|
2790
|
+
buildRewardAddress,
|
|
2791
|
+
buildScriptPubkey,
|
|
2792
|
+
checkSignature,
|
|
2793
|
+
deserializeAddress,
|
|
2794
|
+
deserializeDataHash,
|
|
2795
|
+
deserializeEd25519KeyHash,
|
|
2796
|
+
deserializeNativeScript,
|
|
2797
|
+
deserializePlutusData,
|
|
2798
|
+
deserializePlutusScript,
|
|
2799
|
+
deserializeScriptHash,
|
|
2800
|
+
deserializeScriptRef,
|
|
2801
|
+
deserializeTx,
|
|
2802
|
+
deserializeTxHash,
|
|
2803
|
+
deserializeTxUnspentOutput,
|
|
2804
|
+
deserializeValue,
|
|
2805
|
+
empty,
|
|
2806
|
+
fromNativeScript,
|
|
2807
|
+
fromScriptRef,
|
|
2808
|
+
fromTxUnspentOutput,
|
|
2809
|
+
fromValue,
|
|
2810
|
+
generateNonce,
|
|
2811
|
+
getCoseKeyFromPublicKey,
|
|
2812
|
+
getPublicKeyFromCoseKey,
|
|
2813
|
+
mergeValue,
|
|
2814
|
+
negateValue,
|
|
2815
|
+
negatives,
|
|
2816
|
+
resolveDataHash,
|
|
2817
|
+
resolveNativeScriptAddress,
|
|
2818
|
+
resolveNativeScriptHash,
|
|
2819
|
+
resolvePaymentKeyHash,
|
|
2820
|
+
resolvePlutusScriptAddress,
|
|
2821
|
+
resolvePlutusScriptHash,
|
|
2822
|
+
resolvePoolId,
|
|
2823
|
+
resolvePrivateKey,
|
|
2824
|
+
resolveRewardAddress,
|
|
2825
|
+
resolveScriptRef,
|
|
2826
|
+
resolveStakeKeyHash,
|
|
2827
|
+
resolveTxHash,
|
|
2828
|
+
signData,
|
|
2829
|
+
subValue,
|
|
2830
|
+
toAddress,
|
|
2831
|
+
toBaseAddress,
|
|
2832
|
+
toEnterpriseAddress,
|
|
2833
|
+
toNativeScript,
|
|
2834
|
+
toPlutusData,
|
|
2835
|
+
toRewardAddress,
|
|
2836
|
+
toScriptRef,
|
|
2837
|
+
toTxUnspentOutput,
|
|
2838
|
+
toValue
|
|
2839
|
+
});
|