@meshsdk/common 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +135 -7
- package/dist/index.d.ts +135 -7
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ge=Object.create;var R=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,Se=Object.prototype.hasOwnProperty;var he=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},X=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of xe(t))!Se.call(e,n)&&n!==r&&R(e,n,{get:()=>t[n],enumerable:!(o=ye(t,n))||o.enumerable});return e};var Te=(e,t,r)=>(r=e!=null?ge(be(e)):{},X(t||!e||!e.__esModule?R(r,"default",{value:e,enumerable:!0}):r,e)),Ae=e=>X(R({},"__esModule",{value:!0}),e);var kt={};he(kt,{AssetFingerprint:()=>de,BigNum:()=>p,CIP68_100:()=>we,CIP68_222:()=>Ue,DEFAULT_PROTOCOL_PARAMETERS:()=>x,DEFAULT_REDEEMER_BUDGET:()=>Re,DEFAULT_V1_COST_MODEL_LIST:()=>Ce,DEFAULT_V2_COST_MODEL_LIST:()=>ve,HARDENED_KEY_START:()=>He,LANGUAGE_VERSIONS:()=>Ie,POLICY_ID_LENGTH:()=>g,SLOT_CONFIG_NETWORK:()=>j,SUPPORTED_CLOCKS:()=>Be,SUPPORTED_HANDLES:()=>Oe,SUPPORTED_LANGUAGE_VIEWS:()=>J,SUPPORTED_OGMIOS_LINKS:()=>Ke,SUPPORTED_TOKENS:()=>Ne,SUPPORTED_WALLETS:()=>Me,UtxoSelection:()=>Y,assetClass:()=>at,assetName:()=>ne,assocMap:()=>H,bool:()=>rt,builtinByteString:()=>te,byteString:()=>S,bytesToHex:()=>se,certificateToObj:()=>Fe,conStr:()=>I,conStr0:()=>u,conStr1:()=>b,conStr2:()=>tt,currencySymbol:()=>K,dict:()=>ct,emptyTxBuilderBody:()=>Qe,experimentalSelectUtxos:()=>z,fromUTF8:()=>ie,fungibleAssetKeys:()=>Le,generateMnemonic:()=>E.generateMnemonic,hashByteString:()=>Q,hexToBytes:()=>ut,hexToString:()=>mt,integer:()=>C,isNetwork:()=>_e,keepRelevant:()=>G,largestFirst:()=>$,largestFirstMultiAsset:()=>W,list:()=>re,mAssetClass:()=>Ge,mBool:()=>Je,mConStr:()=>je,mConStr0:()=>l,mConStr1:()=>A,mConStr2:()=>ze,mMaybeStakingHash:()=>F,mOutputReference:()=>ee,mPlutusBSArrayToString:()=>et,mPubKeyAddress:()=>Ye,mScriptAddress:()=>Xe,mStringToPlutusBSArray:()=>Ze,mTuple:()=>We,mTxOutRef:()=>$e,maybeStakingHash:()=>q,mergeAssets:()=>Ee,metadataStandardKeys:()=>Pe,metadataToCip68:()=>L,mnemonicToEntropy:()=>E.mnemonicToEntropy,outputReference:()=>ae,parseAssetUnit:()=>yt,parsePlutusValueToAssets:()=>Tt,plutusBSArrayToString:()=>nt,policyId:()=>oe,poolMetadataToObj:()=>Z,poolParamsToObj:()=>_,posixTime:()=>it,pubKeyAddress:()=>dt,pubKeyHash:()=>O,relayToObj:()=>V,resolveEpochNo:()=>St,resolveFingerprint:()=>At,resolveLanguageView:()=>ke,resolveSlotNo:()=>bt,resolveTxFees:()=>M,royaltiesStandardKeys:()=>De,scriptAddress:()=>ft,scriptHash:()=>B,slotToBeginUnixTime:()=>xt,stringToBSArray:()=>ot,stringToHex:()=>lt,toBytes:()=>w,toUTF8:()=>gt,tokenName:()=>N,tuple:()=>pt,txOutRef:()=>st,unixTimeToEnclosingSlot:()=>ce,validityRangeToObj:()=>qe,value:()=>ht});module.exports=Ae(kt);var x={epoch:0,coinsPerUtxoSize:4310,priceMem:.0577,priceStep:721e-7,minFeeA:44,minFeeB:155381,keyDeposit:2e6,maxTxSize:16384,maxValSize:5e3,poolDeposit:5e8,maxCollateralInputs:3,decentralisation:0,maxBlockSize:98304,collateralPercent:150,maxBlockHeaderSize:1100,minPoolCost:"340000000",maxTxExMem:"16000000",maxTxExSteps:"10000000000",maxBlockExMem:"80000000",maxBlockExSteps:"40000000000"},M=(e,t=x.minFeeA,r=x.minFeeB)=>(BigInt(t)*BigInt(e)+BigInt(r)).toString();var Me=["begin","eternl","flint","lace","nami","nufi","gerowallet","typhoncip30","vespr","yoroi"];var Ce=[205665,812,1,1,1e3,571,0,1,1e3,24177,4,1,1e3,32,117366,10475,4,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,100,100,23e3,100,19537,32,175354,32,46417,4,221973,511,0,1,89141,32,497525,14068,4,2,196500,453240,220,0,1,1,1e3,28662,4,2,245e3,216773,62,1,1060367,12586,1,208512,421,1,187e3,1e3,52998,1,80436,32,43249,32,1e3,32,80556,1,57667,4,1e3,10,197145,156,1,197145,156,1,204924,473,1,208896,511,1,52467,32,64832,32,65493,32,22558,32,16563,32,76511,32,196500,453240,220,0,1,1,69522,11687,0,1,60091,32,196500,453240,220,0,1,1,196500,453240,220,0,1,1,806990,30482,4,1927926,82523,4,265318,0,4,0,85931,32,205665,812,1,1,41182,32,212342,32,31220,32,32696,32,43357,32,32247,32,38314,32,57996947,18975,10],ve=[205665,812,1,1,1e3,571,0,1,1e3,24177,4,1,1e3,32,117366,10475,4,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,100,100,23e3,100,19537,32,175354,32,46417,4,221973,511,0,1,89141,32,497525,14068,4,2,196500,453240,220,0,1,1,1e3,28662,4,2,245e3,216773,62,1,1060367,12586,1,208512,421,1,187e3,1e3,52998,1,80436,32,43249,32,1e3,32,80556,1,57667,4,1e3,10,197145,156,1,197145,156,1,204924,473,1,208896,511,1,52467,32,64832,32,65493,32,22558,32,16563,32,76511,32,196500,453240,220,0,1,1,69522,11687,0,1,60091,32,196500,453240,220,0,1,1,196500,453240,220,0,1,1,1159724,392670,0,2,806990,30482,4,1927926,82523,4,265318,0,4,0,85931,32,205665,812,1,1,41182,32,212342,32,31220,32,32696,32,43357,32,32247,32,38314,32,35892428,10,57996947,18975,10,38887044,32947,10];var J={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}},ke=(e,t)=>J[e][t];var Re={mem:7e6,steps:3e9},g=56,Ie={V1:"V1",V2:"V2",V3:"V3"},He=2147483648,Be={testnet:["74","1598400","1595967616","432000"],preview:["183","15811222","1682467200","86400"],preprod:["65","26438400","1682121600","432000"],mainnet:["208","4492800","1596059091","432000"]},Oe={0:"8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",1:"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"},Ke={mainnet:"wss://ogmios-api.mainnet.dandelion.link",preprod:"wss://ogmios-api.iohk-preprod.dandelion.link",preview:"__TBD_SOON_TM__",testnet:"wss://ogmios-api.testnet.dandelion.link"},Ne={LQ:"da8c30857834c6ae7203935b89278c532b3995245295456f993e1d244c51",MIN:"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e",NTX:"edfd7a1d77bcb8b884c474bdc92a16002d1fb720e454fa6e993444794e5458",iBTC:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069425443",iETH:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069455448",iUSD:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069555344",MILK:"8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa4d494c4b",AGIX:"f43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc53541474958",MELD:"6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d104d454c44",INDY:"533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0494e4459",CLAY:"38ad9dc3aec6a2f38e220142b9aa6ade63ebe71f65e7cc2b7d8a8535434c4159",MCOS:"6f46e1304b16d884c85c62fb0eef35028facdc41aaa0fd319a152ed64d434f53",DING:"ce5b9e0f8a88255b65f2e4d065c6e716e9fa9a8a86dfb86423dd1ac044494e47",GERO:"10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b64745524f",NMKR:"5dac8536653edc12f6f5e1045d8164b9f59998d3bdc300fc928434894e4d4b52",PAVIA:"884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903ae5041564941",HOSKY:"a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235484f534b59",YUMMI:"078eafce5cd7edafdf63900edef2c1ea759e77f30ca81d6bbdeec92479756d6d69",C3:"8e51398904a5d3fc129fbf4f1589701de23c7824d5c90fdb9490e15a434841524c4933",GIMBAL:"2b0a04a7b60132b1805b296c7fcb3b217ff14413991bf76f72663c3067696d62616c",SUNDAE:"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145",GREENS:"4623ab311b7d982d8d26fcbe1a9439ca56661aafcdcd8d8a0ef31fd6475245454e53",GENS:"dda5fdb1002f7389b33e036b6afee82a8189becb6cba852e8b79b4fb0014df1047454e53",SOCIETY:"25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459",DJED:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344",SHEN:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344",WMT:"1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e776f726c646d6f62696c65746f6b656e",COPI:"b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0436f726e75636f70696173205b76696120436861696e506f72742e696f5d"},we=e=>`000643b0${e}`,Ue=e=>`000de140${e}`;var Ee=e=>{let t=[];return e.forEach(r=>{let o=t.find(n=>n.unit===r.unit);o?o.quantity=(BigInt(o.quantity)+BigInt(r.quantity)).toString():t.push(r)}),t};var De=["rate","address"],Pe=["name","image","mediaType","description","instagram","twitter","discord","website"],Le=["ticker","decimals"],L=e=>{switch(typeof e){case"object":if(e instanceof Array)return e.map(o=>L(o));let t=new Map;return Object.keys(e).forEach(o=>{t.set(o,L(e[o]))}),{alternative:0,fields:[t,1]};default:return e}};var Ve=["testnet","preview","preprod","mainnet"],_e=e=>Ve.includes(e);var V=e=>{switch(e.type){case"SingleHostAddr":return{singleHostAddr:{ipv4:e.IPV4,ipv6:e.IPV6,port:e.port}};case"SingleHostName":return{singleHostName:{hostname:e.domainName,port:e.port}};case"MultiHostName":return{multiHostName:{dnsName:e.domainName}}}};var _=e=>({vrfKeyHash:e.vrfKeyHash,operator:e.operator,pledge:e.pledge,cost:e.cost,margin:e.margin,relays:e.relays.map(t=>V(t)),owners:e.owners,rewardAddress:e.rewardAddress,metadata:e.metadata?Z(e.metadata):void 0}),Z=e=>({url:e.URL,metadata:e.hash});var Fe=e=>{switch(e.type){case"RegisterPool":return{registerPool:{poolParams:_(e.poolParams)}};case"RegisterStake":return{registerStake:{stakeKeyHash:e.stakeKeyHash}};case"DelegateStake":return{delegateStake:{stakeKeyHash:e.stakeKeyHash,poolId:e.poolId}};case"DeregisterStake":return{deregisterStake:{stakeKeyHash:e.stakeKeyHash}};case"RetirePool":return{retirePool:{poolId:e.poolId,epoch:e.epoch}};case"VoteDelegation":return{voteDelegation:{stakeKeyHash:e.stakeKeyHash,drep:e.drep}};case"StakeAndVoteDelegation":return{stakeAndVoteDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,drep:e.drep}};case"StakeRegistrationAndDelegation":return{stakeRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,coin:e.coin}};case"VoteRegistrationAndDelegation":return{voteRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,drep:e.drep,coin:e.coin}};case"StakeVoteRegistrationAndDelegation":return{stakeVoteRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,drep:e.drep,coin:e.coin}};case"CommitteeHotAuth":return{committeeHotAuth:{committeeColdKeyHash:e.committeeColdKeyHash,committeeHotKeyHash:e.committeeHotKeyHash}};case"CommitteeColdResign":return{committeeColdResign:{committeeColdKeyHash:e.committeeColdKeyHash,anchor:e.anchor??null}};case"DRepRegistration":return{dRepRegistration:{votingKeyHash:e.votingKeyHash,coin:e.coin,anchor:e.anchor??null}};case"DRepDeregistration":return{dRepDeregistration:{votingKeyHash:e.votingKeyHash,coin:e.coin}};case"DRepUpdate":return{dRepUpdate:{votingKeyHash:e.votingKeyHash,anchor:e.anchor}}}};var Qe=()=>({inputs:[],outputs:[],extraInputs:[],collaterals:[],requiredSignatures:[],referenceInputs:[],mints:[],changeAddress:"",metadata:[],validityRange:{},certificates:[],withdrawals:[],signingKey:[],selectionConfig:{threshold:"5000000",strategy:"experimental",includeTxFees:!0}}),qe=e=>({invalidBefore:e.invalidBefore??null,invalidHereafter:e.invalidHereafter??null});var je=(e,t)=>({alternative:e,fields:t}),l=e=>({alternative:0,fields:e}),A=e=>({alternative:1,fields:e}),ze=e=>({alternative:2,fields:e});var Ge=(e,t)=>{if(e.length!==56&&e!=="")throw new Error(`Invalid policy id for [${e}] - should be ${g} bytes long or empty string for lovelace`);if(t.length>64)throw new Error(`Invalid asset name for [${t}] - should be less than 32 bytes (64 hex length) long`);return l([e,t])},ee=(e,t)=>{if(e.length!==64)throw new Error("Invalid transaction hash - should be 32 bytes long");return l([l([e]),t])},$e=(e,t)=>ee(e,t),We=(e,t)=>[e,t];var F=(e,t=!1)=>e===""?A([]):t?l([l([A([e])])]):l([l([l([e])])]),Ye=(e,t)=>l([{alternative:0,fields:[e]},F(t||"")]),Xe=(e,t)=>l([{alternative:1,fields:[e]},F(t||"")]);var Je=e=>e?A([]):l([]),Ze=e=>{let t=[];for(let r=0;r<e.length;r+=64){let o=e.substring(r,r+64);t.push(o)}return t},et=e=>e.join("");var I=(e,t)=>{if(!Array.isArray(t))throw new Error("fields of a constructor must be an array");return{constructor:e,fields:t}},u=e=>I(0,e),b=e=>I(1,e),tt=e=>I(2,e);var rt=e=>e?b([]):u([]),te=e=>S(e),S=e=>{if(e.length%2!==0)throw new Error("Invalid hex string - odd length: "+e);if(!/^[0-9a-fA-F]*$/.test(e))throw new Error("Invalid hex string - non-hex string character: "+e);return{bytes:e}},C=e=>({int:e}),re=(e,t=!0)=>(t&&e.forEach(r=>{if(typeof r!="object")throw new Error("List item of JSON Cardano data type must be an object - "+r)}),{list:e}),ot=e=>re((r=>{let o=[];for(let n=0;n<r.length;n+=64){let s=r.substring(n,n+64);o.push(s)}return o})(e).map(te)),nt=e=>e.list.map(t=>t.bytes).join(""),H=(e,t=!0)=>({map:e.map(([r,o])=>{if(t&&(typeof r!="object"||typeof o!="object"))throw new Error(`Map item of JSON Cardano data type must be an object - ${r}, ${o}`);return{k:r,v:o}})});var Q=e=>{if(e.length!==56)throw new Error(`Invalid hash for [${e}] - should be 56 bytes long`);return S(e)},B=e=>Q(e),O=e=>Q(e),oe=e=>{if(e.length!==g&&e!=="")throw new Error(`Invalid policy id for [${e}] - should be ${g} bytes long or empty string for lovelace`);return S(e)},K=e=>oe(e),ne=e=>{if(e.length>64)throw new Error(`Invalid asset name for [${e}] - should be less than 32 bytes (64 hex length) long`);return S(e)},N=e=>ne(e),at=(e,t)=>u([K(e),N(t)]),ae=(e,t)=>{if(e.length!==64)throw new Error("Invalid transaction hash - should be 32 bytes long");return u([u([S(e)]),C(t)])},st=(e,t)=>ae(e,t),it=e=>({int:e}),ct=e=>({map:e.map(([t,r])=>({k:t,v:r}))}),pt=(e,t)=>({list:[e,t]});var q=(e,t=!1)=>e===""?b([]):t?u([u([b([B(e)])])]):u([u([u([O(e)])])]),dt=(e,t,r=!1)=>u([u([O(e)]),q(t||"",r)]),ft=(e,t,r=!1)=>u([b([B(e)]),q(t||"",r)]);var se=e=>Buffer.from(e).toString("hex"),ut=e=>Buffer.from(e,"hex"),lt=e=>Buffer.from(e,"utf8").toString("hex"),mt=e=>Buffer.from(e,"hex").toString("utf8"),w=e=>e.length%2===0&&/^[0-9A-F]*$/i.test(e)?Buffer.from(e,"hex"):Buffer.from(e,"utf-8"),ie=e=>e.length%2===0&&/^[0-9A-F]*$/i.test(e)?e:se(Buffer.from(e,"utf-8")),gt=e=>Buffer.from(e,"hex").toString("utf-8"),yt=e=>{let t=e.slice(0,g),r=e.includes(".")?ie(e.split(".")[1]):e.slice(g);return{policyId:t,assetName:r}};var j={mainnet:{zeroTime:1596059091e3,zeroSlot:4492800,slotLength:1e3,startEpoch:208,epochLength:432e3},preview:{zeroTime:1666656e6,zeroSlot:0,slotLength:1e3,startEpoch:183,epochLength:86400},preprod:{zeroTime:16540416e5+1728e6,zeroSlot:86400,slotLength:1e3,startEpoch:65,epochLength:432e3},testnet:{zeroTime:0,zeroSlot:0,slotLength:0,startEpoch:0,epochLength:0}},xt=(e,t)=>{let r=(e-t.zeroSlot)*t.slotLength;return t.zeroTime+r},ce=(e,t)=>{let r=e-t.zeroTime;return Math.floor(r/t.slotLength)+t.zeroSlot},bt=(e,t=Date.now())=>ce(t,j[e]).toString(),St=(e,t=Date.now())=>{let r=j[e],n=(BigInt(t)/1000n-BigInt(r.zeroTime))/BigInt(r.epochLength)+BigInt(r.startEpoch);return Number(n)};var ht=e=>{let t=[],r={};return e.forEach(o=>{let n=o.unit.replace("lovelace",""),s=n.slice(0,56)||"",d=n.slice(56)||"";r[s]||(r[s]={}),r[s][d]?r[s][d]+=Number(o.quantity):r[s][d]=Number(o.quantity)}),Object.keys(r).forEach(o=>{let n=K(o),s=Object.keys(r[o]).map(i=>[N(i),C(r[o][i])]),d=H(s);t.push([n,d])}),H(t)},Tt=e=>{let t=[];return e.map.forEach(r=>{let o=r.k.bytes;r.v.map.forEach(n=>{let s=n.k.bytes,d=n.v.int.toString(),i=o+s,f=i===""?"lovelace":i;t.push({unit:f,quantity:d})})}),t};var p=class e{value;constructor(t){this.value=BigInt(t)}divFloor(t){return this.value=this.value/t.value,this}checkedMul(t){return this.value*=t.value,this}checkedAdd(t){return this.value+=t.value,this}checkedSub(t){return this.value-=t.value,this}clampedSub(t){let r=this.value-t.value;return this.value=r<0n?0n:r,this}lessThan(t){return this.value<t.value}compare(t){return this.value===t.value?0:this.value<t.value?-1:1}static new=t=>new e(t);toString(){return this.value.toString()}};var pe=Te(require("@emurgo/cip14-js"),1);var de=pe.default,At=(e,t)=>de.default.fromParts(w(e),w(t)).fingerprint();var z=(e,t,r)=>{let o=new Map(e);o.set("lovelace",String(Number(o.get("lovelace")||0)+Number(r)));let n=new Map;for(let a=0;a<t.length;a++)n.set(a,t[a]);let s=new Set,d=new Set,i=new Set,f=new Set,T=new Set;for(let a=0;a<t.length;a++)switch(t[a].output.amount.length){case 1:{d.add(a);break}case 2:{i.add(a);break}case 3:{f.add(a);break}default:{T.add(a);break}}let y=(a,c,m)=>{let D=n.get(a);if(!D)return;let me=Mt(D,c);if(Number(me)>0){s.add(a),m.delete(a);for(let P of D.output.amount)o.set(P.unit,String(Number(o.get(P.unit))-Number(P.quantity)))}};for(let a of o.keys())if(a!="lovelace"){for(let c of i){let m=o.get(a);if(!m||Number(m)<=0)break;y(c,a,i)}for(let c of f){let m=o.get(a);if(!m||Number(m)<=0)break;y(c,a,f)}for(let c of T){let m=o.get(a);if(!m||Number(m)<=0)break;y(c,a,T)}}for(let a of d){let c=o.get("lovelace");if(!c||Number(c)<=0)break;y(a,"lovelace",d)}for(let a of i){let c=o.get("lovelace");if(!c||Number(c)<=0)break;y(a,"lovelace",i)}for(let a of f){let c=o.get("lovelace");if(!c||Number(c)<=0)break;y(a,"lovelace",f)}for(let a of T){let c=o.get("lovelace");if(!c||Number(c)<=0)break;y(a,"lovelace",T)}for(let a of o.keys())if(Number(o.get(a))>0)return console.log("Insufficient funds for",a),console.log("Remaining quantity",Number(o.get(a))),[];let k=[];for(let a of s){let c=n.get(a);c&&k.push(c)}return k},Mt=(e,t)=>{for(let r of e.output.amount)if(r.unit==t)return r.quantity;return"0"};var Ct=(e,t)=>Array.from(t,r=>({unit:r[0],quantity:p.new(r[1])})).every(r=>e.filter(o=>o.output.amount.find(n=>n.unit===r.unit)!==void 0).reduce((o,n)=>{let s=n.output.amount.reduce((d,i)=>d.checkedAdd(p.new(r.unit===i.unit?i.quantity:"0")),p.new("0"));return o.checkedAdd(s)},p.new("0")).lessThan(r.quantity)===!1),v=(e,t)=>{let r=p.new(e.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0");return p.new(t.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0").compare(r)},fe=e=>{let{maxTxSize:t,minFeeA:r,minFeeB:o}=e;return p.new(M(t,r,o))},U=e=>e.output.amount.length>1,ue=e=>e.reduce((t,r)=>{let o=r.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0";return t.checkedAdd(p.new(o))},p.new("0")),le=(e,t)=>{let r=t.sort(v);return h(r,new Map([["lovelace",e]]))},h=(e,t,r=[])=>e.length===0||Ct(r,t)?r:vt(e[0],t)?h(e.slice(1),t,[...r,e[0]]):h(e.slice(1),t,r),vt=(e,t)=>Array.from(t.keys()).some(r=>e.output.amount.find(o=>o.unit===r)!==void 0);var G=(e,t,r="5000000")=>{let o=p.new(e.get("lovelace")??"0").checkedAdd(p.new(r)),n=t.filter(i=>i.output.amount.filter(f=>f.unit!=="lovelace").some(f=>e.has(f.unit))),s=ue(n);return[...s.lessThan(o)?le(o.clampedSub(s).toString(),t.filter(i=>!n.some(f=>f.input.txHash===i.input.txHash&&f.input.outputIndex===i.input.outputIndex))):[],...n]};var $=(e,t,r=!1,{maxTxSize:o,minFeeA:n,minFeeB:s}=x)=>{let d=t.filter(k=>U(k)===!1).sort(v),i=p.new(M(o,n,s)),f=r?p.new(e).checkedAdd(i).toString():e;return h(d,new Map([["lovelace",f]]))};var W=(e,t,r=!1,o=x)=>{let n=t.filter(U).sort(v),s=fe(o),d=e.get("lovelace")??"0",i=r?p.new(d).checkedAdd(s).toString():d;return e.set("lovelace",i),h(n,e)};var Y=class{threshold;includeTxFees;constructor(t="5000000",r=!0){this.threshold=t,this.includeTxFees=r}largestFirst(t,r){let o=t.get("lovelace")??"0",n=BigInt(o)+BigInt(this.threshold);return $(n.toString(),r,this.includeTxFees)}keepRelevant(t,r){return G(t,r,this.threshold)}largestFirstMultiAsset(t,r){let o=t.get("lovelace")??"0";return t.set("lovelace",(BigInt(o)+BigInt(this.threshold)).toString()),W(t,r,this.includeTxFees)}experimental(t,r){return z(t,r,this.threshold)}};var E=require("bip39");0&&(module.exports={AssetFingerprint,BigNum,CIP68_100,CIP68_222,DEFAULT_PROTOCOL_PARAMETERS,DEFAULT_REDEEMER_BUDGET,DEFAULT_V1_COST_MODEL_LIST,DEFAULT_V2_COST_MODEL_LIST,HARDENED_KEY_START,LANGUAGE_VERSIONS,POLICY_ID_LENGTH,SLOT_CONFIG_NETWORK,SUPPORTED_CLOCKS,SUPPORTED_HANDLES,SUPPORTED_LANGUAGE_VIEWS,SUPPORTED_OGMIOS_LINKS,SUPPORTED_TOKENS,SUPPORTED_WALLETS,UtxoSelection,assetClass,assetName,assocMap,bool,builtinByteString,byteString,bytesToHex,certificateToObj,conStr,conStr0,conStr1,conStr2,currencySymbol,dict,emptyTxBuilderBody,experimentalSelectUtxos,fromUTF8,fungibleAssetKeys,generateMnemonic,hashByteString,hexToBytes,hexToString,integer,isNetwork,keepRelevant,largestFirst,largestFirstMultiAsset,list,mAssetClass,mBool,mConStr,mConStr0,mConStr1,mConStr2,mMaybeStakingHash,mOutputReference,mPlutusBSArrayToString,mPubKeyAddress,mScriptAddress,mStringToPlutusBSArray,mTuple,mTxOutRef,maybeStakingHash,mergeAssets,metadataStandardKeys,metadataToCip68,mnemonicToEntropy,outputReference,parseAssetUnit,parsePlutusValueToAssets,plutusBSArrayToString,policyId,poolMetadataToObj,poolParamsToObj,posixTime,pubKeyAddress,pubKeyHash,relayToObj,resolveEpochNo,resolveFingerprint,resolveLanguageView,resolveSlotNo,resolveTxFees,royaltiesStandardKeys,scriptAddress,scriptHash,slotToBeginUnixTime,stringToBSArray,stringToHex,toBytes,toUTF8,tokenName,tuple,txOutRef,unixTimeToEnclosingSlot,validityRangeToObj,value});
|
|
1
|
+
"use strict";var ye=Object.create;var B=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,Se=Object.prototype.hasOwnProperty;var Te=(e,t)=>{for(var r in t)B(e,r,{get:t[r],enumerable:!0})},J=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of be(t))!Se.call(e,n)&&n!==r&&B(e,n,{get:()=>t[n],enumerable:!(o=xe(t,n))||o.enumerable});return e};var Ae=(e,t,r)=>(r=e!=null?ye(he(e)):{},J(t||!e||!e.__esModule?B(r,"default",{value:e,enumerable:!0}):r,e)),Me=e=>J(B({},"__esModule",{value:!0}),e);var kt={};Te(kt,{AssetFingerprint:()=>de,BigNum:()=>i,CIP68_100:()=>Ue,CIP68_222:()=>Ee,DEFAULT_PROTOCOL_PARAMETERS:()=>b,DEFAULT_REDEEMER_BUDGET:()=>Be,DEFAULT_V1_COST_MODEL_LIST:()=>Ce,DEFAULT_V2_COST_MODEL_LIST:()=>Ie,HARDENED_KEY_START:()=>Re,LANGUAGE_VERSIONS:()=>Oe,MeshValue:()=>C,POLICY_ID_LENGTH:()=>g,SLOT_CONFIG_NETWORK:()=>z,SUPPORTED_CLOCKS:()=>He,SUPPORTED_HANDLES:()=>Ke,SUPPORTED_LANGUAGE_VIEWS:()=>Z,SUPPORTED_OGMIOS_LINKS:()=>Ne,SUPPORTED_TOKENS:()=>we,SUPPORTED_WALLETS:()=>ve,UtxoSelection:()=>X,assetClass:()=>st,assetName:()=>ae,assocMap:()=>R,bool:()=>ot,builtinByteString:()=>re,byteString:()=>S,bytesToHex:()=>ie,certificateToObj:()=>qe,conStr:()=>O,conStr0:()=>f,conStr1:()=>h,conStr2:()=>rt,currencySymbol:()=>N,dict:()=>pt,emptyTxBuilderBody:()=>Qe,experimentalSelectUtxos:()=>G,fromUTF8:()=>ce,fungibleAssetKeys:()=>Le,generateMnemonic:()=>D.generateMnemonic,hashByteString:()=>Q,hexToBytes:()=>lt,hexToString:()=>gt,integer:()=>v,isNetwork:()=>Fe,keepRelevant:()=>$,largestFirst:()=>W,largestFirstMultiAsset:()=>Y,list:()=>oe,mAssetClass:()=>$e,mBool:()=>Ze,mConStr:()=>ze,mConStr0:()=>l,mConStr1:()=>A,mConStr2:()=>Ge,mMaybeStakingHash:()=>q,mOutputReference:()=>te,mPlutusBSArrayToString:()=>tt,mPubKeyAddress:()=>Xe,mScriptAddress:()=>Je,mStringToPlutusBSArray:()=>et,mTuple:()=>Ye,mTxOutRef:()=>We,mValue:()=>Mt,maybeStakingHash:()=>j,mergeAssets:()=>De,metadataStandardKeys:()=>Ve,metadataToCip68:()=>L,mnemonicToEntropy:()=>D.mnemonicToEntropy,outputReference:()=>se,parseAssetUnit:()=>xt,plutusBSArrayToString:()=>at,policyId:()=>ne,poolMetadataToObj:()=>ee,poolParamsToObj:()=>F,posixTime:()=>ct,pubKeyAddress:()=>dt,pubKeyHash:()=>K,relayToObj:()=>_,resolveEpochNo:()=>St,resolveFingerprint:()=>Tt,resolveLanguageView:()=>ke,resolveSlotNo:()=>ht,resolveTxFees:()=>M,royaltiesStandardKeys:()=>Pe,scriptAddress:()=>ft,scriptHash:()=>H,slotToBeginUnixTime:()=>bt,stringToBSArray:()=>nt,stringToHex:()=>mt,toBytes:()=>U,toUTF8:()=>yt,tokenName:()=>w,tuple:()=>ut,txOutRef:()=>it,unixTimeToEnclosingSlot:()=>pe,validityRangeToObj:()=>je,value:()=>At});module.exports=Me(kt);var b={epoch:0,coinsPerUtxoSize:4310,priceMem:.0577,priceStep:721e-7,minFeeA:44,minFeeB:155381,keyDeposit:2e6,maxTxSize:16384,maxValSize:5e3,poolDeposit:5e8,maxCollateralInputs:3,decentralisation:0,maxBlockSize:98304,collateralPercent:150,maxBlockHeaderSize:1100,minPoolCost:"340000000",maxTxExMem:"16000000",maxTxExSteps:"10000000000",maxBlockExMem:"80000000",maxBlockExSteps:"40000000000"},M=(e,t=b.minFeeA,r=b.minFeeB)=>(BigInt(t)*BigInt(e)+BigInt(r)).toString();var ve=["begin","eternl","flint","lace","nami","nufi","gerowallet","typhoncip30","vespr","yoroi"];var Ce=[205665,812,1,1,1e3,571,0,1,1e3,24177,4,1,1e3,32,117366,10475,4,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,100,100,23e3,100,19537,32,175354,32,46417,4,221973,511,0,1,89141,32,497525,14068,4,2,196500,453240,220,0,1,1,1e3,28662,4,2,245e3,216773,62,1,1060367,12586,1,208512,421,1,187e3,1e3,52998,1,80436,32,43249,32,1e3,32,80556,1,57667,4,1e3,10,197145,156,1,197145,156,1,204924,473,1,208896,511,1,52467,32,64832,32,65493,32,22558,32,16563,32,76511,32,196500,453240,220,0,1,1,69522,11687,0,1,60091,32,196500,453240,220,0,1,1,196500,453240,220,0,1,1,806990,30482,4,1927926,82523,4,265318,0,4,0,85931,32,205665,812,1,1,41182,32,212342,32,31220,32,32696,32,43357,32,32247,32,38314,32,57996947,18975,10],Ie=[205665,812,1,1,1e3,571,0,1,1e3,24177,4,1,1e3,32,117366,10475,4,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,100,100,23e3,100,19537,32,175354,32,46417,4,221973,511,0,1,89141,32,497525,14068,4,2,196500,453240,220,0,1,1,1e3,28662,4,2,245e3,216773,62,1,1060367,12586,1,208512,421,1,187e3,1e3,52998,1,80436,32,43249,32,1e3,32,80556,1,57667,4,1e3,10,197145,156,1,197145,156,1,204924,473,1,208896,511,1,52467,32,64832,32,65493,32,22558,32,16563,32,76511,32,196500,453240,220,0,1,1,69522,11687,0,1,60091,32,196500,453240,220,0,1,1,196500,453240,220,0,1,1,1159724,392670,0,2,806990,30482,4,1927926,82523,4,265318,0,4,0,85931,32,205665,812,1,1,41182,32,212342,32,31220,32,32696,32,43357,32,32247,32,38314,32,35892428,10,57996947,18975,10,38887044,32947,10];var Z={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}},ke=(e,t)=>Z[e][t];var Be={mem:7e6,steps:3e9},g=56,Oe={V1:"V1",V2:"V2",V3:"V3"},Re=2147483648,He={testnet:["74","1598400","1595967616","432000"],preview:["183","15811222","1682467200","86400"],preprod:["65","26438400","1682121600","432000"],mainnet:["208","4492800","1596059091","432000"]},Ke={0:"8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",1:"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"},Ne={mainnet:"wss://ogmios-api.mainnet.dandelion.link",preprod:"wss://ogmios-api.iohk-preprod.dandelion.link",preview:"__TBD_SOON_TM__",testnet:"wss://ogmios-api.testnet.dandelion.link"},we={LQ:"da8c30857834c6ae7203935b89278c532b3995245295456f993e1d244c51",MIN:"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e",NTX:"edfd7a1d77bcb8b884c474bdc92a16002d1fb720e454fa6e993444794e5458",iBTC:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069425443",iETH:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069455448",iUSD:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069555344",MILK:"8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa4d494c4b",AGIX:"f43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc53541474958",MELD:"6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d104d454c44",INDY:"533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0494e4459",CLAY:"38ad9dc3aec6a2f38e220142b9aa6ade63ebe71f65e7cc2b7d8a8535434c4159",MCOS:"6f46e1304b16d884c85c62fb0eef35028facdc41aaa0fd319a152ed64d434f53",DING:"ce5b9e0f8a88255b65f2e4d065c6e716e9fa9a8a86dfb86423dd1ac044494e47",GERO:"10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b64745524f",NMKR:"5dac8536653edc12f6f5e1045d8164b9f59998d3bdc300fc928434894e4d4b52",PAVIA:"884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903ae5041564941",HOSKY:"a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235484f534b59",YUMMI:"078eafce5cd7edafdf63900edef2c1ea759e77f30ca81d6bbdeec92479756d6d69",C3:"8e51398904a5d3fc129fbf4f1589701de23c7824d5c90fdb9490e15a434841524c4933",GIMBAL:"2b0a04a7b60132b1805b296c7fcb3b217ff14413991bf76f72663c3067696d62616c",SUNDAE:"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145",GREENS:"4623ab311b7d982d8d26fcbe1a9439ca56661aafcdcd8d8a0ef31fd6475245454e53",GENS:"dda5fdb1002f7389b33e036b6afee82a8189becb6cba852e8b79b4fb0014df1047454e53",SOCIETY:"25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459",DJED:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344",SHEN:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344",WMT:"1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e776f726c646d6f62696c65746f6b656e",COPI:"b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0436f726e75636f70696173205b76696120436861696e506f72742e696f5d"},Ue=e=>`000643b0${e}`,Ee=e=>`000de140${e}`;var De=e=>{let t=[];return e.forEach(r=>{let o=t.find(n=>n.unit===r.unit);o?o.quantity=(BigInt(o.quantity)+BigInt(r.quantity)).toString():t.push(r)}),t};var Pe=["rate","address"],Ve=["name","image","mediaType","description","instagram","twitter","discord","website"],Le=["ticker","decimals"],L=e=>{switch(typeof e){case"object":if(e instanceof Array)return e.map(o=>L(o));let t=new Map;return Object.keys(e).forEach(o=>{t.set(o,L(e[o]))}),{alternative:0,fields:[t,1]};default:return e}};var _e=["testnet","preview","preprod","mainnet"],Fe=e=>_e.includes(e);var _=e=>{switch(e.type){case"SingleHostAddr":return{singleHostAddr:{ipv4:e.IPV4,ipv6:e.IPV6,port:e.port}};case"SingleHostName":return{singleHostName:{hostname:e.domainName,port:e.port}};case"MultiHostName":return{multiHostName:{dnsName:e.domainName}}}};var F=e=>({vrfKeyHash:e.vrfKeyHash,operator:e.operator,pledge:e.pledge,cost:e.cost,margin:e.margin,relays:e.relays.map(t=>_(t)),owners:e.owners,rewardAddress:e.rewardAddress,metadata:e.metadata?ee(e.metadata):void 0}),ee=e=>({url:e.URL,metadata:e.hash});var qe=e=>{switch(e.type){case"RegisterPool":return{registerPool:{poolParams:F(e.poolParams)}};case"RegisterStake":return{registerStake:{stakeKeyHash:e.stakeKeyHash}};case"DelegateStake":return{delegateStake:{stakeKeyHash:e.stakeKeyHash,poolId:e.poolId}};case"DeregisterStake":return{deregisterStake:{stakeKeyHash:e.stakeKeyHash}};case"RetirePool":return{retirePool:{poolId:e.poolId,epoch:e.epoch}};case"VoteDelegation":return{voteDelegation:{stakeKeyHash:e.stakeKeyHash,drep:e.drep}};case"StakeAndVoteDelegation":return{stakeAndVoteDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,drep:e.drep}};case"StakeRegistrationAndDelegation":return{stakeRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,coin:e.coin}};case"VoteRegistrationAndDelegation":return{voteRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,drep:e.drep,coin:e.coin}};case"StakeVoteRegistrationAndDelegation":return{stakeVoteRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,drep:e.drep,coin:e.coin}};case"CommitteeHotAuth":return{committeeHotAuth:{committeeColdKeyHash:e.committeeColdKeyHash,committeeHotKeyHash:e.committeeHotKeyHash}};case"CommitteeColdResign":return{committeeColdResign:{committeeColdKeyHash:e.committeeColdKeyHash,anchor:e.anchor??null}};case"DRepRegistration":return{dRepRegistration:{votingKeyHash:e.votingKeyHash,coin:e.coin,anchor:e.anchor??null}};case"DRepDeregistration":return{dRepDeregistration:{votingKeyHash:e.votingKeyHash,coin:e.coin}};case"DRepUpdate":return{dRepUpdate:{votingKeyHash:e.votingKeyHash,anchor:e.anchor}}}};var Qe=()=>({inputs:[],outputs:[],extraInputs:[],collaterals:[],requiredSignatures:[],referenceInputs:[],mints:[],changeAddress:"",metadata:[],validityRange:{},certificates:[],withdrawals:[],signingKey:[],selectionConfig:{threshold:"5000000",strategy:"experimental",includeTxFees:!0}}),je=e=>({invalidBefore:e.invalidBefore??null,invalidHereafter:e.invalidHereafter??null});var ze=(e,t)=>({alternative:e,fields:t}),l=e=>({alternative:0,fields:e}),A=e=>({alternative:1,fields:e}),Ge=e=>({alternative:2,fields:e});var $e=(e,t)=>{if(e.length!==56&&e!=="")throw new Error(`Invalid policy id for [${e}] - should be ${g} bytes long or empty string for lovelace`);if(t.length>64)throw new Error(`Invalid asset name for [${t}] - should be less than 32 bytes (64 hex length) long`);return l([e,t])},te=(e,t)=>{if(e.length!==64)throw new Error("Invalid transaction hash - should be 32 bytes long");return l([l([e]),t])},We=(e,t)=>te(e,t),Ye=(e,t)=>[e,t];var q=(e,t=!1)=>e===""?A([]):t?l([l([A([e])])]):l([l([l([e])])]),Xe=(e,t)=>l([{alternative:0,fields:[e]},q(t||"")]),Je=(e,t)=>l([{alternative:1,fields:[e]},q(t||"")]);var Ze=e=>e?A([]):l([]),et=e=>{let t=[];for(let r=0;r<e.length;r+=64){let o=e.substring(r,r+64);t.push(o)}return t},tt=e=>e.join("");var O=(e,t)=>{if(!Array.isArray(t))throw new Error("fields of a constructor must be an array");return{constructor:e,fields:t}},f=e=>O(0,e),h=e=>O(1,e),rt=e=>O(2,e);var ot=e=>e?h([]):f([]),re=e=>S(e),S=e=>{if(e.length%2!==0)throw new Error("Invalid hex string - odd length: "+e);if(!/^[0-9a-fA-F]*$/.test(e))throw new Error("Invalid hex string - non-hex string character: "+e);return{bytes:e}},v=e=>({int:e}),oe=(e,t=!0)=>(t&&e.forEach(r=>{if(typeof r!="object")throw new Error("List item of JSON Cardano data type must be an object - "+r)}),{list:e}),nt=e=>oe((r=>{let o=[];for(let n=0;n<r.length;n+=64){let s=r.substring(n,n+64);o.push(s)}return o})(e).map(re)),at=e=>e.list.map(t=>t.bytes).join(""),R=(e,t=!0)=>({map:e.map(([r,o])=>{if(t&&(typeof r!="object"||typeof o!="object"))throw new Error(`Map item of JSON Cardano data type must be an object - ${r}, ${o}`);return{k:r,v:o}})});var Q=e=>{if(e.length!==56)throw new Error(`Invalid hash for [${e}] - should be 56 bytes long`);return S(e)},H=e=>Q(e),K=e=>Q(e),ne=e=>{if(e.length!==g&&e!=="")throw new Error(`Invalid policy id for [${e}] - should be ${g} bytes long or empty string for lovelace`);return S(e)},N=e=>ne(e),ae=e=>{if(e.length>64)throw new Error(`Invalid asset name for [${e}] - should be less than 32 bytes (64 hex length) long`);return S(e)},w=e=>ae(e),st=(e,t)=>f([N(e),w(t)]),se=(e,t)=>{if(e.length!==64)throw new Error("Invalid transaction hash - should be 32 bytes long");return f([f([S(e)]),v(t)])},it=(e,t)=>se(e,t),ct=e=>({int:e}),pt=e=>({map:e.map(([t,r])=>({k:t,v:r}))}),ut=(e,t)=>({list:[e,t]});var j=(e,t=!1)=>e===""?h([]):t?f([f([h([H(e)])])]):f([f([f([K(e)])])]),dt=(e,t,r=!1)=>f([f([K(e)]),j(t||"",r)]),ft=(e,t,r=!1)=>f([h([H(e)]),j(t||"",r)]);var ie=e=>Buffer.from(e).toString("hex"),lt=e=>Buffer.from(e,"hex"),mt=e=>Buffer.from(e,"utf8").toString("hex"),gt=e=>Buffer.from(e,"hex").toString("utf8"),U=e=>e.length%2===0&&/^[0-9A-F]*$/i.test(e)?Buffer.from(e,"hex"):Buffer.from(e,"utf-8"),ce=e=>e.length%2===0&&/^[0-9A-F]*$/i.test(e)?e:ie(Buffer.from(e,"utf-8")),yt=e=>Buffer.from(e,"hex").toString("utf-8"),xt=e=>{let t=e.slice(0,g),r=e.includes(".")?ce(e.split(".")[1]):e.slice(g);return{policyId:t,assetName:r}};var z={mainnet:{zeroTime:1596059091e3,zeroSlot:4492800,slotLength:1e3,startEpoch:208,epochLength:432e3},preview:{zeroTime:1666656e6,zeroSlot:0,slotLength:1e3,startEpoch:183,epochLength:86400},preprod:{zeroTime:16540416e5+1728e6,zeroSlot:86400,slotLength:1e3,startEpoch:65,epochLength:432e3},testnet:{zeroTime:0,zeroSlot:0,slotLength:0,startEpoch:0,epochLength:0}},bt=(e,t)=>{let r=(e-t.zeroSlot)*t.slotLength;return t.zeroTime+r},pe=(e,t)=>{let r=e-t.zeroTime;return Math.floor(r/t.slotLength)+t.zeroSlot},ht=(e,t=Date.now())=>pe(t,z[e]).toString(),St=(e,t=Date.now())=>{let r=z[e],n=(BigInt(t)/1000n-BigInt(r.zeroTime))/BigInt(r.epochLength)+BigInt(r.startEpoch);return Number(n)};var i=class e{value;constructor(t){if(!t){this.value=BigInt(0);return}this.value=BigInt(t)}static new(t){return t?new e(t):new e(0)}divFloor(t){return this.value=this.value/t.value,this}checkedMul(t){return this.value*=t.value,this}checkedAdd(t){return this.value+=t.value,this}checkedSub(t){return this.value-=t.value,this}clampedSub(t){let r=this.value-t.value;return this.value=r<0n?0n:r,this}lessThan(t){return this.value<t.value}compare(t){return this.value===t.value?0:this.value<t.value?-1:1}toString(){return this.value.toString()}};var ue=Ae(require("@emurgo/cip14-js"),1);var de=ue.default,Tt=(e,t)=>de.default.fromParts(U(e),U(t)).fingerprint();var At=e=>C.fromAssets(e).toJSON(),Mt=e=>C.fromAssets(e).toData(),C=class e{value;constructor(t={}){this.value=t}static fromAssets=t=>{let r=new e;return r.addAssets(t),r};static fromValue=t=>{let r=[];return t.map.forEach(o=>{let n=o.k.bytes;o.v.map.forEach(s=>{let c=s.k.bytes,p=s.v.int.toString(),d=n+c,y=d===""?"lovelace":d;r.push({unit:y,quantity:p})})}),e.fromAssets(r)};addAsset=t=>{let r=BigInt(t.quantity),{unit:o}=t;return this.value[o]?this.value[o]+=r:this.value[o]=r,this};addAssets=t=>(t.forEach(r=>{this.addAsset(r)}),this);negateAsset=t=>{let{unit:r,quantity:o}=t,n=i.new(this.value[r]);return n.clampedSub(i.new(o)),n.value===BigInt(0)?delete this.value[r]:this.value[r]=n.value,this};negateAssets=t=>(t.forEach(r=>{this.negateAsset(r)}),this);get=t=>this.value[t]?BigInt(this.value[t]):BigInt(0);units=()=>Object.keys(this.value);geq=t=>Object.keys(t.value).every(r=>this.geqUnit(r,t));geqUnit=(t,r)=>this.value[t]===void 0||r.value[t]===void 0?!1:BigInt(this.value[t])>=BigInt(r.value[t]);leq=t=>Object.keys(t.value).every(r=>this.leqUnit(r,t));leqUnit=(t,r)=>this.value[t]===void 0||r.value[t]===void 0?!1:BigInt(this.value[t])<=BigInt(r.value[t]);isEmpty=()=>Object.keys(this.value).length===0;merge=t=>((Array.isArray(t)?t:[t]).forEach(o=>{Object.entries(o.value).forEach(([n,s])=>{this.value[n]=(this.value[n]!==void 0?BigInt(this.value[n]):BigInt(0))+BigInt(s)})}),this);toAssets=()=>{let t=[];return Object.entries(this.value).forEach(([r,o])=>{t.push({unit:r,quantity:o.toString()})}),t};toData=()=>{let t=new Map;return this.toAssets().forEach(r=>{let o=r.unit.slice(0,56)||"",n=r.unit.slice(56)||"";t.has(o)||t.set(o,new Map);let s=t.get(o),c=s?.get(n);c?s.set(n,c+BigInt(r.quantity)):s.set(n,BigInt(r.quantity))}),t};toJSON=()=>{let t=[],r={};return this.toAssets().forEach(o=>{let n=o.unit.replace("lovelace",""),s=n.slice(0,56)||"",c=n.slice(56)||"";r[s]||(r[s]={}),r[s][c]?r[s][c]+=Number(o.quantity):r[s][c]=Number(o.quantity)}),Object.keys(r).forEach(o=>{let n=N(o),s=Object.keys(r[o]).map(p=>[w(p),v(r[o][p])]),c=R(s);t.push([n,c])}),R(t)}};var G=(e,t,r)=>{let o=new Map(e);o.set("lovelace",String(Number(o.get("lovelace")||0)+Number(r)));let n=new Map;for(let a=0;a<t.length;a++)n.set(a,t[a]);let s=new Set,c=new Set,p=new Set,d=new Set,y=new Set;for(let a=0;a<t.length;a++)switch(t[a].output.amount.length){case 1:{c.add(a);break}case 2:{p.add(a);break}case 3:{d.add(a);break}default:{y.add(a);break}}let x=(a,u,m)=>{let P=n.get(a);if(!P)return;let ge=vt(P,u);if(Number(ge)>0){s.add(a),m.delete(a);for(let V of P.output.amount)o.set(V.unit,String(Number(o.get(V.unit))-Number(V.quantity)))}};for(let a of o.keys())if(a!="lovelace"){for(let u of p){let m=o.get(a);if(!m||Number(m)<=0)break;x(u,a,p)}for(let u of d){let m=o.get(a);if(!m||Number(m)<=0)break;x(u,a,d)}for(let u of y){let m=o.get(a);if(!m||Number(m)<=0)break;x(u,a,y)}}for(let a of c){let u=o.get("lovelace");if(!u||Number(u)<=0)break;x(a,"lovelace",c)}for(let a of p){let u=o.get("lovelace");if(!u||Number(u)<=0)break;x(a,"lovelace",p)}for(let a of d){let u=o.get("lovelace");if(!u||Number(u)<=0)break;x(a,"lovelace",d)}for(let a of y){let u=o.get("lovelace");if(!u||Number(u)<=0)break;x(a,"lovelace",y)}for(let a of o.keys())if(Number(o.get(a))>0)return console.log("Insufficient funds for",a),console.log("Remaining quantity",Number(o.get(a))),[];let k=[];for(let a of s){let u=n.get(a);u&&k.push(u)}return k},vt=(e,t)=>{for(let r of e.output.amount)if(r.unit==t)return r.quantity;return"0"};var Ct=(e,t)=>Array.from(t,r=>({unit:r[0],quantity:i.new(r[1])})).every(r=>e.filter(o=>o.output.amount.find(n=>n.unit===r.unit)!==void 0).reduce((o,n)=>{let s=n.output.amount.reduce((c,p)=>c.checkedAdd(i.new(r.unit===p.unit?p.quantity:"0")),i.new("0"));return o.checkedAdd(s)},i.new("0")).lessThan(r.quantity)===!1),I=(e,t)=>{let r=i.new(e.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0");return i.new(t.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0").compare(r)},fe=e=>{let{maxTxSize:t,minFeeA:r,minFeeB:o}=e;return i.new(M(t,r,o))},E=e=>e.output.amount.length>1,le=e=>e.reduce((t,r)=>{let o=r.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0";return t.checkedAdd(i.new(o))},i.new("0")),me=(e,t)=>{let r=t.sort(I);return T(r,new Map([["lovelace",e]]))},T=(e,t,r=[])=>e.length===0||Ct(r,t)?r:It(e[0],t)?T(e.slice(1),t,[...r,e[0]]):T(e.slice(1),t,r),It=(e,t)=>Array.from(t.keys()).some(r=>e.output.amount.find(o=>o.unit===r)!==void 0);var $=(e,t,r="5000000")=>{let o=i.new(e.get("lovelace")??"0").checkedAdd(i.new(r)),n=t.filter(p=>p.output.amount.filter(d=>d.unit!=="lovelace").some(d=>e.has(d.unit))),s=le(n);return[...s.lessThan(o)?me(o.clampedSub(s).toString(),t.filter(p=>!n.some(d=>d.input.txHash===p.input.txHash&&d.input.outputIndex===p.input.outputIndex))):[],...n]};var W=(e,t,r=!1,{maxTxSize:o,minFeeA:n,minFeeB:s}=b)=>{let c=t.filter(k=>E(k)===!1).sort(I),p=i.new(M(o,n,s)),d=r?i.new(e).checkedAdd(p).toString():e;return T(c,new Map([["lovelace",d]]))};var Y=(e,t,r=!1,o=b)=>{let n=t.filter(E).sort(I),s=fe(o),c=e.get("lovelace")??"0",p=r?i.new(c).checkedAdd(s).toString():c;return e.set("lovelace",p),T(n,e)};var X=class{threshold;includeTxFees;constructor(t="5000000",r=!0){this.threshold=t,this.includeTxFees=r}largestFirst(t,r){let o=t.get("lovelace")??"0",n=BigInt(o)+BigInt(this.threshold);return W(n.toString(),r,this.includeTxFees)}keepRelevant(t,r){return $(t,r,this.threshold)}largestFirstMultiAsset(t,r){let o=t.get("lovelace")??"0";return t.set("lovelace",(BigInt(o)+BigInt(this.threshold)).toString()),Y(t,r,this.includeTxFees)}experimental(t,r){return G(t,r,this.threshold)}};var D=require("bip39");0&&(module.exports={AssetFingerprint,BigNum,CIP68_100,CIP68_222,DEFAULT_PROTOCOL_PARAMETERS,DEFAULT_REDEEMER_BUDGET,DEFAULT_V1_COST_MODEL_LIST,DEFAULT_V2_COST_MODEL_LIST,HARDENED_KEY_START,LANGUAGE_VERSIONS,MeshValue,POLICY_ID_LENGTH,SLOT_CONFIG_NETWORK,SUPPORTED_CLOCKS,SUPPORTED_HANDLES,SUPPORTED_LANGUAGE_VIEWS,SUPPORTED_OGMIOS_LINKS,SUPPORTED_TOKENS,SUPPORTED_WALLETS,UtxoSelection,assetClass,assetName,assocMap,bool,builtinByteString,byteString,bytesToHex,certificateToObj,conStr,conStr0,conStr1,conStr2,currencySymbol,dict,emptyTxBuilderBody,experimentalSelectUtxos,fromUTF8,fungibleAssetKeys,generateMnemonic,hashByteString,hexToBytes,hexToString,integer,isNetwork,keepRelevant,largestFirst,largestFirstMultiAsset,list,mAssetClass,mBool,mConStr,mConStr0,mConStr1,mConStr2,mMaybeStakingHash,mOutputReference,mPlutusBSArrayToString,mPubKeyAddress,mScriptAddress,mStringToPlutusBSArray,mTuple,mTxOutRef,mValue,maybeStakingHash,mergeAssets,metadataStandardKeys,metadataToCip68,mnemonicToEntropy,outputReference,parseAssetUnit,plutusBSArrayToString,policyId,poolMetadataToObj,poolParamsToObj,posixTime,pubKeyAddress,pubKeyHash,relayToObj,resolveEpochNo,resolveFingerprint,resolveLanguageView,resolveSlotNo,resolveTxFees,royaltiesStandardKeys,scriptAddress,scriptHash,slotToBeginUnixTime,stringToBSArray,stringToHex,toBytes,toUTF8,tokenName,tuple,txOutRef,unixTimeToEnclosingSlot,validityRangeToObj,value});
|
package/dist/index.d.cts
CHANGED
|
@@ -640,6 +640,7 @@ interface IMeshTxSerializer {
|
|
|
640
640
|
deserializer: IDeserializer;
|
|
641
641
|
serializeData(data: BuilderData): string;
|
|
642
642
|
serializeAddress(address: DeserializedAddress, networkId?: 0 | 1): string;
|
|
643
|
+
serializePoolId(hash: string): string;
|
|
643
644
|
}
|
|
644
645
|
interface IResolver {
|
|
645
646
|
keys: {
|
|
@@ -657,9 +658,6 @@ interface IResolver {
|
|
|
657
658
|
script: {
|
|
658
659
|
resolveScriptRef(script: NativeScript | PlutusScript): string;
|
|
659
660
|
};
|
|
660
|
-
pool: {
|
|
661
|
-
resolvePoolId(hash: string): string;
|
|
662
|
-
};
|
|
663
661
|
}
|
|
664
662
|
interface IDeserializer {
|
|
665
663
|
key: {
|
|
@@ -669,6 +667,9 @@ interface IDeserializer {
|
|
|
669
667
|
deserializeNativeScript(script: NativeScript): DeserializedScript;
|
|
670
668
|
deserializePlutusScript(script: PlutusScript): DeserializedScript;
|
|
671
669
|
};
|
|
670
|
+
cert: {
|
|
671
|
+
deserializePoolId(poolId: string): string;
|
|
672
|
+
};
|
|
672
673
|
}
|
|
673
674
|
|
|
674
675
|
interface ISigner {
|
|
@@ -1239,14 +1240,142 @@ declare const resolveEpochNo: (network: Network, milliseconds?: number) => numbe
|
|
|
1239
1240
|
* where first key as policy id, second key as asset name, and final value as quantity.
|
|
1240
1241
|
*/
|
|
1241
1242
|
|
|
1243
|
+
/**
|
|
1244
|
+
* Aiken alias
|
|
1245
|
+
* Value is the JSON representation of Cardano data Value
|
|
1246
|
+
*/
|
|
1242
1247
|
type Value = AssocMap<CurrencySymbol, AssocMap<TokenName, Integer>>;
|
|
1248
|
+
/**
|
|
1249
|
+
* Aiken alias
|
|
1250
|
+
* MValue is the Cardano data Value in Mesh Data type
|
|
1251
|
+
*/
|
|
1243
1252
|
type MValue = Map<string, Map<string, bigint>>;
|
|
1253
|
+
/**
|
|
1254
|
+
* The utility function to convert assets into Cardano data Value in JSON
|
|
1255
|
+
* @param assets The assets to convert
|
|
1256
|
+
* @returns The Cardano data Value in JSON
|
|
1257
|
+
*/
|
|
1244
1258
|
declare const value: (assets: Asset[]) => Value;
|
|
1245
|
-
|
|
1259
|
+
/**
|
|
1260
|
+
* The utility function to convert assets into Cardano data Value in Mesh Data type
|
|
1261
|
+
* @param assets The assets to convert
|
|
1262
|
+
* @returns The Cardano data Value in Mesh Data type
|
|
1263
|
+
*/
|
|
1264
|
+
declare const mValue: (assets: Asset[]) => MValue;
|
|
1265
|
+
/**
|
|
1266
|
+
* MeshValue provide utility to handle the Cardano value manipulation. It offers certain axioms:
|
|
1267
|
+
* 1. No duplication of asset - adding assets with same asset name will increase the quantity of the asset in the same record.
|
|
1268
|
+
* 2. No zero and negative entry - the quantity of the asset should not be zero or negative.
|
|
1269
|
+
* 3. Sanitization of lovelace asset name - the class handle back and forth conversion of lovelace asset name to empty string.
|
|
1270
|
+
* 4. Easy convertion to Cardano data - offer utility to convert into either Mesh Data type and JSON type for its Cardano data representation.
|
|
1271
|
+
*/
|
|
1272
|
+
declare class MeshValue {
|
|
1273
|
+
value: Record<string, bigint>;
|
|
1274
|
+
constructor(value?: Record<string, bigint>);
|
|
1275
|
+
/**
|
|
1276
|
+
* Converting assets into MeshValue
|
|
1277
|
+
* @param assets The assets to convert
|
|
1278
|
+
* @returns MeshValue
|
|
1279
|
+
*/
|
|
1280
|
+
static fromAssets: (assets: Asset[]) => MeshValue;
|
|
1281
|
+
/**
|
|
1282
|
+
* Converting Value (the JSON representation of Cardano data Value) into MeshValue
|
|
1283
|
+
* @param plutusValue The Value to convert
|
|
1284
|
+
* @returns MeshValue
|
|
1285
|
+
*/
|
|
1286
|
+
static fromValue: (plutusValue: Value) => MeshValue;
|
|
1287
|
+
/**
|
|
1288
|
+
* Add an asset to the Value class's value record.
|
|
1289
|
+
* @param asset The asset to add
|
|
1290
|
+
* @returns The updated MeshValue object
|
|
1291
|
+
*/
|
|
1292
|
+
addAsset: (asset: Asset) => this;
|
|
1293
|
+
/**
|
|
1294
|
+
* Add an array of assets to the Value class's value record.
|
|
1295
|
+
* @param assets The assets to add
|
|
1296
|
+
* @returns The updated MeshValue object
|
|
1297
|
+
*/
|
|
1298
|
+
addAssets: (assets: Asset[]) => this;
|
|
1299
|
+
/**
|
|
1300
|
+
* Substract an asset from the Value class's value record.
|
|
1301
|
+
* @param asset The asset to subtract
|
|
1302
|
+
* @returns The updated MeshValue object
|
|
1303
|
+
*/
|
|
1304
|
+
negateAsset: (asset: Asset) => this;
|
|
1305
|
+
/**
|
|
1306
|
+
* Subtract an array of assets from the Value class's value record.
|
|
1307
|
+
* @param assets The assets to subtract
|
|
1308
|
+
* @returns The updated MeshValue object
|
|
1309
|
+
*/
|
|
1310
|
+
negateAssets: (assets: Asset[]) => this;
|
|
1311
|
+
/**
|
|
1312
|
+
* Get the quantity of asset object per unit
|
|
1313
|
+
* @param unit The unit to get the quantity of
|
|
1314
|
+
* @returns The quantity of the asset
|
|
1315
|
+
*/
|
|
1316
|
+
get: (unit: string) => bigint;
|
|
1317
|
+
/**
|
|
1318
|
+
* Get all asset units
|
|
1319
|
+
* @returns The asset units
|
|
1320
|
+
*/
|
|
1321
|
+
units: () => string[];
|
|
1322
|
+
/**
|
|
1323
|
+
* Check if the value is greater than or equal to another value
|
|
1324
|
+
* @param other - The value to compare against
|
|
1325
|
+
* @returns boolean
|
|
1326
|
+
*/
|
|
1327
|
+
geq: (other: MeshValue) => boolean;
|
|
1328
|
+
/**
|
|
1329
|
+
* Check if the specific unit of value is greater than or equal to that unit of another value
|
|
1330
|
+
* @param unit - The unit to compare
|
|
1331
|
+
* @param other - The value to compare against
|
|
1332
|
+
* @returns boolean
|
|
1333
|
+
*/
|
|
1334
|
+
geqUnit: (unit: string, other: MeshValue) => boolean;
|
|
1335
|
+
/**
|
|
1336
|
+
* Check if the value is less than or equal to another value
|
|
1337
|
+
* @param other - The value to compare against
|
|
1338
|
+
* @returns boolean
|
|
1339
|
+
*/
|
|
1340
|
+
leq: (other: MeshValue) => boolean;
|
|
1341
|
+
/**
|
|
1342
|
+
* Check if the specific unit of value is less than or equal to that unit of another value
|
|
1343
|
+
* @param unit - The unit to compare
|
|
1344
|
+
* @param other - The value to compare against
|
|
1345
|
+
* @returns boolean
|
|
1346
|
+
*/
|
|
1347
|
+
leqUnit: (unit: string, other: MeshValue) => boolean;
|
|
1348
|
+
/**
|
|
1349
|
+
* Check if the value is empty
|
|
1350
|
+
* @returns boolean
|
|
1351
|
+
*/
|
|
1352
|
+
isEmpty: () => boolean;
|
|
1353
|
+
/**
|
|
1354
|
+
* Merge the given values
|
|
1355
|
+
* @param values The other values to merge
|
|
1356
|
+
* @returns this
|
|
1357
|
+
*/
|
|
1358
|
+
merge: (values: MeshValue | MeshValue[]) => this;
|
|
1359
|
+
/**
|
|
1360
|
+
* Convert the MeshValue object into an array of Asset
|
|
1361
|
+
* @returns The array of Asset
|
|
1362
|
+
*/
|
|
1363
|
+
toAssets: () => Asset[];
|
|
1364
|
+
/**
|
|
1365
|
+
* Convert the MeshValue object into Cardano data Value in Mesh Data type
|
|
1366
|
+
*/
|
|
1367
|
+
toData: () => MValue;
|
|
1368
|
+
/**
|
|
1369
|
+
* Convert the MeshValue object into a JSON representation of Cardano data Value
|
|
1370
|
+
* @returns Cardano data Value in JSON
|
|
1371
|
+
*/
|
|
1372
|
+
toJSON: () => Value;
|
|
1373
|
+
}
|
|
1246
1374
|
|
|
1247
1375
|
declare class BigNum {
|
|
1248
1376
|
value: bigint;
|
|
1249
|
-
constructor(value
|
|
1377
|
+
constructor(value?: bigint | number | string);
|
|
1378
|
+
static new(value: number | string | bigint | undefined): BigNum;
|
|
1250
1379
|
divFloor(other: BigNum): BigNum;
|
|
1251
1380
|
checkedMul(other: BigNum): BigNum;
|
|
1252
1381
|
checkedAdd(other: BigNum): BigNum;
|
|
@@ -1254,11 +1383,10 @@ declare class BigNum {
|
|
|
1254
1383
|
clampedSub(other: BigNum): BigNum;
|
|
1255
1384
|
lessThan(other: BigNum): boolean;
|
|
1256
1385
|
compare(other: BigNum): -1 | 0 | 1;
|
|
1257
|
-
static new: (value: number | string) => BigNum;
|
|
1258
1386
|
toString(): string;
|
|
1259
1387
|
}
|
|
1260
1388
|
|
|
1261
1389
|
declare const AssetFingerprint: typeof CIP14;
|
|
1262
1390
|
declare const resolveFingerprint: (policyId: string, assetName: string) => any;
|
|
1263
1391
|
|
|
1264
|
-
export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type ConStr, type ConStr0, type ConStr1, type ConStr2, type CurrencySymbol, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type FungibleAssetMetadata, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IInitiator, type IListener, type IMeshTxSerializer, type IResolver, type ISigner, type ISubmitter, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MMaybeStakingHash, type MOutputReference, type MPubKeyAddress, type MScriptAddress, type MTuple, type MTxOutRef, type MValue, type MaybeStakingHash, type MeshTxBuilderBody, type Message, type Metadata, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type PlutusData, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SlotConfig, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, certificateToObj, conStr, conStr0, conStr1, conStr2, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, hashByteString, hexToBytes, hexToString, integer, isNetwork, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mMaybeStakingHash, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScriptAddress, mStringToPlutusBSArray, mTuple, mTxOutRef, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, outputReference, parseAssetUnit,
|
|
1392
|
+
export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type ConStr, type ConStr0, type ConStr1, type ConStr2, type CurrencySymbol, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type FungibleAssetMetadata, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IInitiator, type IListener, type IMeshTxSerializer, type IResolver, type ISigner, type ISubmitter, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MMaybeStakingHash, type MOutputReference, type MPubKeyAddress, type MScriptAddress, type MTuple, type MTxOutRef, type MValue, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type PlutusData, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SlotConfig, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, certificateToObj, conStr, conStr0, conStr1, conStr2, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, hashByteString, hexToBytes, hexToString, integer, isNetwork, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mMaybeStakingHash, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScriptAddress, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, outputReference, parseAssetUnit, plutusBSArrayToString, policyId, poolMetadataToObj, poolParamsToObj, posixTime, pubKeyAddress, pubKeyHash, relayToObj, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, scriptAddress, scriptHash, slotToBeginUnixTime, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value };
|
package/dist/index.d.ts
CHANGED
|
@@ -640,6 +640,7 @@ interface IMeshTxSerializer {
|
|
|
640
640
|
deserializer: IDeserializer;
|
|
641
641
|
serializeData(data: BuilderData): string;
|
|
642
642
|
serializeAddress(address: DeserializedAddress, networkId?: 0 | 1): string;
|
|
643
|
+
serializePoolId(hash: string): string;
|
|
643
644
|
}
|
|
644
645
|
interface IResolver {
|
|
645
646
|
keys: {
|
|
@@ -657,9 +658,6 @@ interface IResolver {
|
|
|
657
658
|
script: {
|
|
658
659
|
resolveScriptRef(script: NativeScript | PlutusScript): string;
|
|
659
660
|
};
|
|
660
|
-
pool: {
|
|
661
|
-
resolvePoolId(hash: string): string;
|
|
662
|
-
};
|
|
663
661
|
}
|
|
664
662
|
interface IDeserializer {
|
|
665
663
|
key: {
|
|
@@ -669,6 +667,9 @@ interface IDeserializer {
|
|
|
669
667
|
deserializeNativeScript(script: NativeScript): DeserializedScript;
|
|
670
668
|
deserializePlutusScript(script: PlutusScript): DeserializedScript;
|
|
671
669
|
};
|
|
670
|
+
cert: {
|
|
671
|
+
deserializePoolId(poolId: string): string;
|
|
672
|
+
};
|
|
672
673
|
}
|
|
673
674
|
|
|
674
675
|
interface ISigner {
|
|
@@ -1239,14 +1240,142 @@ declare const resolveEpochNo: (network: Network, milliseconds?: number) => numbe
|
|
|
1239
1240
|
* where first key as policy id, second key as asset name, and final value as quantity.
|
|
1240
1241
|
*/
|
|
1241
1242
|
|
|
1243
|
+
/**
|
|
1244
|
+
* Aiken alias
|
|
1245
|
+
* Value is the JSON representation of Cardano data Value
|
|
1246
|
+
*/
|
|
1242
1247
|
type Value = AssocMap<CurrencySymbol, AssocMap<TokenName, Integer>>;
|
|
1248
|
+
/**
|
|
1249
|
+
* Aiken alias
|
|
1250
|
+
* MValue is the Cardano data Value in Mesh Data type
|
|
1251
|
+
*/
|
|
1243
1252
|
type MValue = Map<string, Map<string, bigint>>;
|
|
1253
|
+
/**
|
|
1254
|
+
* The utility function to convert assets into Cardano data Value in JSON
|
|
1255
|
+
* @param assets The assets to convert
|
|
1256
|
+
* @returns The Cardano data Value in JSON
|
|
1257
|
+
*/
|
|
1244
1258
|
declare const value: (assets: Asset[]) => Value;
|
|
1245
|
-
|
|
1259
|
+
/**
|
|
1260
|
+
* The utility function to convert assets into Cardano data Value in Mesh Data type
|
|
1261
|
+
* @param assets The assets to convert
|
|
1262
|
+
* @returns The Cardano data Value in Mesh Data type
|
|
1263
|
+
*/
|
|
1264
|
+
declare const mValue: (assets: Asset[]) => MValue;
|
|
1265
|
+
/**
|
|
1266
|
+
* MeshValue provide utility to handle the Cardano value manipulation. It offers certain axioms:
|
|
1267
|
+
* 1. No duplication of asset - adding assets with same asset name will increase the quantity of the asset in the same record.
|
|
1268
|
+
* 2. No zero and negative entry - the quantity of the asset should not be zero or negative.
|
|
1269
|
+
* 3. Sanitization of lovelace asset name - the class handle back and forth conversion of lovelace asset name to empty string.
|
|
1270
|
+
* 4. Easy convertion to Cardano data - offer utility to convert into either Mesh Data type and JSON type for its Cardano data representation.
|
|
1271
|
+
*/
|
|
1272
|
+
declare class MeshValue {
|
|
1273
|
+
value: Record<string, bigint>;
|
|
1274
|
+
constructor(value?: Record<string, bigint>);
|
|
1275
|
+
/**
|
|
1276
|
+
* Converting assets into MeshValue
|
|
1277
|
+
* @param assets The assets to convert
|
|
1278
|
+
* @returns MeshValue
|
|
1279
|
+
*/
|
|
1280
|
+
static fromAssets: (assets: Asset[]) => MeshValue;
|
|
1281
|
+
/**
|
|
1282
|
+
* Converting Value (the JSON representation of Cardano data Value) into MeshValue
|
|
1283
|
+
* @param plutusValue The Value to convert
|
|
1284
|
+
* @returns MeshValue
|
|
1285
|
+
*/
|
|
1286
|
+
static fromValue: (plutusValue: Value) => MeshValue;
|
|
1287
|
+
/**
|
|
1288
|
+
* Add an asset to the Value class's value record.
|
|
1289
|
+
* @param asset The asset to add
|
|
1290
|
+
* @returns The updated MeshValue object
|
|
1291
|
+
*/
|
|
1292
|
+
addAsset: (asset: Asset) => this;
|
|
1293
|
+
/**
|
|
1294
|
+
* Add an array of assets to the Value class's value record.
|
|
1295
|
+
* @param assets The assets to add
|
|
1296
|
+
* @returns The updated MeshValue object
|
|
1297
|
+
*/
|
|
1298
|
+
addAssets: (assets: Asset[]) => this;
|
|
1299
|
+
/**
|
|
1300
|
+
* Substract an asset from the Value class's value record.
|
|
1301
|
+
* @param asset The asset to subtract
|
|
1302
|
+
* @returns The updated MeshValue object
|
|
1303
|
+
*/
|
|
1304
|
+
negateAsset: (asset: Asset) => this;
|
|
1305
|
+
/**
|
|
1306
|
+
* Subtract an array of assets from the Value class's value record.
|
|
1307
|
+
* @param assets The assets to subtract
|
|
1308
|
+
* @returns The updated MeshValue object
|
|
1309
|
+
*/
|
|
1310
|
+
negateAssets: (assets: Asset[]) => this;
|
|
1311
|
+
/**
|
|
1312
|
+
* Get the quantity of asset object per unit
|
|
1313
|
+
* @param unit The unit to get the quantity of
|
|
1314
|
+
* @returns The quantity of the asset
|
|
1315
|
+
*/
|
|
1316
|
+
get: (unit: string) => bigint;
|
|
1317
|
+
/**
|
|
1318
|
+
* Get all asset units
|
|
1319
|
+
* @returns The asset units
|
|
1320
|
+
*/
|
|
1321
|
+
units: () => string[];
|
|
1322
|
+
/**
|
|
1323
|
+
* Check if the value is greater than or equal to another value
|
|
1324
|
+
* @param other - The value to compare against
|
|
1325
|
+
* @returns boolean
|
|
1326
|
+
*/
|
|
1327
|
+
geq: (other: MeshValue) => boolean;
|
|
1328
|
+
/**
|
|
1329
|
+
* Check if the specific unit of value is greater than or equal to that unit of another value
|
|
1330
|
+
* @param unit - The unit to compare
|
|
1331
|
+
* @param other - The value to compare against
|
|
1332
|
+
* @returns boolean
|
|
1333
|
+
*/
|
|
1334
|
+
geqUnit: (unit: string, other: MeshValue) => boolean;
|
|
1335
|
+
/**
|
|
1336
|
+
* Check if the value is less than or equal to another value
|
|
1337
|
+
* @param other - The value to compare against
|
|
1338
|
+
* @returns boolean
|
|
1339
|
+
*/
|
|
1340
|
+
leq: (other: MeshValue) => boolean;
|
|
1341
|
+
/**
|
|
1342
|
+
* Check if the specific unit of value is less than or equal to that unit of another value
|
|
1343
|
+
* @param unit - The unit to compare
|
|
1344
|
+
* @param other - The value to compare against
|
|
1345
|
+
* @returns boolean
|
|
1346
|
+
*/
|
|
1347
|
+
leqUnit: (unit: string, other: MeshValue) => boolean;
|
|
1348
|
+
/**
|
|
1349
|
+
* Check if the value is empty
|
|
1350
|
+
* @returns boolean
|
|
1351
|
+
*/
|
|
1352
|
+
isEmpty: () => boolean;
|
|
1353
|
+
/**
|
|
1354
|
+
* Merge the given values
|
|
1355
|
+
* @param values The other values to merge
|
|
1356
|
+
* @returns this
|
|
1357
|
+
*/
|
|
1358
|
+
merge: (values: MeshValue | MeshValue[]) => this;
|
|
1359
|
+
/**
|
|
1360
|
+
* Convert the MeshValue object into an array of Asset
|
|
1361
|
+
* @returns The array of Asset
|
|
1362
|
+
*/
|
|
1363
|
+
toAssets: () => Asset[];
|
|
1364
|
+
/**
|
|
1365
|
+
* Convert the MeshValue object into Cardano data Value in Mesh Data type
|
|
1366
|
+
*/
|
|
1367
|
+
toData: () => MValue;
|
|
1368
|
+
/**
|
|
1369
|
+
* Convert the MeshValue object into a JSON representation of Cardano data Value
|
|
1370
|
+
* @returns Cardano data Value in JSON
|
|
1371
|
+
*/
|
|
1372
|
+
toJSON: () => Value;
|
|
1373
|
+
}
|
|
1246
1374
|
|
|
1247
1375
|
declare class BigNum {
|
|
1248
1376
|
value: bigint;
|
|
1249
|
-
constructor(value
|
|
1377
|
+
constructor(value?: bigint | number | string);
|
|
1378
|
+
static new(value: number | string | bigint | undefined): BigNum;
|
|
1250
1379
|
divFloor(other: BigNum): BigNum;
|
|
1251
1380
|
checkedMul(other: BigNum): BigNum;
|
|
1252
1381
|
checkedAdd(other: BigNum): BigNum;
|
|
@@ -1254,11 +1383,10 @@ declare class BigNum {
|
|
|
1254
1383
|
clampedSub(other: BigNum): BigNum;
|
|
1255
1384
|
lessThan(other: BigNum): boolean;
|
|
1256
1385
|
compare(other: BigNum): -1 | 0 | 1;
|
|
1257
|
-
static new: (value: number | string) => BigNum;
|
|
1258
1386
|
toString(): string;
|
|
1259
1387
|
}
|
|
1260
1388
|
|
|
1261
1389
|
declare const AssetFingerprint: typeof CIP14;
|
|
1262
1390
|
declare const resolveFingerprint: (policyId: string, assetName: string) => any;
|
|
1263
1391
|
|
|
1264
|
-
export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type ConStr, type ConStr0, type ConStr1, type ConStr2, type CurrencySymbol, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type FungibleAssetMetadata, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IInitiator, type IListener, type IMeshTxSerializer, type IResolver, type ISigner, type ISubmitter, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MMaybeStakingHash, type MOutputReference, type MPubKeyAddress, type MScriptAddress, type MTuple, type MTxOutRef, type MValue, type MaybeStakingHash, type MeshTxBuilderBody, type Message, type Metadata, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type PlutusData, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SlotConfig, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, certificateToObj, conStr, conStr0, conStr1, conStr2, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, hashByteString, hexToBytes, hexToString, integer, isNetwork, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mMaybeStakingHash, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScriptAddress, mStringToPlutusBSArray, mTuple, mTxOutRef, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, outputReference, parseAssetUnit,
|
|
1392
|
+
export { type AccountInfo, type Action, type Anchor, type Asset, type AssetClass, type AssetExtended, AssetFingerprint, type AssetMetadata, type AssetName, type AssocMap, type AssocMapItem, BigNum, type BlockInfo, type Bool, type Budget, type BuilderData, type BuiltinByteString, type ByteString, CIP68_100, CIP68_222, type Certificate, type ConStr, type ConStr0, type ConStr1, type ConStr2, type CurrencySymbol, DEFAULT_PROTOCOL_PARAMETERS, DEFAULT_REDEEMER_BUDGET, DEFAULT_V1_COST_MODEL_LIST, DEFAULT_V2_COST_MODEL_LIST, type DRep, type Data, type DataSignature, type DatumSource, type DeserializedAddress, type DeserializedScript, type Dict, type DictItem, type Era, type Files, type FungibleAssetMetadata, HARDENED_KEY_START, type IDeserializer, type IEvaluator, type IFetcher, type IInitiator, type IListener, type IMeshTxSerializer, type IResolver, type ISigner, type ISubmitter, type ImageAssetMetadata, type Integer, LANGUAGE_VERSIONS, type LanguageVersion, type List, type MAssetClass, type MBool, type MConStr, type MConStr0, type MConStr1, type MConStr2, type MMaybeStakingHash, type MOutputReference, type MPubKeyAddress, type MScriptAddress, type MTuple, type MTxOutRef, type MValue, type MaybeStakingHash, type MeshTxBuilderBody, MeshValue, type Message, type Metadata, type Mint, type MintItem, type NativeScript, type Network, type NonFungibleAssetMetadata, type Output, type OutputReference, POLICY_ID_LENGTH, type POSIXTime, type PlutusData, type PlutusScript, type PolicyId, type PoolMetadata, type PoolParams, type Protocol, type PubKeyAddress, type PubKeyHash, type PubKeyTxIn, type Quantity, type Recipient, type Redeemer, type RedeemerTagType, type RefTxIn, type Relay, type RequiredWith, type RoyaltiesStandard, SLOT_CONFIG_NETWORK, SUPPORTED_CLOCKS, SUPPORTED_HANDLES, SUPPORTED_LANGUAGE_VIEWS, SUPPORTED_OGMIOS_LINKS, SUPPORTED_TOKENS, SUPPORTED_WALLETS, type ScriptAddress, type ScriptHash, type ScriptSource, type ScriptTxIn, type ScriptTxInParameter, type SimpleScriptSourceInfo, type SimpleScriptTxIn, type SimpleScriptTxInParameter, type SlotConfig, type Token, type TokenName, type TransactionInfo, type Tuple, type TxIn, type TxInParameter, type TxOutRef, type UTxO, type Unit, UtxoSelection, type UtxoSelectionStrategy, type ValidityRange, type Value, type Wallet, type Withdrawal, assetClass, assetName, assocMap, bool, builtinByteString, byteString, bytesToHex, certificateToObj, conStr, conStr0, conStr1, conStr2, currencySymbol, dict, emptyTxBuilderBody, experimentalSelectUtxos, fromUTF8, fungibleAssetKeys, hashByteString, hexToBytes, hexToString, integer, isNetwork, keepRelevant, largestFirst, largestFirstMultiAsset, list, mAssetClass, mBool, mConStr, mConStr0, mConStr1, mConStr2, mMaybeStakingHash, mOutputReference, mPlutusBSArrayToString, mPubKeyAddress, mScriptAddress, mStringToPlutusBSArray, mTuple, mTxOutRef, mValue, maybeStakingHash, mergeAssets, metadataStandardKeys, metadataToCip68, outputReference, parseAssetUnit, plutusBSArrayToString, policyId, poolMetadataToObj, poolParamsToObj, posixTime, pubKeyAddress, pubKeyHash, relayToObj, resolveEpochNo, resolveFingerprint, resolveLanguageView, resolveSlotNo, resolveTxFees, royaltiesStandardKeys, scriptAddress, scriptHash, slotToBeginUnixTime, stringToBSArray, stringToHex, toBytes, toUTF8, tokenName, tuple, txOutRef, unixTimeToEnclosingSlot, validityRangeToObj, value };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var S={epoch:0,coinsPerUtxoSize:4310,priceMem:.0577,priceStep:721e-7,minFeeA:44,minFeeB:155381,keyDeposit:2e6,maxTxSize:16384,maxValSize:5e3,poolDeposit:5e8,maxCollateralInputs:3,decentralisation:0,maxBlockSize:98304,collateralPercent:150,maxBlockHeaderSize:1100,minPoolCost:"340000000",maxTxExMem:"16000000",maxTxExSteps:"10000000000",maxBlockExMem:"80000000",maxBlockExSteps:"40000000000"},v=(e,t=S.minFeeA,r=S.minFeeB)=>(BigInt(t)*BigInt(e)+BigInt(r)).toString();var xe=["begin","eternl","flint","lace","nami","nufi","gerowallet","typhoncip30","vespr","yoroi"];var Se=[205665,812,1,1,1e3,571,0,1,1e3,24177,4,1,1e3,32,117366,10475,4,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,100,100,23e3,100,19537,32,175354,32,46417,4,221973,511,0,1,89141,32,497525,14068,4,2,196500,453240,220,0,1,1,1e3,28662,4,2,245e3,216773,62,1,1060367,12586,1,208512,421,1,187e3,1e3,52998,1,80436,32,43249,32,1e3,32,80556,1,57667,4,1e3,10,197145,156,1,197145,156,1,204924,473,1,208896,511,1,52467,32,64832,32,65493,32,22558,32,16563,32,76511,32,196500,453240,220,0,1,1,69522,11687,0,1,60091,32,196500,453240,220,0,1,1,196500,453240,220,0,1,1,806990,30482,4,1927926,82523,4,265318,0,4,0,85931,32,205665,812,1,1,41182,32,212342,32,31220,32,32696,32,43357,32,32247,32,38314,32,57996947,18975,10],he=[205665,812,1,1,1e3,571,0,1,1e3,24177,4,1,1e3,32,117366,10475,4,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,100,100,23e3,100,19537,32,175354,32,46417,4,221973,511,0,1,89141,32,497525,14068,4,2,196500,453240,220,0,1,1,1e3,28662,4,2,245e3,216773,62,1,1060367,12586,1,208512,421,1,187e3,1e3,52998,1,80436,32,43249,32,1e3,32,80556,1,57667,4,1e3,10,197145,156,1,197145,156,1,204924,473,1,208896,511,1,52467,32,64832,32,65493,32,22558,32,16563,32,76511,32,196500,453240,220,0,1,1,69522,11687,0,1,60091,32,196500,453240,220,0,1,1,196500,453240,220,0,1,1,1159724,392670,0,2,806990,30482,4,1927926,82523,4,265318,0,4,0,85931,32,205665,812,1,1,41182,32,212342,32,31220,32,32696,32,43357,32,32247,32,38314,32,35892428,10,57996947,18975,10,38887044,32947,10];var Z={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}},Ae=(e,t)=>Z[e][t];var Ce={mem:7e6,steps:3e9},y=56,ve={V1:"V1",V2:"V2",V3:"V3"},ke=2147483648,Re={testnet:["74","1598400","1595967616","432000"],preview:["183","15811222","1682467200","86400"],preprod:["65","26438400","1682121600","432000"],mainnet:["208","4492800","1596059091","432000"]},Ie={0:"8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",1:"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"},He={mainnet:"wss://ogmios-api.mainnet.dandelion.link",preprod:"wss://ogmios-api.iohk-preprod.dandelion.link",preview:"__TBD_SOON_TM__",testnet:"wss://ogmios-api.testnet.dandelion.link"},Be={LQ:"da8c30857834c6ae7203935b89278c532b3995245295456f993e1d244c51",MIN:"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e",NTX:"edfd7a1d77bcb8b884c474bdc92a16002d1fb720e454fa6e993444794e5458",iBTC:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069425443",iETH:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069455448",iUSD:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069555344",MILK:"8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa4d494c4b",AGIX:"f43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc53541474958",MELD:"6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d104d454c44",INDY:"533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0494e4459",CLAY:"38ad9dc3aec6a2f38e220142b9aa6ade63ebe71f65e7cc2b7d8a8535434c4159",MCOS:"6f46e1304b16d884c85c62fb0eef35028facdc41aaa0fd319a152ed64d434f53",DING:"ce5b9e0f8a88255b65f2e4d065c6e716e9fa9a8a86dfb86423dd1ac044494e47",GERO:"10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b64745524f",NMKR:"5dac8536653edc12f6f5e1045d8164b9f59998d3bdc300fc928434894e4d4b52",PAVIA:"884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903ae5041564941",HOSKY:"a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235484f534b59",YUMMI:"078eafce5cd7edafdf63900edef2c1ea759e77f30ca81d6bbdeec92479756d6d69",C3:"8e51398904a5d3fc129fbf4f1589701de23c7824d5c90fdb9490e15a434841524c4933",GIMBAL:"2b0a04a7b60132b1805b296c7fcb3b217ff14413991bf76f72663c3067696d62616c",SUNDAE:"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145",GREENS:"4623ab311b7d982d8d26fcbe1a9439ca56661aafcdcd8d8a0ef31fd6475245454e53",GENS:"dda5fdb1002f7389b33e036b6afee82a8189becb6cba852e8b79b4fb0014df1047454e53",SOCIETY:"25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459",DJED:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344",SHEN:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344",WMT:"1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e776f726c646d6f62696c65746f6b656e",COPI:"b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0436f726e75636f70696173205b76696120436861696e506f72742e696f5d"},Oe=e=>`000643b0${e}`,Ke=e=>`000de140${e}`;var je=e=>{let t=[];return e.forEach(r=>{let o=t.find(n=>n.unit===r.unit);o?o.quantity=(BigInt(o.quantity)+BigInt(r.quantity)).toString():t.push(r)}),t};var Ge=["rate","address"],$e=["name","image","mediaType","description","instagram","twitter","discord","website"],We=["ticker","decimals"],D=e=>{switch(typeof e){case"object":if(e instanceof Array)return e.map(o=>D(o));let t=new Map;return Object.keys(e).forEach(o=>{t.set(o,D(e[o]))}),{alternative:0,fields:[t,1]};default:return e}};var ee=["testnet","preview","preprod","mainnet"],Xe=e=>ee.includes(e);var P=e=>{switch(e.type){case"SingleHostAddr":return{singleHostAddr:{ipv4:e.IPV4,ipv6:e.IPV6,port:e.port}};case"SingleHostName":return{singleHostName:{hostname:e.domainName,port:e.port}};case"MultiHostName":return{multiHostName:{dnsName:e.domainName}}}};var L=e=>({vrfKeyHash:e.vrfKeyHash,operator:e.operator,pledge:e.pledge,cost:e.cost,margin:e.margin,relays:e.relays.map(t=>P(t)),owners:e.owners,rewardAddress:e.rewardAddress,metadata:e.metadata?te(e.metadata):void 0}),te=e=>({url:e.URL,metadata:e.hash});var at=e=>{switch(e.type){case"RegisterPool":return{registerPool:{poolParams:L(e.poolParams)}};case"RegisterStake":return{registerStake:{stakeKeyHash:e.stakeKeyHash}};case"DelegateStake":return{delegateStake:{stakeKeyHash:e.stakeKeyHash,poolId:e.poolId}};case"DeregisterStake":return{deregisterStake:{stakeKeyHash:e.stakeKeyHash}};case"RetirePool":return{retirePool:{poolId:e.poolId,epoch:e.epoch}};case"VoteDelegation":return{voteDelegation:{stakeKeyHash:e.stakeKeyHash,drep:e.drep}};case"StakeAndVoteDelegation":return{stakeAndVoteDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,drep:e.drep}};case"StakeRegistrationAndDelegation":return{stakeRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,coin:e.coin}};case"VoteRegistrationAndDelegation":return{voteRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,drep:e.drep,coin:e.coin}};case"StakeVoteRegistrationAndDelegation":return{stakeVoteRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,drep:e.drep,coin:e.coin}};case"CommitteeHotAuth":return{committeeHotAuth:{committeeColdKeyHash:e.committeeColdKeyHash,committeeHotKeyHash:e.committeeHotKeyHash}};case"CommitteeColdResign":return{committeeColdResign:{committeeColdKeyHash:e.committeeColdKeyHash,anchor:e.anchor??null}};case"DRepRegistration":return{dRepRegistration:{votingKeyHash:e.votingKeyHash,coin:e.coin,anchor:e.anchor??null}};case"DRepDeregistration":return{dRepDeregistration:{votingKeyHash:e.votingKeyHash,coin:e.coin}};case"DRepUpdate":return{dRepUpdate:{votingKeyHash:e.votingKeyHash,anchor:e.anchor}}}};var it=()=>({inputs:[],outputs:[],extraInputs:[],collaterals:[],requiredSignatures:[],referenceInputs:[],mints:[],changeAddress:"",metadata:[],validityRange:{},certificates:[],withdrawals:[],signingKey:[],selectionConfig:{threshold:"5000000",strategy:"experimental",includeTxFees:!0}}),ct=e=>({invalidBefore:e.invalidBefore??null,invalidHereafter:e.invalidHereafter??null});var Qt=(e,t)=>({alternative:e,fields:t}),l=e=>({alternative:0,fields:e}),A=e=>({alternative:1,fields:e}),qt=e=>({alternative:2,fields:e});var Wt=(e,t)=>{if(e.length!==56&&e!=="")throw new Error(`Invalid policy id for [${e}] - should be ${y} bytes long or empty string for lovelace`);if(t.length>64)throw new Error(`Invalid asset name for [${t}] - should be less than 32 bytes (64 hex length) long`);return l([e,t])},re=(e,t)=>{if(e.length!==64)throw new Error("Invalid transaction hash - should be 32 bytes long");return l([l([e]),t])},Yt=(e,t)=>re(e,t),Xt=(e,t)=>[e,t];var V=(e,t=!1)=>e===""?A([]):t?l([l([A([e])])]):l([l([l([e])])]),r0=(e,t)=>l([{alternative:0,fields:[e]},V(t||"")]),o0=(e,t)=>l([{alternative:1,fields:[e]},V(t||"")]);var c0=e=>e?A([]):l([]),p0=e=>{let t=[];for(let r=0;r<e.length;r+=64){let o=e.substring(r,r+64);t.push(o)}return t},d0=e=>e.join("");var B=(e,t)=>{if(!Array.isArray(t))throw new Error("fields of a constructor must be an array");return{constructor:e,fields:t}},u=e=>B(0,e),h=e=>B(1,e),x0=e=>B(2,e);var A0=e=>e?h([]):u([]),oe=e=>T(e),T=e=>{if(e.length%2!==0)throw new Error("Invalid hex string - odd length: "+e);if(!/^[0-9a-fA-F]*$/.test(e))throw new Error("Invalid hex string - non-hex string character: "+e);return{bytes:e}},k=e=>({int:e}),ne=(e,t=!0)=>(t&&e.forEach(r=>{if(typeof r!="object")throw new Error("List item of JSON Cardano data type must be an object - "+r)}),{list:e}),M0=e=>ne((r=>{let o=[];for(let n=0;n<r.length;n+=64){let s=r.substring(n,n+64);o.push(s)}return o})(e).map(oe)),C0=e=>e.list.map(t=>t.bytes).join(""),O=(e,t=!0)=>({map:e.map(([r,o])=>{if(t&&(typeof r!="object"||typeof o!="object"))throw new Error(`Map item of JSON Cardano data type must be an object - ${r}, ${o}`);return{k:r,v:o}})});var _=e=>{if(e.length!==56)throw new Error(`Invalid hash for [${e}] - should be 56 bytes long`);return T(e)},K=e=>_(e),N=e=>_(e),ae=e=>{if(e.length!==y&&e!=="")throw new Error(`Invalid policy id for [${e}] - should be ${y} bytes long or empty string for lovelace`);return T(e)},w=e=>ae(e),se=e=>{if(e.length>64)throw new Error(`Invalid asset name for [${e}] - should be less than 32 bytes (64 hex length) long`);return T(e)},U=e=>se(e),K0=(e,t)=>u([w(e),U(t)]),ie=(e,t)=>{if(e.length!==64)throw new Error("Invalid transaction hash - should be 32 bytes long");return u([u([T(e)]),k(t)])},N0=(e,t)=>ie(e,t),w0=e=>({int:e}),U0=e=>({map:e.map(([t,r])=>({k:t,v:r}))}),E0=(e,t)=>({list:[e,t]});var F=(e,t=!1)=>e===""?h([]):t?u([u([h([K(e)])])]):u([u([u([N(e)])])]),q0=(e,t,r=!1)=>u([u([N(e)]),F(t||"",r)]),j0=(e,t,r=!1)=>u([h([K(e)]),F(t||"",r)]);var ce=e=>Buffer.from(e).toString("hex"),Z0=e=>Buffer.from(e,"hex"),er=e=>Buffer.from(e,"utf8").toString("hex"),tr=e=>Buffer.from(e,"hex").toString("utf8"),E=e=>e.length%2===0&&/^[0-9A-F]*$/i.test(e)?Buffer.from(e,"hex"):Buffer.from(e,"utf-8"),pe=e=>e.length%2===0&&/^[0-9A-F]*$/i.test(e)?e:ce(Buffer.from(e,"utf-8")),rr=e=>Buffer.from(e,"hex").toString("utf-8"),or=e=>{let t=e.slice(0,y),r=e.includes(".")?pe(e.split(".")[1]):e.slice(y);return{policyId:t,assetName:r}};var Q={mainnet:{zeroTime:1596059091e3,zeroSlot:4492800,slotLength:1e3,startEpoch:208,epochLength:432e3},preview:{zeroTime:1666656e6,zeroSlot:0,slotLength:1e3,startEpoch:183,epochLength:86400},preprod:{zeroTime:16540416e5+1728e6,zeroSlot:86400,slotLength:1e3,startEpoch:65,epochLength:432e3},testnet:{zeroTime:0,zeroSlot:0,slotLength:0,startEpoch:0,epochLength:0}},ar=(e,t)=>{let r=(e-t.zeroSlot)*t.slotLength;return t.zeroTime+r},de=(e,t)=>{let r=e-t.zeroTime;return Math.floor(r/t.slotLength)+t.zeroSlot},sr=(e,t=Date.now())=>de(t,Q[e]).toString(),ir=(e,t=Date.now())=>{let r=Q[e],n=(BigInt(t)/1000n-BigInt(r.zeroTime))/BigInt(r.epochLength)+BigInt(r.startEpoch);return Number(n)};var mr=e=>{let t=[],r={};return e.forEach(o=>{let n=o.unit.replace("lovelace",""),s=n.slice(0,56)||"",d=n.slice(56)||"";r[s]||(r[s]={}),r[s][d]?r[s][d]+=Number(o.quantity):r[s][d]=Number(o.quantity)}),Object.keys(r).forEach(o=>{let n=w(o),s=Object.keys(r[o]).map(i=>[U(i),k(r[o][i])]),d=O(s);t.push([n,d])}),O(t)},gr=e=>{let t=[];return e.map.forEach(r=>{let o=r.k.bytes;r.v.map.forEach(n=>{let s=n.k.bytes,d=n.v.int.toString(),i=o+s,f=i===""?"lovelace":i;t.push({unit:f,quantity:d})})}),t};var p=class e{value;constructor(t){this.value=BigInt(t)}divFloor(t){return this.value=this.value/t.value,this}checkedMul(t){return this.value*=t.value,this}checkedAdd(t){return this.value+=t.value,this}checkedSub(t){return this.value-=t.value,this}clampedSub(t){let r=this.value-t.value;return this.value=r<0n?0n:r,this}lessThan(t){return this.value<t.value}compare(t){return this.value===t.value?0:this.value<t.value?-1:1}static new=t=>new e(t);toString(){return this.value.toString()}};import fe from"@emurgo/cip14-js";var ue=fe,kr=(e,t)=>ue.default.fromParts(E(e),E(t)).fingerprint();var q=(e,t,r)=>{let o=new Map(e);o.set("lovelace",String(Number(o.get("lovelace")||0)+Number(r)));let n=new Map;for(let a=0;a<t.length;a++)n.set(a,t[a]);let s=new Set,d=new Set,i=new Set,f=new Set,b=new Set;for(let a=0;a<t.length;a++)switch(t[a].output.amount.length){case 1:{d.add(a);break}case 2:{i.add(a);break}case 3:{f.add(a);break}default:{b.add(a);break}}let g=(a,c,m)=>{let I=n.get(a);if(!I)return;let J=le(I,c);if(Number(J)>0){s.add(a),m.delete(a);for(let H of I.output.amount)o.set(H.unit,String(Number(o.get(H.unit))-Number(H.quantity)))}};for(let a of o.keys())if(a!="lovelace"){for(let c of i){let m=o.get(a);if(!m||Number(m)<=0)break;g(c,a,i)}for(let c of f){let m=o.get(a);if(!m||Number(m)<=0)break;g(c,a,f)}for(let c of b){let m=o.get(a);if(!m||Number(m)<=0)break;g(c,a,b)}}for(let a of d){let c=o.get("lovelace");if(!c||Number(c)<=0)break;g(a,"lovelace",d)}for(let a of i){let c=o.get("lovelace");if(!c||Number(c)<=0)break;g(a,"lovelace",i)}for(let a of f){let c=o.get("lovelace");if(!c||Number(c)<=0)break;g(a,"lovelace",f)}for(let a of b){let c=o.get("lovelace");if(!c||Number(c)<=0)break;g(a,"lovelace",b)}for(let a of o.keys())if(Number(o.get(a))>0)return console.log("Insufficient funds for",a),console.log("Remaining quantity",Number(o.get(a))),[];let C=[];for(let a of s){let c=n.get(a);c&&C.push(c)}return C},le=(e,t)=>{for(let r of e.output.amount)if(r.unit==t)return r.quantity;return"0"};var me=(e,t)=>Array.from(t,r=>({unit:r[0],quantity:p.new(r[1])})).every(r=>e.filter(o=>o.output.amount.find(n=>n.unit===r.unit)!==void 0).reduce((o,n)=>{let s=n.output.amount.reduce((d,i)=>d.checkedAdd(p.new(r.unit===i.unit?i.quantity:"0")),p.new("0"));return o.checkedAdd(s)},p.new("0")).lessThan(r.quantity)===!1),M=(e,t)=>{let r=p.new(e.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0");return p.new(t.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0").compare(r)},j=e=>{let{maxTxSize:t,minFeeA:r,minFeeB:o}=e;return p.new(v(t,r,o))},R=e=>e.output.amount.length>1,z=e=>e.reduce((t,r)=>{let o=r.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0";return t.checkedAdd(p.new(o))},p.new("0")),G=(e,t)=>{let r=t.sort(M);return x(r,new Map([["lovelace",e]]))},x=(e,t,r=[])=>e.length===0||me(r,t)?r:ge(e[0],t)?x(e.slice(1),t,[...r,e[0]]):x(e.slice(1),t,r),ge=(e,t)=>Array.from(t.keys()).some(r=>e.output.amount.find(o=>o.unit===r)!==void 0);var $=(e,t,r="5000000")=>{let o=p.new(e.get("lovelace")??"0").checkedAdd(p.new(r)),n=t.filter(i=>i.output.amount.filter(f=>f.unit!=="lovelace").some(f=>e.has(f.unit))),s=z(n);return[...s.lessThan(o)?G(o.clampedSub(s).toString(),t.filter(i=>!n.some(f=>f.input.txHash===i.input.txHash&&f.input.outputIndex===i.input.outputIndex))):[],...n]};var W=(e,t,r=!1,{maxTxSize:o,minFeeA:n,minFeeB:s}=S)=>{let d=t.filter(C=>R(C)===!1).sort(M),i=p.new(v(o,n,s)),f=r?p.new(e).checkedAdd(i).toString():e;return x(d,new Map([["lovelace",f]]))};var Y=(e,t,r=!1,o=S)=>{let n=t.filter(R).sort(M),s=j(o),d=e.get("lovelace")??"0",i=r?p.new(d).checkedAdd(s).toString():d;return e.set("lovelace",i),x(n,e)};var X=class{threshold;includeTxFees;constructor(t="5000000",r=!0){this.threshold=t,this.includeTxFees=r}largestFirst(t,r){let o=t.get("lovelace")??"0",n=BigInt(o)+BigInt(this.threshold);return W(n.toString(),r,this.includeTxFees)}keepRelevant(t,r){return $(t,r,this.threshold)}largestFirstMultiAsset(t,r){let o=t.get("lovelace")??"0";return t.set("lovelace",(BigInt(o)+BigInt(this.threshold)).toString()),Y(t,r,this.includeTxFees)}experimental(t,r){return q(t,r,this.threshold)}};import{generateMnemonic as yo,mnemonicToEntropy as xo}from"bip39";export{ue as AssetFingerprint,p as BigNum,Oe as CIP68_100,Ke as CIP68_222,S as DEFAULT_PROTOCOL_PARAMETERS,Ce as DEFAULT_REDEEMER_BUDGET,Se as DEFAULT_V1_COST_MODEL_LIST,he as DEFAULT_V2_COST_MODEL_LIST,ke as HARDENED_KEY_START,ve as LANGUAGE_VERSIONS,y as POLICY_ID_LENGTH,Q as SLOT_CONFIG_NETWORK,Re as SUPPORTED_CLOCKS,Ie as SUPPORTED_HANDLES,Z as SUPPORTED_LANGUAGE_VIEWS,He as SUPPORTED_OGMIOS_LINKS,Be as SUPPORTED_TOKENS,xe as SUPPORTED_WALLETS,X as UtxoSelection,K0 as assetClass,se as assetName,O as assocMap,A0 as bool,oe as builtinByteString,T as byteString,ce as bytesToHex,at as certificateToObj,B as conStr,u as conStr0,h as conStr1,x0 as conStr2,w as currencySymbol,U0 as dict,it as emptyTxBuilderBody,q as experimentalSelectUtxos,pe as fromUTF8,We as fungibleAssetKeys,yo as generateMnemonic,_ as hashByteString,Z0 as hexToBytes,tr as hexToString,k as integer,Xe as isNetwork,$ as keepRelevant,W as largestFirst,Y as largestFirstMultiAsset,ne as list,Wt as mAssetClass,c0 as mBool,Qt as mConStr,l as mConStr0,A as mConStr1,qt as mConStr2,V as mMaybeStakingHash,re as mOutputReference,d0 as mPlutusBSArrayToString,r0 as mPubKeyAddress,o0 as mScriptAddress,p0 as mStringToPlutusBSArray,Xt as mTuple,Yt as mTxOutRef,F as maybeStakingHash,je as mergeAssets,$e as metadataStandardKeys,D as metadataToCip68,xo as mnemonicToEntropy,ie as outputReference,or as parseAssetUnit,gr as parsePlutusValueToAssets,C0 as plutusBSArrayToString,ae as policyId,te as poolMetadataToObj,L as poolParamsToObj,w0 as posixTime,q0 as pubKeyAddress,N as pubKeyHash,P as relayToObj,ir as resolveEpochNo,kr as resolveFingerprint,Ae as resolveLanguageView,sr as resolveSlotNo,v as resolveTxFees,Ge as royaltiesStandardKeys,j0 as scriptAddress,K as scriptHash,ar as slotToBeginUnixTime,M0 as stringToBSArray,er as stringToHex,E as toBytes,rr as toUTF8,U as tokenName,E0 as tuple,N0 as txOutRef,de as unixTimeToEnclosingSlot,ct as validityRangeToObj,mr as value};
|
|
1
|
+
var h={epoch:0,coinsPerUtxoSize:4310,priceMem:.0577,priceStep:721e-7,minFeeA:44,minFeeB:155381,keyDeposit:2e6,maxTxSize:16384,maxValSize:5e3,poolDeposit:5e8,maxCollateralInputs:3,decentralisation:0,maxBlockSize:98304,collateralPercent:150,maxBlockHeaderSize:1100,minPoolCost:"340000000",maxTxExMem:"16000000",maxTxExSteps:"10000000000",maxBlockExMem:"80000000",maxBlockExSteps:"40000000000"},C=(e,t=h.minFeeA,r=h.minFeeB)=>(BigInt(t)*BigInt(e)+BigInt(r)).toString();var be=["begin","eternl","flint","lace","nami","nufi","gerowallet","typhoncip30","vespr","yoroi"];var Se=[205665,812,1,1,1e3,571,0,1,1e3,24177,4,1,1e3,32,117366,10475,4,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,100,100,23e3,100,19537,32,175354,32,46417,4,221973,511,0,1,89141,32,497525,14068,4,2,196500,453240,220,0,1,1,1e3,28662,4,2,245e3,216773,62,1,1060367,12586,1,208512,421,1,187e3,1e3,52998,1,80436,32,43249,32,1e3,32,80556,1,57667,4,1e3,10,197145,156,1,197145,156,1,204924,473,1,208896,511,1,52467,32,64832,32,65493,32,22558,32,16563,32,76511,32,196500,453240,220,0,1,1,69522,11687,0,1,60091,32,196500,453240,220,0,1,1,196500,453240,220,0,1,1,806990,30482,4,1927926,82523,4,265318,0,4,0,85931,32,205665,812,1,1,41182,32,212342,32,31220,32,32696,32,43357,32,32247,32,38314,32,57996947,18975,10],Te=[205665,812,1,1,1e3,571,0,1,1e3,24177,4,1,1e3,32,117366,10475,4,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,23e3,100,100,100,23e3,100,19537,32,175354,32,46417,4,221973,511,0,1,89141,32,497525,14068,4,2,196500,453240,220,0,1,1,1e3,28662,4,2,245e3,216773,62,1,1060367,12586,1,208512,421,1,187e3,1e3,52998,1,80436,32,43249,32,1e3,32,80556,1,57667,4,1e3,10,197145,156,1,197145,156,1,204924,473,1,208896,511,1,52467,32,64832,32,65493,32,22558,32,16563,32,76511,32,196500,453240,220,0,1,1,69522,11687,0,1,60091,32,196500,453240,220,0,1,1,196500,453240,220,0,1,1,1159724,392670,0,2,806990,30482,4,1927926,82523,4,265318,0,4,0,85931,32,205665,812,1,1,41182,32,212342,32,31220,32,32696,32,43357,32,32247,32,38314,32,35892428,10,57996947,18975,10,38887044,32947,10];var ee={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}},Me=(e,t)=>ee[e][t];var Ce={mem:7e6,steps:3e9},x=56,Ie={V1:"V1",V2:"V2",V3:"V3"},ke=2147483648,Be={testnet:["74","1598400","1595967616","432000"],preview:["183","15811222","1682467200","86400"],preprod:["65","26438400","1682121600","432000"],mainnet:["208","4492800","1596059091","432000"]},Oe={0:"8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",1:"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"},Re={mainnet:"wss://ogmios-api.mainnet.dandelion.link",preprod:"wss://ogmios-api.iohk-preprod.dandelion.link",preview:"__TBD_SOON_TM__",testnet:"wss://ogmios-api.testnet.dandelion.link"},He={LQ:"da8c30857834c6ae7203935b89278c532b3995245295456f993e1d244c51",MIN:"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e",NTX:"edfd7a1d77bcb8b884c474bdc92a16002d1fb720e454fa6e993444794e5458",iBTC:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069425443",iETH:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069455448",iUSD:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069555344",MILK:"8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa4d494c4b",AGIX:"f43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc53541474958",MELD:"6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d104d454c44",INDY:"533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0494e4459",CLAY:"38ad9dc3aec6a2f38e220142b9aa6ade63ebe71f65e7cc2b7d8a8535434c4159",MCOS:"6f46e1304b16d884c85c62fb0eef35028facdc41aaa0fd319a152ed64d434f53",DING:"ce5b9e0f8a88255b65f2e4d065c6e716e9fa9a8a86dfb86423dd1ac044494e47",GERO:"10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b64745524f",NMKR:"5dac8536653edc12f6f5e1045d8164b9f59998d3bdc300fc928434894e4d4b52",PAVIA:"884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903ae5041564941",HOSKY:"a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235484f534b59",YUMMI:"078eafce5cd7edafdf63900edef2c1ea759e77f30ca81d6bbdeec92479756d6d69",C3:"8e51398904a5d3fc129fbf4f1589701de23c7824d5c90fdb9490e15a434841524c4933",GIMBAL:"2b0a04a7b60132b1805b296c7fcb3b217ff14413991bf76f72663c3067696d62616c",SUNDAE:"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145",GREENS:"4623ab311b7d982d8d26fcbe1a9439ca56661aafcdcd8d8a0ef31fd6475245454e53",GENS:"dda5fdb1002f7389b33e036b6afee82a8189becb6cba852e8b79b4fb0014df1047454e53",SOCIETY:"25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459",DJED:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344",SHEN:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344",WMT:"1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e776f726c646d6f62696c65746f6b656e",COPI:"b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0436f726e75636f70696173205b76696120436861696e506f72742e696f5d"},Ke=e=>`000643b0${e}`,Ne=e=>`000de140${e}`;var ze=e=>{let t=[];return e.forEach(r=>{let o=t.find(n=>n.unit===r.unit);o?o.quantity=(BigInt(o.quantity)+BigInt(r.quantity)).toString():t.push(r)}),t};var $e=["rate","address"],We=["name","image","mediaType","description","instagram","twitter","discord","website"],Ye=["ticker","decimals"],P=e=>{switch(typeof e){case"object":if(e instanceof Array)return e.map(o=>P(o));let t=new Map;return Object.keys(e).forEach(o=>{t.set(o,P(e[o]))}),{alternative:0,fields:[t,1]};default:return e}};var te=["testnet","preview","preprod","mainnet"],Je=e=>te.includes(e);var V=e=>{switch(e.type){case"SingleHostAddr":return{singleHostAddr:{ipv4:e.IPV4,ipv6:e.IPV6,port:e.port}};case"SingleHostName":return{singleHostName:{hostname:e.domainName,port:e.port}};case"MultiHostName":return{multiHostName:{dnsName:e.domainName}}}};var L=e=>({vrfKeyHash:e.vrfKeyHash,operator:e.operator,pledge:e.pledge,cost:e.cost,margin:e.margin,relays:e.relays.map(t=>V(t)),owners:e.owners,rewardAddress:e.rewardAddress,metadata:e.metadata?re(e.metadata):void 0}),re=e=>({url:e.URL,metadata:e.hash});var st=e=>{switch(e.type){case"RegisterPool":return{registerPool:{poolParams:L(e.poolParams)}};case"RegisterStake":return{registerStake:{stakeKeyHash:e.stakeKeyHash}};case"DelegateStake":return{delegateStake:{stakeKeyHash:e.stakeKeyHash,poolId:e.poolId}};case"DeregisterStake":return{deregisterStake:{stakeKeyHash:e.stakeKeyHash}};case"RetirePool":return{retirePool:{poolId:e.poolId,epoch:e.epoch}};case"VoteDelegation":return{voteDelegation:{stakeKeyHash:e.stakeKeyHash,drep:e.drep}};case"StakeAndVoteDelegation":return{stakeAndVoteDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,drep:e.drep}};case"StakeRegistrationAndDelegation":return{stakeRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,coin:e.coin}};case"VoteRegistrationAndDelegation":return{voteRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,drep:e.drep,coin:e.coin}};case"StakeVoteRegistrationAndDelegation":return{stakeVoteRegistrationAndDelegation:{stakeKeyHash:e.stakeKeyHash,poolKeyHash:e.poolKeyHash,drep:e.drep,coin:e.coin}};case"CommitteeHotAuth":return{committeeHotAuth:{committeeColdKeyHash:e.committeeColdKeyHash,committeeHotKeyHash:e.committeeHotKeyHash}};case"CommitteeColdResign":return{committeeColdResign:{committeeColdKeyHash:e.committeeColdKeyHash,anchor:e.anchor??null}};case"DRepRegistration":return{dRepRegistration:{votingKeyHash:e.votingKeyHash,coin:e.coin,anchor:e.anchor??null}};case"DRepDeregistration":return{dRepDeregistration:{votingKeyHash:e.votingKeyHash,coin:e.coin}};case"DRepUpdate":return{dRepUpdate:{votingKeyHash:e.votingKeyHash,anchor:e.anchor}}}};var ct=()=>({inputs:[],outputs:[],extraInputs:[],collaterals:[],requiredSignatures:[],referenceInputs:[],mints:[],changeAddress:"",metadata:[],validityRange:{},certificates:[],withdrawals:[],signingKey:[],selectionConfig:{threshold:"5000000",strategy:"experimental",includeTxFees:!0}}),pt=e=>({invalidBefore:e.invalidBefore??null,invalidHereafter:e.invalidHereafter??null});var Qt=(e,t)=>({alternative:e,fields:t}),l=e=>({alternative:0,fields:e}),A=e=>({alternative:1,fields:e}),jt=e=>({alternative:2,fields:e});var Yt=(e,t)=>{if(e.length!==56&&e!=="")throw new Error(`Invalid policy id for [${e}] - should be ${x} bytes long or empty string for lovelace`);if(t.length>64)throw new Error(`Invalid asset name for [${t}] - should be less than 32 bytes (64 hex length) long`);return l([e,t])},oe=(e,t)=>{if(e.length!==64)throw new Error("Invalid transaction hash - should be 32 bytes long");return l([l([e]),t])},Xt=(e,t)=>oe(e,t),Jt=(e,t)=>[e,t];var _=(e,t=!1)=>e===""?A([]):t?l([l([A([e])])]):l([l([l([e])])]),o0=(e,t)=>l([{alternative:0,fields:[e]},_(t||"")]),n0=(e,t)=>l([{alternative:1,fields:[e]},_(t||"")]);var p0=e=>e?A([]):l([]),u0=e=>{let t=[];for(let r=0;r<e.length;r+=64){let o=e.substring(r,r+64);t.push(o)}return t},d0=e=>e.join("");var H=(e,t)=>{if(!Array.isArray(t))throw new Error("fields of a constructor must be an array");return{constructor:e,fields:t}},f=e=>H(0,e),S=e=>H(1,e),b0=e=>H(2,e);var M0=e=>e?S([]):f([]),ne=e=>T(e),T=e=>{if(e.length%2!==0)throw new Error("Invalid hex string - odd length: "+e);if(!/^[0-9a-fA-F]*$/.test(e))throw new Error("Invalid hex string - non-hex string character: "+e);return{bytes:e}},I=e=>({int:e}),ae=(e,t=!0)=>(t&&e.forEach(r=>{if(typeof r!="object")throw new Error("List item of JSON Cardano data type must be an object - "+r)}),{list:e}),v0=e=>ae((r=>{let o=[];for(let n=0;n<r.length;n+=64){let s=r.substring(n,n+64);o.push(s)}return o})(e).map(ne)),C0=e=>e.list.map(t=>t.bytes).join(""),K=(e,t=!0)=>({map:e.map(([r,o])=>{if(t&&(typeof r!="object"||typeof o!="object"))throw new Error(`Map item of JSON Cardano data type must be an object - ${r}, ${o}`);return{k:r,v:o}})});var F=e=>{if(e.length!==56)throw new Error(`Invalid hash for [${e}] - should be 56 bytes long`);return T(e)},N=e=>F(e),w=e=>F(e),se=e=>{if(e.length!==x&&e!=="")throw new Error(`Invalid policy id for [${e}] - should be ${x} bytes long or empty string for lovelace`);return T(e)},U=e=>se(e),ie=e=>{if(e.length>64)throw new Error(`Invalid asset name for [${e}] - should be less than 32 bytes (64 hex length) long`);return T(e)},E=e=>ie(e),N0=(e,t)=>f([U(e),E(t)]),ce=(e,t)=>{if(e.length!==64)throw new Error("Invalid transaction hash - should be 32 bytes long");return f([f([T(e)]),I(t)])},w0=(e,t)=>ce(e,t),U0=e=>({int:e}),E0=e=>({map:e.map(([t,r])=>({k:t,v:r}))}),D0=(e,t)=>({list:[e,t]});var q=(e,t=!1)=>e===""?S([]):t?f([f([S([N(e)])])]):f([f([f([w(e)])])]),j0=(e,t,r=!1)=>f([f([w(e)]),q(t||"",r)]),z0=(e,t,r=!1)=>f([S([N(e)]),q(t||"",r)]);var pe=e=>Buffer.from(e).toString("hex"),er=e=>Buffer.from(e,"hex"),tr=e=>Buffer.from(e,"utf8").toString("hex"),rr=e=>Buffer.from(e,"hex").toString("utf8"),D=e=>e.length%2===0&&/^[0-9A-F]*$/i.test(e)?Buffer.from(e,"hex"):Buffer.from(e,"utf-8"),ue=e=>e.length%2===0&&/^[0-9A-F]*$/i.test(e)?e:pe(Buffer.from(e,"utf-8")),or=e=>Buffer.from(e,"hex").toString("utf-8"),nr=e=>{let t=e.slice(0,x),r=e.includes(".")?ue(e.split(".")[1]):e.slice(x);return{policyId:t,assetName:r}};var Q={mainnet:{zeroTime:1596059091e3,zeroSlot:4492800,slotLength:1e3,startEpoch:208,epochLength:432e3},preview:{zeroTime:1666656e6,zeroSlot:0,slotLength:1e3,startEpoch:183,epochLength:86400},preprod:{zeroTime:16540416e5+1728e6,zeroSlot:86400,slotLength:1e3,startEpoch:65,epochLength:432e3},testnet:{zeroTime:0,zeroSlot:0,slotLength:0,startEpoch:0,epochLength:0}},sr=(e,t)=>{let r=(e-t.zeroSlot)*t.slotLength;return t.zeroTime+r},de=(e,t)=>{let r=e-t.zeroTime;return Math.floor(r/t.slotLength)+t.zeroSlot},ir=(e,t=Date.now())=>de(t,Q[e]).toString(),cr=(e,t=Date.now())=>{let r=Q[e],n=(BigInt(t)/1000n-BigInt(r.zeroTime))/BigInt(r.epochLength)+BigInt(r.startEpoch);return Number(n)};var i=class e{value;constructor(t){if(!t){this.value=BigInt(0);return}this.value=BigInt(t)}static new(t){return t?new e(t):new e(0)}divFloor(t){return this.value=this.value/t.value,this}checkedMul(t){return this.value*=t.value,this}checkedAdd(t){return this.value+=t.value,this}checkedSub(t){return this.value-=t.value,this}clampedSub(t){let r=this.value-t.value;return this.value=r<0n?0n:r,this}lessThan(t){return this.value<t.value}compare(t){return this.value===t.value?0:this.value<t.value?-1:1}toString(){return this.value.toString()}};import fe from"@emurgo/cip14-js";var le=fe,lr=(e,t)=>le.default.fromParts(D(e),D(t)).fingerprint();var vr=e=>k.fromAssets(e).toJSON(),Cr=e=>k.fromAssets(e).toData(),k=class e{value;constructor(t={}){this.value=t}static fromAssets=t=>{let r=new e;return r.addAssets(t),r};static fromValue=t=>{let r=[];return t.map.forEach(o=>{let n=o.k.bytes;o.v.map.forEach(s=>{let c=s.k.bytes,p=s.v.int.toString(),d=n+c,g=d===""?"lovelace":d;r.push({unit:g,quantity:p})})}),e.fromAssets(r)};addAsset=t=>{let r=BigInt(t.quantity),{unit:o}=t;return this.value[o]?this.value[o]+=r:this.value[o]=r,this};addAssets=t=>(t.forEach(r=>{this.addAsset(r)}),this);negateAsset=t=>{let{unit:r,quantity:o}=t,n=i.new(this.value[r]);return n.clampedSub(i.new(o)),n.value===BigInt(0)?delete this.value[r]:this.value[r]=n.value,this};negateAssets=t=>(t.forEach(r=>{this.negateAsset(r)}),this);get=t=>this.value[t]?BigInt(this.value[t]):BigInt(0);units=()=>Object.keys(this.value);geq=t=>Object.keys(t.value).every(r=>this.geqUnit(r,t));geqUnit=(t,r)=>this.value[t]===void 0||r.value[t]===void 0?!1:BigInt(this.value[t])>=BigInt(r.value[t]);leq=t=>Object.keys(t.value).every(r=>this.leqUnit(r,t));leqUnit=(t,r)=>this.value[t]===void 0||r.value[t]===void 0?!1:BigInt(this.value[t])<=BigInt(r.value[t]);isEmpty=()=>Object.keys(this.value).length===0;merge=t=>((Array.isArray(t)?t:[t]).forEach(o=>{Object.entries(o.value).forEach(([n,s])=>{this.value[n]=(this.value[n]!==void 0?BigInt(this.value[n]):BigInt(0))+BigInt(s)})}),this);toAssets=()=>{let t=[];return Object.entries(this.value).forEach(([r,o])=>{t.push({unit:r,quantity:o.toString()})}),t};toData=()=>{let t=new Map;return this.toAssets().forEach(r=>{let o=r.unit.slice(0,56)||"",n=r.unit.slice(56)||"";t.has(o)||t.set(o,new Map);let s=t.get(o),c=s?.get(n);c?s.set(n,c+BigInt(r.quantity)):s.set(n,BigInt(r.quantity))}),t};toJSON=()=>{let t=[],r={};return this.toAssets().forEach(o=>{let n=o.unit.replace("lovelace",""),s=n.slice(0,56)||"",c=n.slice(56)||"";r[s]||(r[s]={}),r[s][c]?r[s][c]+=Number(o.quantity):r[s][c]=Number(o.quantity)}),Object.keys(r).forEach(o=>{let n=U(o),s=Object.keys(r[o]).map(p=>[E(p),I(r[o][p])]),c=K(s);t.push([n,c])}),K(t)}};var j=(e,t,r)=>{let o=new Map(e);o.set("lovelace",String(Number(o.get("lovelace")||0)+Number(r)));let n=new Map;for(let a=0;a<t.length;a++)n.set(a,t[a]);let s=new Set,c=new Set,p=new Set,d=new Set,g=new Set;for(let a=0;a<t.length;a++)switch(t[a].output.amount.length){case 1:{c.add(a);break}case 2:{p.add(a);break}case 3:{d.add(a);break}default:{g.add(a);break}}let y=(a,u,m)=>{let O=n.get(a);if(!O)return;let Z=me(O,u);if(Number(Z)>0){s.add(a),m.delete(a);for(let R of O.output.amount)o.set(R.unit,String(Number(o.get(R.unit))-Number(R.quantity)))}};for(let a of o.keys())if(a!="lovelace"){for(let u of p){let m=o.get(a);if(!m||Number(m)<=0)break;y(u,a,p)}for(let u of d){let m=o.get(a);if(!m||Number(m)<=0)break;y(u,a,d)}for(let u of g){let m=o.get(a);if(!m||Number(m)<=0)break;y(u,a,g)}}for(let a of c){let u=o.get("lovelace");if(!u||Number(u)<=0)break;y(a,"lovelace",c)}for(let a of p){let u=o.get("lovelace");if(!u||Number(u)<=0)break;y(a,"lovelace",p)}for(let a of d){let u=o.get("lovelace");if(!u||Number(u)<=0)break;y(a,"lovelace",d)}for(let a of g){let u=o.get("lovelace");if(!u||Number(u)<=0)break;y(a,"lovelace",g)}for(let a of o.keys())if(Number(o.get(a))>0)return console.log("Insufficient funds for",a),console.log("Remaining quantity",Number(o.get(a))),[];let v=[];for(let a of s){let u=n.get(a);u&&v.push(u)}return v},me=(e,t)=>{for(let r of e.output.amount)if(r.unit==t)return r.quantity;return"0"};var ge=(e,t)=>Array.from(t,r=>({unit:r[0],quantity:i.new(r[1])})).every(r=>e.filter(o=>o.output.amount.find(n=>n.unit===r.unit)!==void 0).reduce((o,n)=>{let s=n.output.amount.reduce((c,p)=>c.checkedAdd(i.new(r.unit===p.unit?p.quantity:"0")),i.new("0"));return o.checkedAdd(s)},i.new("0")).lessThan(r.quantity)===!1),M=(e,t)=>{let r=i.new(e.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0");return i.new(t.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0").compare(r)},z=e=>{let{maxTxSize:t,minFeeA:r,minFeeB:o}=e;return i.new(C(t,r,o))},B=e=>e.output.amount.length>1,G=e=>e.reduce((t,r)=>{let o=r.output.amount.find(n=>n.unit==="lovelace")?.quantity??"0";return t.checkedAdd(i.new(o))},i.new("0")),$=(e,t)=>{let r=t.sort(M);return b(r,new Map([["lovelace",e]]))},b=(e,t,r=[])=>e.length===0||ge(r,t)?r:ye(e[0],t)?b(e.slice(1),t,[...r,e[0]]):b(e.slice(1),t,r),ye=(e,t)=>Array.from(t.keys()).some(r=>e.output.amount.find(o=>o.unit===r)!==void 0);var W=(e,t,r="5000000")=>{let o=i.new(e.get("lovelace")??"0").checkedAdd(i.new(r)),n=t.filter(p=>p.output.amount.filter(d=>d.unit!=="lovelace").some(d=>e.has(d.unit))),s=G(n);return[...s.lessThan(o)?$(o.clampedSub(s).toString(),t.filter(p=>!n.some(d=>d.input.txHash===p.input.txHash&&d.input.outputIndex===p.input.outputIndex))):[],...n]};var Y=(e,t,r=!1,{maxTxSize:o,minFeeA:n,minFeeB:s}=h)=>{let c=t.filter(v=>B(v)===!1).sort(M),p=i.new(C(o,n,s)),d=r?i.new(e).checkedAdd(p).toString():e;return b(c,new Map([["lovelace",d]]))};var X=(e,t,r=!1,o=h)=>{let n=t.filter(B).sort(M),s=z(o),c=e.get("lovelace")??"0",p=r?i.new(c).checkedAdd(s).toString():c;return e.set("lovelace",p),b(n,e)};var J=class{threshold;includeTxFees;constructor(t="5000000",r=!0){this.threshold=t,this.includeTxFees=r}largestFirst(t,r){let o=t.get("lovelace")??"0",n=BigInt(o)+BigInt(this.threshold);return Y(n.toString(),r,this.includeTxFees)}keepRelevant(t,r){return W(t,r,this.threshold)}largestFirstMultiAsset(t,r){let o=t.get("lovelace")??"0";return t.set("lovelace",(BigInt(o)+BigInt(this.threshold)).toString()),X(t,r,this.includeTxFees)}experimental(t,r){return j(t,r,this.threshold)}};import{generateMnemonic as bo,mnemonicToEntropy as ho}from"bip39";export{le as AssetFingerprint,i as BigNum,Ke as CIP68_100,Ne as CIP68_222,h as DEFAULT_PROTOCOL_PARAMETERS,Ce as DEFAULT_REDEEMER_BUDGET,Se as DEFAULT_V1_COST_MODEL_LIST,Te as DEFAULT_V2_COST_MODEL_LIST,ke as HARDENED_KEY_START,Ie as LANGUAGE_VERSIONS,k as MeshValue,x as POLICY_ID_LENGTH,Q as SLOT_CONFIG_NETWORK,Be as SUPPORTED_CLOCKS,Oe as SUPPORTED_HANDLES,ee as SUPPORTED_LANGUAGE_VIEWS,Re as SUPPORTED_OGMIOS_LINKS,He as SUPPORTED_TOKENS,be as SUPPORTED_WALLETS,J as UtxoSelection,N0 as assetClass,ie as assetName,K as assocMap,M0 as bool,ne as builtinByteString,T as byteString,pe as bytesToHex,st as certificateToObj,H as conStr,f as conStr0,S as conStr1,b0 as conStr2,U as currencySymbol,E0 as dict,ct as emptyTxBuilderBody,j as experimentalSelectUtxos,ue as fromUTF8,Ye as fungibleAssetKeys,bo as generateMnemonic,F as hashByteString,er as hexToBytes,rr as hexToString,I as integer,Je as isNetwork,W as keepRelevant,Y as largestFirst,X as largestFirstMultiAsset,ae as list,Yt as mAssetClass,p0 as mBool,Qt as mConStr,l as mConStr0,A as mConStr1,jt as mConStr2,_ as mMaybeStakingHash,oe as mOutputReference,d0 as mPlutusBSArrayToString,o0 as mPubKeyAddress,n0 as mScriptAddress,u0 as mStringToPlutusBSArray,Jt as mTuple,Xt as mTxOutRef,Cr as mValue,q as maybeStakingHash,ze as mergeAssets,We as metadataStandardKeys,P as metadataToCip68,ho as mnemonicToEntropy,ce as outputReference,nr as parseAssetUnit,C0 as plutusBSArrayToString,se as policyId,re as poolMetadataToObj,L as poolParamsToObj,U0 as posixTime,j0 as pubKeyAddress,w as pubKeyHash,V as relayToObj,cr as resolveEpochNo,lr as resolveFingerprint,Me as resolveLanguageView,ir as resolveSlotNo,C as resolveTxFees,$e as royaltiesStandardKeys,z0 as scriptAddress,N as scriptHash,sr as slotToBeginUnixTime,v0 as stringToBSArray,tr as stringToHex,D as toBytes,or as toUTF8,E as tokenName,D0 as tuple,w0 as txOutRef,de as unixTimeToEnclosingSlot,pt as validityRangeToObj,vr as value};
|