@meshsdk/common 1.6.2 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1635 -1
- package/dist/index.d.cts +127 -91
- package/dist/index.d.ts +127 -91
- package/dist/index.js +1505 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -1 +1,1635 @@
|
|
|
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});
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
AssetFingerprint: () => AssetFingerprint,
|
|
34
|
+
BigNum: () => BigNum,
|
|
35
|
+
CIP68_100: () => CIP68_100,
|
|
36
|
+
CIP68_222: () => CIP68_222,
|
|
37
|
+
DEFAULT_PROTOCOL_PARAMETERS: () => DEFAULT_PROTOCOL_PARAMETERS,
|
|
38
|
+
DEFAULT_REDEEMER_BUDGET: () => DEFAULT_REDEEMER_BUDGET,
|
|
39
|
+
DEFAULT_V1_COST_MODEL_LIST: () => DEFAULT_V1_COST_MODEL_LIST,
|
|
40
|
+
DEFAULT_V2_COST_MODEL_LIST: () => DEFAULT_V2_COST_MODEL_LIST,
|
|
41
|
+
HARDENED_KEY_START: () => HARDENED_KEY_START,
|
|
42
|
+
LANGUAGE_VERSIONS: () => LANGUAGE_VERSIONS,
|
|
43
|
+
MeshValue: () => MeshValue,
|
|
44
|
+
POLICY_ID_LENGTH: () => POLICY_ID_LENGTH,
|
|
45
|
+
SLOT_CONFIG_NETWORK: () => SLOT_CONFIG_NETWORK,
|
|
46
|
+
SUPPORTED_CLOCKS: () => SUPPORTED_CLOCKS,
|
|
47
|
+
SUPPORTED_HANDLES: () => SUPPORTED_HANDLES,
|
|
48
|
+
SUPPORTED_LANGUAGE_VIEWS: () => SUPPORTED_LANGUAGE_VIEWS,
|
|
49
|
+
SUPPORTED_OGMIOS_LINKS: () => SUPPORTED_OGMIOS_LINKS,
|
|
50
|
+
SUPPORTED_TOKENS: () => SUPPORTED_TOKENS,
|
|
51
|
+
SUPPORTED_WALLETS: () => SUPPORTED_WALLETS,
|
|
52
|
+
UtxoSelection: () => UtxoSelection,
|
|
53
|
+
assetClass: () => assetClass,
|
|
54
|
+
assetName: () => assetName,
|
|
55
|
+
assocMap: () => assocMap,
|
|
56
|
+
bool: () => bool,
|
|
57
|
+
builtinByteString: () => builtinByteString,
|
|
58
|
+
byteString: () => byteString,
|
|
59
|
+
bytesToHex: () => bytesToHex,
|
|
60
|
+
castProtocol: () => castProtocol,
|
|
61
|
+
conStr: () => conStr,
|
|
62
|
+
conStr0: () => conStr0,
|
|
63
|
+
conStr1: () => conStr1,
|
|
64
|
+
conStr2: () => conStr2,
|
|
65
|
+
currencySymbol: () => currencySymbol,
|
|
66
|
+
dict: () => dict,
|
|
67
|
+
emptyTxBuilderBody: () => emptyTxBuilderBody,
|
|
68
|
+
experimentalSelectUtxos: () => experimentalSelectUtxos,
|
|
69
|
+
fromUTF8: () => fromUTF8,
|
|
70
|
+
fungibleAssetKeys: () => fungibleAssetKeys,
|
|
71
|
+
generateMnemonic: () => import_bip39.generateMnemonic,
|
|
72
|
+
hashByteString: () => hashByteString,
|
|
73
|
+
hexToBytes: () => hexToBytes,
|
|
74
|
+
hexToString: () => hexToString,
|
|
75
|
+
integer: () => integer,
|
|
76
|
+
isNetwork: () => isNetwork,
|
|
77
|
+
keepRelevant: () => keepRelevant,
|
|
78
|
+
largestFirst: () => largestFirst,
|
|
79
|
+
largestFirstMultiAsset: () => largestFirstMultiAsset,
|
|
80
|
+
list: () => list,
|
|
81
|
+
mAssetClass: () => mAssetClass,
|
|
82
|
+
mBool: () => mBool,
|
|
83
|
+
mConStr: () => mConStr,
|
|
84
|
+
mConStr0: () => mConStr0,
|
|
85
|
+
mConStr1: () => mConStr1,
|
|
86
|
+
mConStr2: () => mConStr2,
|
|
87
|
+
mMaybeStakingHash: () => mMaybeStakingHash,
|
|
88
|
+
mOutputReference: () => mOutputReference,
|
|
89
|
+
mPlutusBSArrayToString: () => mPlutusBSArrayToString,
|
|
90
|
+
mPubKeyAddress: () => mPubKeyAddress,
|
|
91
|
+
mScriptAddress: () => mScriptAddress,
|
|
92
|
+
mStringToPlutusBSArray: () => mStringToPlutusBSArray,
|
|
93
|
+
mTuple: () => mTuple,
|
|
94
|
+
mTxOutRef: () => mTxOutRef,
|
|
95
|
+
mValue: () => mValue,
|
|
96
|
+
maybeStakingHash: () => maybeStakingHash,
|
|
97
|
+
mergeAssets: () => mergeAssets,
|
|
98
|
+
metadataStandardKeys: () => metadataStandardKeys,
|
|
99
|
+
metadataToCip68: () => metadataToCip68,
|
|
100
|
+
mnemonicToEntropy: () => import_bip39.mnemonicToEntropy,
|
|
101
|
+
outputReference: () => outputReference,
|
|
102
|
+
parseAssetUnit: () => parseAssetUnit,
|
|
103
|
+
plutusBSArrayToString: () => plutusBSArrayToString,
|
|
104
|
+
policyId: () => policyId,
|
|
105
|
+
posixTime: () => posixTime,
|
|
106
|
+
pubKeyAddress: () => pubKeyAddress,
|
|
107
|
+
pubKeyHash: () => pubKeyHash,
|
|
108
|
+
resolveEpochNo: () => resolveEpochNo,
|
|
109
|
+
resolveFingerprint: () => resolveFingerprint,
|
|
110
|
+
resolveLanguageView: () => resolveLanguageView,
|
|
111
|
+
resolveSlotNo: () => resolveSlotNo,
|
|
112
|
+
resolveTxFees: () => resolveTxFees,
|
|
113
|
+
royaltiesStandardKeys: () => royaltiesStandardKeys,
|
|
114
|
+
scriptAddress: () => scriptAddress,
|
|
115
|
+
scriptHash: () => scriptHash,
|
|
116
|
+
slotToBeginUnixTime: () => slotToBeginUnixTime,
|
|
117
|
+
stringToBSArray: () => stringToBSArray,
|
|
118
|
+
stringToHex: () => stringToHex,
|
|
119
|
+
toBytes: () => toBytes,
|
|
120
|
+
toUTF8: () => toUTF8,
|
|
121
|
+
tokenName: () => tokenName,
|
|
122
|
+
tuple: () => tuple,
|
|
123
|
+
txOutRef: () => txOutRef,
|
|
124
|
+
unixTimeToEnclosingSlot: () => unixTimeToEnclosingSlot,
|
|
125
|
+
validityRangeToObj: () => validityRangeToObj,
|
|
126
|
+
value: () => value
|
|
127
|
+
});
|
|
128
|
+
module.exports = __toCommonJS(src_exports);
|
|
129
|
+
|
|
130
|
+
// src/constants/protocol-parameters.ts
|
|
131
|
+
var DEFAULT_PROTOCOL_PARAMETERS = {
|
|
132
|
+
epoch: 0,
|
|
133
|
+
coinsPerUtxoSize: 4310,
|
|
134
|
+
priceMem: 0.0577,
|
|
135
|
+
priceStep: 721e-7,
|
|
136
|
+
minFeeA: 44,
|
|
137
|
+
minFeeB: 155381,
|
|
138
|
+
keyDeposit: 2e6,
|
|
139
|
+
maxTxSize: 16384,
|
|
140
|
+
maxValSize: 5e3,
|
|
141
|
+
poolDeposit: 5e8,
|
|
142
|
+
maxCollateralInputs: 3,
|
|
143
|
+
decentralisation: 0,
|
|
144
|
+
maxBlockSize: 98304,
|
|
145
|
+
collateralPercent: 150,
|
|
146
|
+
maxBlockHeaderSize: 1100,
|
|
147
|
+
minPoolCost: "340000000",
|
|
148
|
+
maxTxExMem: "16000000",
|
|
149
|
+
maxTxExSteps: "10000000000",
|
|
150
|
+
maxBlockExMem: "80000000",
|
|
151
|
+
maxBlockExSteps: "40000000000"
|
|
152
|
+
};
|
|
153
|
+
var resolveTxFees = (txSize, minFeeA = DEFAULT_PROTOCOL_PARAMETERS.minFeeA, minFeeB = DEFAULT_PROTOCOL_PARAMETERS.minFeeB) => {
|
|
154
|
+
const fees = BigInt(minFeeA) * BigInt(txSize) + BigInt(minFeeB);
|
|
155
|
+
return fees.toString();
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// src/constants/supported-wallets.ts
|
|
159
|
+
var SUPPORTED_WALLETS = [
|
|
160
|
+
"begin",
|
|
161
|
+
"eternl",
|
|
162
|
+
"flint",
|
|
163
|
+
"lace",
|
|
164
|
+
"nami",
|
|
165
|
+
"nufi",
|
|
166
|
+
"gerowallet",
|
|
167
|
+
"typhoncip30",
|
|
168
|
+
"vespr",
|
|
169
|
+
"yoroi"
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
// src/constants/cost-models.ts
|
|
173
|
+
var DEFAULT_V1_COST_MODEL_LIST = [
|
|
174
|
+
205665,
|
|
175
|
+
812,
|
|
176
|
+
1,
|
|
177
|
+
1,
|
|
178
|
+
1e3,
|
|
179
|
+
571,
|
|
180
|
+
0,
|
|
181
|
+
1,
|
|
182
|
+
1e3,
|
|
183
|
+
24177,
|
|
184
|
+
4,
|
|
185
|
+
1,
|
|
186
|
+
1e3,
|
|
187
|
+
32,
|
|
188
|
+
117366,
|
|
189
|
+
10475,
|
|
190
|
+
4,
|
|
191
|
+
23e3,
|
|
192
|
+
100,
|
|
193
|
+
23e3,
|
|
194
|
+
100,
|
|
195
|
+
23e3,
|
|
196
|
+
100,
|
|
197
|
+
23e3,
|
|
198
|
+
100,
|
|
199
|
+
23e3,
|
|
200
|
+
100,
|
|
201
|
+
23e3,
|
|
202
|
+
100,
|
|
203
|
+
100,
|
|
204
|
+
100,
|
|
205
|
+
23e3,
|
|
206
|
+
100,
|
|
207
|
+
19537,
|
|
208
|
+
32,
|
|
209
|
+
175354,
|
|
210
|
+
32,
|
|
211
|
+
46417,
|
|
212
|
+
4,
|
|
213
|
+
221973,
|
|
214
|
+
511,
|
|
215
|
+
0,
|
|
216
|
+
1,
|
|
217
|
+
89141,
|
|
218
|
+
32,
|
|
219
|
+
497525,
|
|
220
|
+
14068,
|
|
221
|
+
4,
|
|
222
|
+
2,
|
|
223
|
+
196500,
|
|
224
|
+
453240,
|
|
225
|
+
220,
|
|
226
|
+
0,
|
|
227
|
+
1,
|
|
228
|
+
1,
|
|
229
|
+
1e3,
|
|
230
|
+
28662,
|
|
231
|
+
4,
|
|
232
|
+
2,
|
|
233
|
+
245e3,
|
|
234
|
+
216773,
|
|
235
|
+
62,
|
|
236
|
+
1,
|
|
237
|
+
1060367,
|
|
238
|
+
12586,
|
|
239
|
+
1,
|
|
240
|
+
208512,
|
|
241
|
+
421,
|
|
242
|
+
1,
|
|
243
|
+
187e3,
|
|
244
|
+
1e3,
|
|
245
|
+
52998,
|
|
246
|
+
1,
|
|
247
|
+
80436,
|
|
248
|
+
32,
|
|
249
|
+
43249,
|
|
250
|
+
32,
|
|
251
|
+
1e3,
|
|
252
|
+
32,
|
|
253
|
+
80556,
|
|
254
|
+
1,
|
|
255
|
+
57667,
|
|
256
|
+
4,
|
|
257
|
+
1e3,
|
|
258
|
+
10,
|
|
259
|
+
197145,
|
|
260
|
+
156,
|
|
261
|
+
1,
|
|
262
|
+
197145,
|
|
263
|
+
156,
|
|
264
|
+
1,
|
|
265
|
+
204924,
|
|
266
|
+
473,
|
|
267
|
+
1,
|
|
268
|
+
208896,
|
|
269
|
+
511,
|
|
270
|
+
1,
|
|
271
|
+
52467,
|
|
272
|
+
32,
|
|
273
|
+
64832,
|
|
274
|
+
32,
|
|
275
|
+
65493,
|
|
276
|
+
32,
|
|
277
|
+
22558,
|
|
278
|
+
32,
|
|
279
|
+
16563,
|
|
280
|
+
32,
|
|
281
|
+
76511,
|
|
282
|
+
32,
|
|
283
|
+
196500,
|
|
284
|
+
453240,
|
|
285
|
+
220,
|
|
286
|
+
0,
|
|
287
|
+
1,
|
|
288
|
+
1,
|
|
289
|
+
69522,
|
|
290
|
+
11687,
|
|
291
|
+
0,
|
|
292
|
+
1,
|
|
293
|
+
60091,
|
|
294
|
+
32,
|
|
295
|
+
196500,
|
|
296
|
+
453240,
|
|
297
|
+
220,
|
|
298
|
+
0,
|
|
299
|
+
1,
|
|
300
|
+
1,
|
|
301
|
+
196500,
|
|
302
|
+
453240,
|
|
303
|
+
220,
|
|
304
|
+
0,
|
|
305
|
+
1,
|
|
306
|
+
1,
|
|
307
|
+
806990,
|
|
308
|
+
30482,
|
|
309
|
+
4,
|
|
310
|
+
1927926,
|
|
311
|
+
82523,
|
|
312
|
+
4,
|
|
313
|
+
265318,
|
|
314
|
+
0,
|
|
315
|
+
4,
|
|
316
|
+
0,
|
|
317
|
+
85931,
|
|
318
|
+
32,
|
|
319
|
+
205665,
|
|
320
|
+
812,
|
|
321
|
+
1,
|
|
322
|
+
1,
|
|
323
|
+
41182,
|
|
324
|
+
32,
|
|
325
|
+
212342,
|
|
326
|
+
32,
|
|
327
|
+
31220,
|
|
328
|
+
32,
|
|
329
|
+
32696,
|
|
330
|
+
32,
|
|
331
|
+
43357,
|
|
332
|
+
32,
|
|
333
|
+
32247,
|
|
334
|
+
32,
|
|
335
|
+
38314,
|
|
336
|
+
32,
|
|
337
|
+
57996947,
|
|
338
|
+
18975,
|
|
339
|
+
10
|
|
340
|
+
];
|
|
341
|
+
var DEFAULT_V2_COST_MODEL_LIST = [
|
|
342
|
+
205665,
|
|
343
|
+
812,
|
|
344
|
+
1,
|
|
345
|
+
1,
|
|
346
|
+
1e3,
|
|
347
|
+
571,
|
|
348
|
+
0,
|
|
349
|
+
1,
|
|
350
|
+
1e3,
|
|
351
|
+
24177,
|
|
352
|
+
4,
|
|
353
|
+
1,
|
|
354
|
+
1e3,
|
|
355
|
+
32,
|
|
356
|
+
117366,
|
|
357
|
+
10475,
|
|
358
|
+
4,
|
|
359
|
+
23e3,
|
|
360
|
+
100,
|
|
361
|
+
23e3,
|
|
362
|
+
100,
|
|
363
|
+
23e3,
|
|
364
|
+
100,
|
|
365
|
+
23e3,
|
|
366
|
+
100,
|
|
367
|
+
23e3,
|
|
368
|
+
100,
|
|
369
|
+
23e3,
|
|
370
|
+
100,
|
|
371
|
+
100,
|
|
372
|
+
100,
|
|
373
|
+
23e3,
|
|
374
|
+
100,
|
|
375
|
+
19537,
|
|
376
|
+
32,
|
|
377
|
+
175354,
|
|
378
|
+
32,
|
|
379
|
+
46417,
|
|
380
|
+
4,
|
|
381
|
+
221973,
|
|
382
|
+
511,
|
|
383
|
+
0,
|
|
384
|
+
1,
|
|
385
|
+
89141,
|
|
386
|
+
32,
|
|
387
|
+
497525,
|
|
388
|
+
14068,
|
|
389
|
+
4,
|
|
390
|
+
2,
|
|
391
|
+
196500,
|
|
392
|
+
453240,
|
|
393
|
+
220,
|
|
394
|
+
0,
|
|
395
|
+
1,
|
|
396
|
+
1,
|
|
397
|
+
1e3,
|
|
398
|
+
28662,
|
|
399
|
+
4,
|
|
400
|
+
2,
|
|
401
|
+
245e3,
|
|
402
|
+
216773,
|
|
403
|
+
62,
|
|
404
|
+
1,
|
|
405
|
+
1060367,
|
|
406
|
+
12586,
|
|
407
|
+
1,
|
|
408
|
+
208512,
|
|
409
|
+
421,
|
|
410
|
+
1,
|
|
411
|
+
187e3,
|
|
412
|
+
1e3,
|
|
413
|
+
52998,
|
|
414
|
+
1,
|
|
415
|
+
80436,
|
|
416
|
+
32,
|
|
417
|
+
43249,
|
|
418
|
+
32,
|
|
419
|
+
1e3,
|
|
420
|
+
32,
|
|
421
|
+
80556,
|
|
422
|
+
1,
|
|
423
|
+
57667,
|
|
424
|
+
4,
|
|
425
|
+
1e3,
|
|
426
|
+
10,
|
|
427
|
+
197145,
|
|
428
|
+
156,
|
|
429
|
+
1,
|
|
430
|
+
197145,
|
|
431
|
+
156,
|
|
432
|
+
1,
|
|
433
|
+
204924,
|
|
434
|
+
473,
|
|
435
|
+
1,
|
|
436
|
+
208896,
|
|
437
|
+
511,
|
|
438
|
+
1,
|
|
439
|
+
52467,
|
|
440
|
+
32,
|
|
441
|
+
64832,
|
|
442
|
+
32,
|
|
443
|
+
65493,
|
|
444
|
+
32,
|
|
445
|
+
22558,
|
|
446
|
+
32,
|
|
447
|
+
16563,
|
|
448
|
+
32,
|
|
449
|
+
76511,
|
|
450
|
+
32,
|
|
451
|
+
196500,
|
|
452
|
+
453240,
|
|
453
|
+
220,
|
|
454
|
+
0,
|
|
455
|
+
1,
|
|
456
|
+
1,
|
|
457
|
+
69522,
|
|
458
|
+
11687,
|
|
459
|
+
0,
|
|
460
|
+
1,
|
|
461
|
+
60091,
|
|
462
|
+
32,
|
|
463
|
+
196500,
|
|
464
|
+
453240,
|
|
465
|
+
220,
|
|
466
|
+
0,
|
|
467
|
+
1,
|
|
468
|
+
1,
|
|
469
|
+
196500,
|
|
470
|
+
453240,
|
|
471
|
+
220,
|
|
472
|
+
0,
|
|
473
|
+
1,
|
|
474
|
+
1,
|
|
475
|
+
1159724,
|
|
476
|
+
392670,
|
|
477
|
+
0,
|
|
478
|
+
2,
|
|
479
|
+
806990,
|
|
480
|
+
30482,
|
|
481
|
+
4,
|
|
482
|
+
1927926,
|
|
483
|
+
82523,
|
|
484
|
+
4,
|
|
485
|
+
265318,
|
|
486
|
+
0,
|
|
487
|
+
4,
|
|
488
|
+
0,
|
|
489
|
+
85931,
|
|
490
|
+
32,
|
|
491
|
+
205665,
|
|
492
|
+
812,
|
|
493
|
+
1,
|
|
494
|
+
1,
|
|
495
|
+
41182,
|
|
496
|
+
32,
|
|
497
|
+
212342,
|
|
498
|
+
32,
|
|
499
|
+
31220,
|
|
500
|
+
32,
|
|
501
|
+
32696,
|
|
502
|
+
32,
|
|
503
|
+
43357,
|
|
504
|
+
32,
|
|
505
|
+
32247,
|
|
506
|
+
32,
|
|
507
|
+
38314,
|
|
508
|
+
32,
|
|
509
|
+
35892428,
|
|
510
|
+
10,
|
|
511
|
+
57996947,
|
|
512
|
+
18975,
|
|
513
|
+
10,
|
|
514
|
+
38887044,
|
|
515
|
+
32947,
|
|
516
|
+
10
|
|
517
|
+
];
|
|
518
|
+
|
|
519
|
+
// src/constants/language-views.ts
|
|
520
|
+
var SUPPORTED_LANGUAGE_VIEWS = {
|
|
521
|
+
ALONZO: {
|
|
522
|
+
V1: "a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"
|
|
523
|
+
},
|
|
524
|
+
BABBAGE: {
|
|
525
|
+
V1: "a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",
|
|
526
|
+
V2: "a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
var resolveLanguageView = (era, version) => {
|
|
530
|
+
return SUPPORTED_LANGUAGE_VIEWS[era][version];
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
// src/constants/index.ts
|
|
534
|
+
var DEFAULT_REDEEMER_BUDGET = {
|
|
535
|
+
mem: 7e6,
|
|
536
|
+
steps: 3e9
|
|
537
|
+
};
|
|
538
|
+
var POLICY_ID_LENGTH = 56;
|
|
539
|
+
var LANGUAGE_VERSIONS = {
|
|
540
|
+
V1: "V1",
|
|
541
|
+
V2: "V2",
|
|
542
|
+
V3: "V3"
|
|
543
|
+
};
|
|
544
|
+
var HARDENED_KEY_START = 2147483648;
|
|
545
|
+
var SUPPORTED_CLOCKS = {
|
|
546
|
+
testnet: ["74", "1598400", "1595967616", "432000"],
|
|
547
|
+
preview: ["183", "15811222", "1682467200", "86400"],
|
|
548
|
+
preprod: ["65", "26438400", "1682121600", "432000"],
|
|
549
|
+
mainnet: ["208", "4492800", "1596059091", "432000"]
|
|
550
|
+
};
|
|
551
|
+
var SUPPORTED_HANDLES = {
|
|
552
|
+
0: "8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",
|
|
553
|
+
1: "f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"
|
|
554
|
+
};
|
|
555
|
+
var SUPPORTED_OGMIOS_LINKS = {
|
|
556
|
+
mainnet: "wss://ogmios-api.mainnet.dandelion.link",
|
|
557
|
+
preprod: "wss://ogmios-api.iohk-preprod.dandelion.link",
|
|
558
|
+
preview: "__TBD_SOON_TM__",
|
|
559
|
+
testnet: "wss://ogmios-api.testnet.dandelion.link"
|
|
560
|
+
};
|
|
561
|
+
var SUPPORTED_TOKENS = {
|
|
562
|
+
LQ: "da8c30857834c6ae7203935b89278c532b3995245295456f993e1d244c51",
|
|
563
|
+
MIN: "29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e",
|
|
564
|
+
NTX: "edfd7a1d77bcb8b884c474bdc92a16002d1fb720e454fa6e993444794e5458",
|
|
565
|
+
iBTC: "f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069425443",
|
|
566
|
+
iETH: "f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069455448",
|
|
567
|
+
iUSD: "f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069555344",
|
|
568
|
+
MILK: "8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa4d494c4b",
|
|
569
|
+
AGIX: "f43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc53541474958",
|
|
570
|
+
MELD: "6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d104d454c44",
|
|
571
|
+
INDY: "533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0494e4459",
|
|
572
|
+
CLAY: "38ad9dc3aec6a2f38e220142b9aa6ade63ebe71f65e7cc2b7d8a8535434c4159",
|
|
573
|
+
MCOS: "6f46e1304b16d884c85c62fb0eef35028facdc41aaa0fd319a152ed64d434f53",
|
|
574
|
+
DING: "ce5b9e0f8a88255b65f2e4d065c6e716e9fa9a8a86dfb86423dd1ac044494e47",
|
|
575
|
+
GERO: "10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b64745524f",
|
|
576
|
+
NMKR: "5dac8536653edc12f6f5e1045d8164b9f59998d3bdc300fc928434894e4d4b52",
|
|
577
|
+
PAVIA: "884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903ae5041564941",
|
|
578
|
+
HOSKY: "a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235484f534b59",
|
|
579
|
+
YUMMI: "078eafce5cd7edafdf63900edef2c1ea759e77f30ca81d6bbdeec92479756d6d69",
|
|
580
|
+
C3: "8e51398904a5d3fc129fbf4f1589701de23c7824d5c90fdb9490e15a434841524c4933",
|
|
581
|
+
GIMBAL: "2b0a04a7b60132b1805b296c7fcb3b217ff14413991bf76f72663c3067696d62616c",
|
|
582
|
+
SUNDAE: "9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145",
|
|
583
|
+
GREENS: "4623ab311b7d982d8d26fcbe1a9439ca56661aafcdcd8d8a0ef31fd6475245454e53",
|
|
584
|
+
GENS: "dda5fdb1002f7389b33e036b6afee82a8189becb6cba852e8b79b4fb0014df1047454e53",
|
|
585
|
+
SOCIETY: "25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459",
|
|
586
|
+
DJED: "8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344",
|
|
587
|
+
SHEN: "8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344",
|
|
588
|
+
WMT: "1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e776f726c646d6f62696c65746f6b656e",
|
|
589
|
+
COPI: "b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0436f726e75636f70696173205b76696120436861696e506f72742e696f5d"
|
|
590
|
+
};
|
|
591
|
+
var CIP68_100 = (tokenNameHex) => {
|
|
592
|
+
return `000643b0${tokenNameHex}`;
|
|
593
|
+
};
|
|
594
|
+
var CIP68_222 = (tokenNameHex) => {
|
|
595
|
+
return `000de140${tokenNameHex}`;
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
// src/types/asset.ts
|
|
599
|
+
var mergeAssets = (assets) => {
|
|
600
|
+
const merged = [];
|
|
601
|
+
assets.forEach((asset) => {
|
|
602
|
+
const existing = merged.find((a) => a.unit === asset.unit);
|
|
603
|
+
if (existing) {
|
|
604
|
+
existing.quantity = (BigInt(existing.quantity) + BigInt(asset.quantity)).toString();
|
|
605
|
+
} else {
|
|
606
|
+
merged.push(asset);
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
return merged;
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
// src/types/asset-metadata.ts
|
|
613
|
+
var royaltiesStandardKeys = ["rate", "address"];
|
|
614
|
+
var metadataStandardKeys = [
|
|
615
|
+
"name",
|
|
616
|
+
"image",
|
|
617
|
+
"mediaType",
|
|
618
|
+
"description",
|
|
619
|
+
"instagram",
|
|
620
|
+
"twitter",
|
|
621
|
+
"discord",
|
|
622
|
+
"website"
|
|
623
|
+
];
|
|
624
|
+
var fungibleAssetKeys = ["ticker", "decimals"];
|
|
625
|
+
var metadataToCip68 = (metadata) => {
|
|
626
|
+
switch (typeof metadata) {
|
|
627
|
+
case "object":
|
|
628
|
+
if (metadata instanceof Array) {
|
|
629
|
+
return metadata.map((item) => metadataToCip68(item));
|
|
630
|
+
}
|
|
631
|
+
const metadataMap = /* @__PURE__ */ new Map();
|
|
632
|
+
const keys = Object.keys(metadata);
|
|
633
|
+
keys.forEach((key) => {
|
|
634
|
+
metadataMap.set(key, metadataToCip68(metadata[key]));
|
|
635
|
+
});
|
|
636
|
+
return {
|
|
637
|
+
alternative: 0,
|
|
638
|
+
fields: [metadataMap, 1]
|
|
639
|
+
};
|
|
640
|
+
default:
|
|
641
|
+
return metadata;
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
// src/types/network.ts
|
|
646
|
+
var ALL_NETWORKS = ["testnet", "preview", "preprod", "mainnet"];
|
|
647
|
+
var isNetwork = (value2) => {
|
|
648
|
+
return ALL_NETWORKS.includes(value2);
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
// src/types/protocol.ts
|
|
652
|
+
var castProtocol = (data) => {
|
|
653
|
+
const result = {};
|
|
654
|
+
for (const rawKey in DEFAULT_PROTOCOL_PARAMETERS) {
|
|
655
|
+
const key = rawKey;
|
|
656
|
+
const defaultValue = DEFAULT_PROTOCOL_PARAMETERS[key];
|
|
657
|
+
const value2 = data[key];
|
|
658
|
+
if (typeof defaultValue === "number") {
|
|
659
|
+
result[key] = !value2 && value2 !== 0 ? defaultValue : Number(value2);
|
|
660
|
+
} else if (typeof defaultValue === "string") {
|
|
661
|
+
result[key] = !value2 && value2 !== "" ? defaultValue : value2.toString();
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return result;
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
// src/types/transaction-builder/index.ts
|
|
668
|
+
var emptyTxBuilderBody = () => ({
|
|
669
|
+
inputs: [],
|
|
670
|
+
outputs: [],
|
|
671
|
+
extraInputs: [],
|
|
672
|
+
collaterals: [],
|
|
673
|
+
requiredSignatures: [],
|
|
674
|
+
referenceInputs: [],
|
|
675
|
+
mints: [],
|
|
676
|
+
changeAddress: "",
|
|
677
|
+
metadata: [],
|
|
678
|
+
validityRange: {},
|
|
679
|
+
certificates: [],
|
|
680
|
+
withdrawals: [],
|
|
681
|
+
signingKey: [],
|
|
682
|
+
selectionConfig: {
|
|
683
|
+
threshold: "5000000",
|
|
684
|
+
strategy: "experimental",
|
|
685
|
+
includeTxFees: true
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
var validityRangeToObj = (validityRange) => {
|
|
689
|
+
return {
|
|
690
|
+
invalidBefore: validityRange.invalidBefore ?? null,
|
|
691
|
+
invalidHereafter: validityRange.invalidHereafter ?? null
|
|
692
|
+
};
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
// src/data/mesh/constructors.ts
|
|
696
|
+
var mConStr = (alternative, fields) => ({
|
|
697
|
+
alternative,
|
|
698
|
+
fields
|
|
699
|
+
});
|
|
700
|
+
var mConStr0 = (fields) => ({
|
|
701
|
+
alternative: 0,
|
|
702
|
+
fields
|
|
703
|
+
});
|
|
704
|
+
var mConStr1 = (fields) => ({
|
|
705
|
+
alternative: 1,
|
|
706
|
+
fields
|
|
707
|
+
});
|
|
708
|
+
var mConStr2 = (fields) => ({
|
|
709
|
+
alternative: 2,
|
|
710
|
+
fields
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
// src/data/mesh/aliases.ts
|
|
714
|
+
var mAssetClass = (currencySymbolHex, tokenNameHex) => {
|
|
715
|
+
if (currencySymbolHex.length !== 56 && currencySymbolHex !== "") {
|
|
716
|
+
throw new Error(
|
|
717
|
+
`Invalid policy id for [${currencySymbolHex}] - should be ${POLICY_ID_LENGTH} bytes long or empty string for lovelace`
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
if (tokenNameHex.length > 64) {
|
|
721
|
+
throw new Error(
|
|
722
|
+
`Invalid asset name for [${tokenNameHex}] - should be less than 32 bytes (64 hex length) long`
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
return mConStr0([currencySymbolHex, tokenNameHex]);
|
|
726
|
+
};
|
|
727
|
+
var mOutputReference = (txHash, index) => {
|
|
728
|
+
if (txHash.length !== 64) {
|
|
729
|
+
throw new Error("Invalid transaction hash - should be 32 bytes long");
|
|
730
|
+
}
|
|
731
|
+
return mConStr0([mConStr0([txHash]), index]);
|
|
732
|
+
};
|
|
733
|
+
var mTxOutRef = (txHash, index) => mOutputReference(txHash, index);
|
|
734
|
+
var mTuple = (key, value2) => [key, value2];
|
|
735
|
+
|
|
736
|
+
// src/data/mesh/credentials.ts
|
|
737
|
+
var mMaybeStakingHash = (stakeCredential, isScriptCredential = false) => {
|
|
738
|
+
if (stakeCredential === "") {
|
|
739
|
+
return mConStr1([]);
|
|
740
|
+
}
|
|
741
|
+
if (isScriptCredential) {
|
|
742
|
+
return mConStr0([mConStr0([mConStr1([stakeCredential])])]);
|
|
743
|
+
}
|
|
744
|
+
return mConStr0([mConStr0([mConStr0([stakeCredential])])]);
|
|
745
|
+
};
|
|
746
|
+
var mPubKeyAddress = (bytes, stakeCredential, isScriptCredential = false) => mConStr0([
|
|
747
|
+
{ alternative: 0, fields: [bytes] },
|
|
748
|
+
mMaybeStakingHash(stakeCredential || "", isScriptCredential)
|
|
749
|
+
]);
|
|
750
|
+
var mScriptAddress = (bytes, stakeCredential, isScriptCredential = false) => mConStr0([
|
|
751
|
+
{ alternative: 1, fields: [bytes] },
|
|
752
|
+
mMaybeStakingHash(stakeCredential || "", isScriptCredential)
|
|
753
|
+
]);
|
|
754
|
+
|
|
755
|
+
// src/data/mesh/primitives.ts
|
|
756
|
+
var mBool = (b) => b ? mConStr1([]) : mConStr0([]);
|
|
757
|
+
var mStringToPlutusBSArray = (hexString) => {
|
|
758
|
+
const chunks = [];
|
|
759
|
+
for (let i = 0; i < hexString.length; i += 64) {
|
|
760
|
+
const chunk = hexString.substring(i, i + 64);
|
|
761
|
+
chunks.push(chunk);
|
|
762
|
+
}
|
|
763
|
+
return chunks;
|
|
764
|
+
};
|
|
765
|
+
var mPlutusBSArrayToString = (bsArray) => {
|
|
766
|
+
return bsArray.join("");
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
// src/data/json/constructors.ts
|
|
770
|
+
var conStr = (constructor, fields) => {
|
|
771
|
+
if (!Array.isArray(fields)) {
|
|
772
|
+
throw new Error("fields of a constructor must be an array");
|
|
773
|
+
}
|
|
774
|
+
return {
|
|
775
|
+
constructor,
|
|
776
|
+
fields
|
|
777
|
+
};
|
|
778
|
+
};
|
|
779
|
+
var conStr0 = (fields) => conStr(0, fields);
|
|
780
|
+
var conStr1 = (fields) => conStr(1, fields);
|
|
781
|
+
var conStr2 = (fields) => conStr(2, fields);
|
|
782
|
+
|
|
783
|
+
// src/data/json/primitives.ts
|
|
784
|
+
var bool = (b) => b ? conStr1([]) : conStr0([]);
|
|
785
|
+
var builtinByteString = (bytes) => {
|
|
786
|
+
return byteString(bytes);
|
|
787
|
+
};
|
|
788
|
+
var byteString = (bytes) => {
|
|
789
|
+
if (bytes.length % 2 !== 0) {
|
|
790
|
+
throw new Error("Invalid hex string - odd length: " + bytes);
|
|
791
|
+
}
|
|
792
|
+
if (!/^[0-9a-fA-F]*$/.test(bytes)) {
|
|
793
|
+
throw new Error("Invalid hex string - non-hex string character: " + bytes);
|
|
794
|
+
}
|
|
795
|
+
return {
|
|
796
|
+
bytes
|
|
797
|
+
};
|
|
798
|
+
};
|
|
799
|
+
var integer = (int) => ({ int });
|
|
800
|
+
var list = (pList, validation = true) => {
|
|
801
|
+
if (validation) {
|
|
802
|
+
pList.forEach((item) => {
|
|
803
|
+
if (typeof item !== "object") {
|
|
804
|
+
throw new Error(
|
|
805
|
+
"List item of JSON Cardano data type must be an object - " + item
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
return { list: pList };
|
|
811
|
+
};
|
|
812
|
+
var stringToBSArray = (hexString) => {
|
|
813
|
+
const processRawStringIntoPlutusByteArray = (hexString2) => {
|
|
814
|
+
const chunks = [];
|
|
815
|
+
for (let i = 0; i < hexString2.length; i += 64) {
|
|
816
|
+
const chunk = hexString2.substring(i, i + 64);
|
|
817
|
+
chunks.push(chunk);
|
|
818
|
+
}
|
|
819
|
+
return chunks;
|
|
820
|
+
};
|
|
821
|
+
return list(
|
|
822
|
+
processRawStringIntoPlutusByteArray(hexString).map(builtinByteString)
|
|
823
|
+
);
|
|
824
|
+
};
|
|
825
|
+
var plutusBSArrayToString = (bsArray) => {
|
|
826
|
+
return bsArray.list.map((bs) => bs.bytes).join("");
|
|
827
|
+
};
|
|
828
|
+
var assocMap = (mapItems, validation = true) => ({
|
|
829
|
+
map: mapItems.map(([k, v]) => {
|
|
830
|
+
if (validation) {
|
|
831
|
+
if (typeof k !== "object" || typeof v !== "object") {
|
|
832
|
+
throw new Error(
|
|
833
|
+
`Map item of JSON Cardano data type must be an object - ${k}, ${v}`
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
return { k, v };
|
|
838
|
+
})
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
// src/data/json/aliases.ts
|
|
842
|
+
var hashByteString = (bytes) => {
|
|
843
|
+
if (bytes.length !== 56) {
|
|
844
|
+
throw new Error(`Invalid hash for [${bytes}] - should be 56 bytes long`);
|
|
845
|
+
}
|
|
846
|
+
return byteString(bytes);
|
|
847
|
+
};
|
|
848
|
+
var scriptHash = (bytes) => hashByteString(bytes);
|
|
849
|
+
var pubKeyHash = (bytes) => hashByteString(bytes);
|
|
850
|
+
var policyId = (bytes) => {
|
|
851
|
+
if (bytes.length !== POLICY_ID_LENGTH && bytes !== "") {
|
|
852
|
+
throw new Error(
|
|
853
|
+
`Invalid policy id for [${bytes}] - should be ${POLICY_ID_LENGTH} bytes long or empty string for lovelace`
|
|
854
|
+
);
|
|
855
|
+
}
|
|
856
|
+
return byteString(bytes);
|
|
857
|
+
};
|
|
858
|
+
var currencySymbol = (bytes) => policyId(bytes);
|
|
859
|
+
var assetName = (bytes) => {
|
|
860
|
+
if (bytes.length > 64) {
|
|
861
|
+
throw new Error(
|
|
862
|
+
`Invalid asset name for [${bytes}] - should be less than 32 bytes (64 hex length) long`
|
|
863
|
+
);
|
|
864
|
+
}
|
|
865
|
+
return byteString(bytes);
|
|
866
|
+
};
|
|
867
|
+
var tokenName = (bytes) => assetName(bytes);
|
|
868
|
+
var assetClass = (currencySymbolHex, tokenNameHex) => conStr0([currencySymbol(currencySymbolHex), tokenName(tokenNameHex)]);
|
|
869
|
+
var outputReference = (txHash, index) => {
|
|
870
|
+
if (txHash.length !== 64) {
|
|
871
|
+
throw new Error("Invalid transaction hash - should be 32 bytes long");
|
|
872
|
+
}
|
|
873
|
+
return conStr0([conStr0([byteString(txHash)]), integer(index)]);
|
|
874
|
+
};
|
|
875
|
+
var txOutRef = (txHash, index) => outputReference(txHash, index);
|
|
876
|
+
var posixTime = (int) => ({ int });
|
|
877
|
+
var dict = (itemsMap) => ({
|
|
878
|
+
map: itemsMap.map(([k, v]) => ({ k, v }))
|
|
879
|
+
});
|
|
880
|
+
var tuple = (key, value2) => ({ list: [key, value2] });
|
|
881
|
+
|
|
882
|
+
// src/data/json/credentials.ts
|
|
883
|
+
var maybeStakingHash = (stakeCredential, isScriptCredential = false) => {
|
|
884
|
+
if (stakeCredential === "") {
|
|
885
|
+
return conStr1([]);
|
|
886
|
+
}
|
|
887
|
+
if (isScriptCredential) {
|
|
888
|
+
return conStr0([
|
|
889
|
+
conStr0([conStr1([scriptHash(stakeCredential)])])
|
|
890
|
+
]);
|
|
891
|
+
}
|
|
892
|
+
return conStr0([
|
|
893
|
+
conStr0([conStr0([pubKeyHash(stakeCredential)])])
|
|
894
|
+
]);
|
|
895
|
+
};
|
|
896
|
+
var pubKeyAddress = (bytes, stakeCredential, isScriptCredential = false) => conStr0([
|
|
897
|
+
conStr0([pubKeyHash(bytes)]),
|
|
898
|
+
maybeStakingHash(stakeCredential || "", isScriptCredential)
|
|
899
|
+
]);
|
|
900
|
+
var scriptAddress = (bytes, stakeCredential, isScriptCredential = false) => conStr0([
|
|
901
|
+
conStr1([scriptHash(bytes)]),
|
|
902
|
+
maybeStakingHash(stakeCredential || "", isScriptCredential)
|
|
903
|
+
]);
|
|
904
|
+
|
|
905
|
+
// src/data/parser.ts
|
|
906
|
+
var bytesToHex = (bytes) => Buffer.from(bytes).toString("hex");
|
|
907
|
+
var hexToBytes = (hex) => Buffer.from(hex, "hex");
|
|
908
|
+
var stringToHex = (str) => Buffer.from(str, "utf8").toString("hex");
|
|
909
|
+
var hexToString = (hex) => Buffer.from(hex, "hex").toString("utf8");
|
|
910
|
+
var toBytes = (hex) => {
|
|
911
|
+
if (hex.length % 2 === 0 && /^[0-9A-F]*$/i.test(hex))
|
|
912
|
+
return Buffer.from(hex, "hex");
|
|
913
|
+
return Buffer.from(hex, "utf-8");
|
|
914
|
+
};
|
|
915
|
+
var fromUTF8 = (utf8) => {
|
|
916
|
+
if (utf8.length % 2 === 0 && /^[0-9A-F]*$/i.test(utf8)) return utf8;
|
|
917
|
+
return bytesToHex(Buffer.from(utf8, "utf-8"));
|
|
918
|
+
};
|
|
919
|
+
var toUTF8 = (hex) => Buffer.from(hex, "hex").toString("utf-8");
|
|
920
|
+
var parseAssetUnit = (unit) => {
|
|
921
|
+
const policyId2 = unit.slice(0, POLICY_ID_LENGTH);
|
|
922
|
+
const assetName2 = unit.includes(".") ? fromUTF8(unit.split(".")[1]) : unit.slice(POLICY_ID_LENGTH);
|
|
923
|
+
return { policyId: policyId2, assetName: assetName2 };
|
|
924
|
+
};
|
|
925
|
+
|
|
926
|
+
// src/data/time.ts
|
|
927
|
+
var SLOT_CONFIG_NETWORK = {
|
|
928
|
+
mainnet: {
|
|
929
|
+
zeroTime: 1596059091e3,
|
|
930
|
+
zeroSlot: 4492800,
|
|
931
|
+
slotLength: 1e3,
|
|
932
|
+
startEpoch: 208,
|
|
933
|
+
epochLength: 432e3
|
|
934
|
+
},
|
|
935
|
+
// Starting at Shelley era
|
|
936
|
+
preview: {
|
|
937
|
+
zeroTime: 16824672e5,
|
|
938
|
+
zeroSlot: 0,
|
|
939
|
+
slotLength: 1e3,
|
|
940
|
+
startEpoch: 183,
|
|
941
|
+
epochLength: 86400
|
|
942
|
+
},
|
|
943
|
+
// Starting at Shelley era
|
|
944
|
+
preprod: {
|
|
945
|
+
zeroTime: 16821216e5,
|
|
946
|
+
zeroSlot: 86400,
|
|
947
|
+
slotLength: 1e3,
|
|
948
|
+
startEpoch: 65,
|
|
949
|
+
epochLength: 432e3
|
|
950
|
+
},
|
|
951
|
+
// Starting at Shelley era
|
|
952
|
+
/** Customizable slot config (Initialized with 0 values). */
|
|
953
|
+
testnet: {
|
|
954
|
+
zeroTime: 0,
|
|
955
|
+
zeroSlot: 0,
|
|
956
|
+
slotLength: 0,
|
|
957
|
+
startEpoch: 0,
|
|
958
|
+
epochLength: 0
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
var slotToBeginUnixTime = (slot, slotConfig) => {
|
|
962
|
+
const msAfterBegin = (slot - slotConfig.zeroSlot) * slotConfig.slotLength;
|
|
963
|
+
return slotConfig.zeroTime + msAfterBegin;
|
|
964
|
+
};
|
|
965
|
+
var unixTimeToEnclosingSlot = (unixTime, slotConfig) => {
|
|
966
|
+
const timePassed = unixTime - slotConfig.zeroTime;
|
|
967
|
+
const slotsPassed = Math.floor(timePassed / slotConfig.slotLength);
|
|
968
|
+
return slotsPassed + slotConfig.zeroSlot;
|
|
969
|
+
};
|
|
970
|
+
var resolveSlotNo = (network, milliseconds = Date.now()) => {
|
|
971
|
+
return unixTimeToEnclosingSlot(
|
|
972
|
+
milliseconds,
|
|
973
|
+
SLOT_CONFIG_NETWORK[network]
|
|
974
|
+
).toString();
|
|
975
|
+
};
|
|
976
|
+
var resolveEpochNo = (network, milliseconds = Date.now()) => {
|
|
977
|
+
const config = SLOT_CONFIG_NETWORK[network];
|
|
978
|
+
const msBigInt = BigInt(milliseconds);
|
|
979
|
+
const epoch = (msBigInt - BigInt(config.zeroTime)) / 1000n / BigInt(config.epochLength) + BigInt(config.startEpoch);
|
|
980
|
+
return Number(epoch);
|
|
981
|
+
};
|
|
982
|
+
|
|
983
|
+
// src/utils/asset-fingerprint.ts
|
|
984
|
+
var import_cip14_js = __toESM(require("@emurgo/cip14-js"), 1);
|
|
985
|
+
var AssetFingerprint = import_cip14_js.default;
|
|
986
|
+
var resolveFingerprint = (policyId2, assetName2) => {
|
|
987
|
+
return AssetFingerprint.default.fromParts(toBytes(policyId2), toBytes(assetName2)).fingerprint();
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
// src/utils/bigNum.ts
|
|
991
|
+
var BigNum = class _BigNum {
|
|
992
|
+
value;
|
|
993
|
+
constructor(value2) {
|
|
994
|
+
if (!value2) {
|
|
995
|
+
this.value = BigInt(0);
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
this.value = BigInt(value2);
|
|
999
|
+
}
|
|
1000
|
+
static new(value2) {
|
|
1001
|
+
if (!value2) {
|
|
1002
|
+
return new _BigNum(0);
|
|
1003
|
+
}
|
|
1004
|
+
return new _BigNum(value2);
|
|
1005
|
+
}
|
|
1006
|
+
// Operators
|
|
1007
|
+
divFloor(other) {
|
|
1008
|
+
this.value = this.value / other.value;
|
|
1009
|
+
return this;
|
|
1010
|
+
}
|
|
1011
|
+
checkedMul(other) {
|
|
1012
|
+
this.value *= other.value;
|
|
1013
|
+
return this;
|
|
1014
|
+
}
|
|
1015
|
+
checkedAdd(other) {
|
|
1016
|
+
this.value += other.value;
|
|
1017
|
+
return this;
|
|
1018
|
+
}
|
|
1019
|
+
checkedSub(other) {
|
|
1020
|
+
this.value -= other.value;
|
|
1021
|
+
return this;
|
|
1022
|
+
}
|
|
1023
|
+
clampedSub(other) {
|
|
1024
|
+
const result = this.value - other.value;
|
|
1025
|
+
this.value = result < 0n ? 0n : result;
|
|
1026
|
+
return this;
|
|
1027
|
+
}
|
|
1028
|
+
// Comparators
|
|
1029
|
+
lessThan(other) {
|
|
1030
|
+
return this.value < other.value;
|
|
1031
|
+
}
|
|
1032
|
+
compare(other) {
|
|
1033
|
+
if (this.value === other.value) {
|
|
1034
|
+
return 0;
|
|
1035
|
+
} else if (this.value < other.value) {
|
|
1036
|
+
return -1;
|
|
1037
|
+
} else {
|
|
1038
|
+
return 1;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
// Override
|
|
1042
|
+
toString() {
|
|
1043
|
+
return this.value.toString();
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
// src/data/value.ts
|
|
1048
|
+
var value = (assets) => {
|
|
1049
|
+
return MeshValue.fromAssets(assets).toJSON();
|
|
1050
|
+
};
|
|
1051
|
+
var mValue = (assets) => {
|
|
1052
|
+
return MeshValue.fromAssets(assets).toData();
|
|
1053
|
+
};
|
|
1054
|
+
var MeshValue = class _MeshValue {
|
|
1055
|
+
value;
|
|
1056
|
+
constructor(value2 = {}) {
|
|
1057
|
+
this.value = value2;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Converting assets into MeshValue
|
|
1061
|
+
* @param assets The assets to convert
|
|
1062
|
+
* @returns MeshValue
|
|
1063
|
+
*/
|
|
1064
|
+
static fromAssets = (assets) => {
|
|
1065
|
+
const value2 = new _MeshValue();
|
|
1066
|
+
value2.addAssets(assets);
|
|
1067
|
+
return value2;
|
|
1068
|
+
};
|
|
1069
|
+
/**
|
|
1070
|
+
* Converting Value (the JSON representation of Cardano data Value) into MeshValue
|
|
1071
|
+
* @param plutusValue The Value to convert
|
|
1072
|
+
* @returns MeshValue
|
|
1073
|
+
*/
|
|
1074
|
+
static fromValue = (plutusValue) => {
|
|
1075
|
+
const assets = [];
|
|
1076
|
+
plutusValue.map.forEach((policyMap) => {
|
|
1077
|
+
const policy = policyMap.k.bytes;
|
|
1078
|
+
policyMap.v.map.forEach((tokenMap) => {
|
|
1079
|
+
const token = tokenMap.k.bytes;
|
|
1080
|
+
const quantity = tokenMap.v.int.toString();
|
|
1081
|
+
const unsanitizedUnit = policy + token;
|
|
1082
|
+
const unit = unsanitizedUnit === "" ? "lovelace" : unsanitizedUnit;
|
|
1083
|
+
assets.push({ unit, quantity });
|
|
1084
|
+
});
|
|
1085
|
+
});
|
|
1086
|
+
return _MeshValue.fromAssets(assets);
|
|
1087
|
+
};
|
|
1088
|
+
/**
|
|
1089
|
+
* Add an asset to the Value class's value record.
|
|
1090
|
+
* @param asset The asset to add
|
|
1091
|
+
* @returns The updated MeshValue object
|
|
1092
|
+
*/
|
|
1093
|
+
addAsset = (asset) => {
|
|
1094
|
+
const quantity = BigInt(asset.quantity);
|
|
1095
|
+
const { unit } = asset;
|
|
1096
|
+
if (this.value[unit]) {
|
|
1097
|
+
this.value[unit] += quantity;
|
|
1098
|
+
} else {
|
|
1099
|
+
this.value[unit] = quantity;
|
|
1100
|
+
}
|
|
1101
|
+
return this;
|
|
1102
|
+
};
|
|
1103
|
+
/**
|
|
1104
|
+
* Add an array of assets to the Value class's value record.
|
|
1105
|
+
* @param assets The assets to add
|
|
1106
|
+
* @returns The updated MeshValue object
|
|
1107
|
+
*/
|
|
1108
|
+
addAssets = (assets) => {
|
|
1109
|
+
assets.forEach((asset) => {
|
|
1110
|
+
this.addAsset(asset);
|
|
1111
|
+
});
|
|
1112
|
+
return this;
|
|
1113
|
+
};
|
|
1114
|
+
/**
|
|
1115
|
+
* Substract an asset from the Value class's value record.
|
|
1116
|
+
* @param asset The asset to subtract
|
|
1117
|
+
* @returns The updated MeshValue object
|
|
1118
|
+
*/
|
|
1119
|
+
negateAsset = (asset) => {
|
|
1120
|
+
const { unit, quantity: assetQty } = asset;
|
|
1121
|
+
const quantity = BigNum.new(this.value[unit]);
|
|
1122
|
+
quantity.clampedSub(BigNum.new(assetQty));
|
|
1123
|
+
if (quantity.value === BigInt(0)) {
|
|
1124
|
+
delete this.value[unit];
|
|
1125
|
+
} else {
|
|
1126
|
+
this.value[unit] = quantity.value;
|
|
1127
|
+
}
|
|
1128
|
+
return this;
|
|
1129
|
+
};
|
|
1130
|
+
/**
|
|
1131
|
+
* Subtract an array of assets from the Value class's value record.
|
|
1132
|
+
* @param assets The assets to subtract
|
|
1133
|
+
* @returns The updated MeshValue object
|
|
1134
|
+
*/
|
|
1135
|
+
negateAssets = (assets) => {
|
|
1136
|
+
assets.forEach((asset) => {
|
|
1137
|
+
this.negateAsset(asset);
|
|
1138
|
+
});
|
|
1139
|
+
return this;
|
|
1140
|
+
};
|
|
1141
|
+
/**
|
|
1142
|
+
* Get the quantity of asset object per unit
|
|
1143
|
+
* @param unit The unit to get the quantity of
|
|
1144
|
+
* @returns The quantity of the asset
|
|
1145
|
+
*/
|
|
1146
|
+
get = (unit) => {
|
|
1147
|
+
return this.value[unit] ? BigInt(this.value[unit]) : BigInt(0);
|
|
1148
|
+
};
|
|
1149
|
+
/**
|
|
1150
|
+
* Get all asset units
|
|
1151
|
+
* @returns The asset units
|
|
1152
|
+
*/
|
|
1153
|
+
units = () => {
|
|
1154
|
+
return Object.keys(this.value);
|
|
1155
|
+
};
|
|
1156
|
+
/**
|
|
1157
|
+
* Check if the value is greater than or equal to another value
|
|
1158
|
+
* @param other - The value to compare against
|
|
1159
|
+
* @returns boolean
|
|
1160
|
+
*/
|
|
1161
|
+
geq = (other) => {
|
|
1162
|
+
return Object.keys(other.value).every((key) => this.geqUnit(key, other));
|
|
1163
|
+
};
|
|
1164
|
+
/**
|
|
1165
|
+
* Check if the specific unit of value is greater than or equal to that unit of another value
|
|
1166
|
+
* @param unit - The unit to compare
|
|
1167
|
+
* @param other - The value to compare against
|
|
1168
|
+
* @returns boolean
|
|
1169
|
+
*/
|
|
1170
|
+
geqUnit = (unit, other) => {
|
|
1171
|
+
if (this.value[unit] === void 0 || other.value[unit] === void 0) {
|
|
1172
|
+
return false;
|
|
1173
|
+
}
|
|
1174
|
+
return BigInt(this.value[unit]) >= BigInt(other.value[unit]);
|
|
1175
|
+
};
|
|
1176
|
+
/**
|
|
1177
|
+
* Check if the value is less than or equal to another value
|
|
1178
|
+
* @param other - The value to compare against
|
|
1179
|
+
* @returns boolean
|
|
1180
|
+
*/
|
|
1181
|
+
leq = (other) => {
|
|
1182
|
+
return Object.keys(other.value).every((key) => this.leqUnit(key, other));
|
|
1183
|
+
};
|
|
1184
|
+
/**
|
|
1185
|
+
* Check if the specific unit of value is less than or equal to that unit of another value
|
|
1186
|
+
* @param unit - The unit to compare
|
|
1187
|
+
* @param other - The value to compare against
|
|
1188
|
+
* @returns boolean
|
|
1189
|
+
*/
|
|
1190
|
+
leqUnit = (unit, other) => {
|
|
1191
|
+
if (this.value[unit] === void 0 || other.value[unit] === void 0) {
|
|
1192
|
+
return false;
|
|
1193
|
+
}
|
|
1194
|
+
return BigInt(this.value[unit]) <= BigInt(other.value[unit]);
|
|
1195
|
+
};
|
|
1196
|
+
/**
|
|
1197
|
+
* Check if the value is empty
|
|
1198
|
+
* @returns boolean
|
|
1199
|
+
*/
|
|
1200
|
+
isEmpty = () => {
|
|
1201
|
+
return Object.keys(this.value).length === 0;
|
|
1202
|
+
};
|
|
1203
|
+
/**
|
|
1204
|
+
* Merge the given values
|
|
1205
|
+
* @param values The other values to merge
|
|
1206
|
+
* @returns this
|
|
1207
|
+
*/
|
|
1208
|
+
merge = (values) => {
|
|
1209
|
+
const valuesArray = Array.isArray(values) ? values : [values];
|
|
1210
|
+
valuesArray.forEach((other) => {
|
|
1211
|
+
Object.entries(other.value).forEach(([key, value2]) => {
|
|
1212
|
+
this.value[key] = (this.value[key] !== void 0 ? BigInt(this.value[key]) : BigInt(0)) + BigInt(value2);
|
|
1213
|
+
});
|
|
1214
|
+
});
|
|
1215
|
+
return this;
|
|
1216
|
+
};
|
|
1217
|
+
/**
|
|
1218
|
+
* Convert the MeshValue object into an array of Asset
|
|
1219
|
+
* @returns The array of Asset
|
|
1220
|
+
*/
|
|
1221
|
+
toAssets = () => {
|
|
1222
|
+
const assets = [];
|
|
1223
|
+
Object.entries(this.value).forEach(([unit, quantity]) => {
|
|
1224
|
+
assets.push({ unit, quantity: quantity.toString() });
|
|
1225
|
+
});
|
|
1226
|
+
return assets;
|
|
1227
|
+
};
|
|
1228
|
+
/**
|
|
1229
|
+
* Convert the MeshValue object into Cardano data Value in Mesh Data type
|
|
1230
|
+
*/
|
|
1231
|
+
toData = () => {
|
|
1232
|
+
const valueMap = /* @__PURE__ */ new Map();
|
|
1233
|
+
this.toAssets().forEach((asset) => {
|
|
1234
|
+
const policy = asset.unit.slice(0, 56) || "";
|
|
1235
|
+
const token = asset.unit.slice(56) || "";
|
|
1236
|
+
if (!valueMap.has(policy)) {
|
|
1237
|
+
valueMap.set(policy, /* @__PURE__ */ new Map());
|
|
1238
|
+
}
|
|
1239
|
+
const tokenMap = valueMap.get(policy);
|
|
1240
|
+
const quantity = tokenMap?.get(token);
|
|
1241
|
+
if (!quantity) {
|
|
1242
|
+
tokenMap.set(token, BigInt(asset.quantity));
|
|
1243
|
+
} else {
|
|
1244
|
+
tokenMap.set(token, quantity + BigInt(asset.quantity));
|
|
1245
|
+
}
|
|
1246
|
+
});
|
|
1247
|
+
return valueMap;
|
|
1248
|
+
};
|
|
1249
|
+
/**
|
|
1250
|
+
* Convert the MeshValue object into a JSON representation of Cardano data Value
|
|
1251
|
+
* @returns Cardano data Value in JSON
|
|
1252
|
+
*/
|
|
1253
|
+
toJSON = () => {
|
|
1254
|
+
const valueMapToParse = [];
|
|
1255
|
+
const valueMap = {};
|
|
1256
|
+
this.toAssets().forEach((asset) => {
|
|
1257
|
+
const sanitizedName = asset.unit.replace("lovelace", "");
|
|
1258
|
+
const policy = sanitizedName.slice(0, 56) || "";
|
|
1259
|
+
const token = sanitizedName.slice(56) || "";
|
|
1260
|
+
if (!valueMap[policy]) {
|
|
1261
|
+
valueMap[policy] = {};
|
|
1262
|
+
}
|
|
1263
|
+
if (!valueMap[policy][token]) {
|
|
1264
|
+
valueMap[policy][token] = Number(asset.quantity);
|
|
1265
|
+
} else {
|
|
1266
|
+
valueMap[policy][token] += Number(asset.quantity);
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
Object.keys(valueMap).forEach((policy) => {
|
|
1270
|
+
const policyByte = currencySymbol(policy);
|
|
1271
|
+
const tokens = Object.keys(valueMap[policy]).map(
|
|
1272
|
+
(name) => [tokenName(name), integer(valueMap[policy][name])]
|
|
1273
|
+
);
|
|
1274
|
+
const policyMap = assocMap(tokens);
|
|
1275
|
+
valueMapToParse.push([policyByte, policyMap]);
|
|
1276
|
+
});
|
|
1277
|
+
return assocMap(valueMapToParse);
|
|
1278
|
+
};
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
// src/utxo-selection/experimental.ts
|
|
1282
|
+
var experimentalSelectUtxos = (requiredAssets, inputs, threshold) => {
|
|
1283
|
+
const totalRequiredAssets = new Map(requiredAssets);
|
|
1284
|
+
totalRequiredAssets.set(
|
|
1285
|
+
"lovelace",
|
|
1286
|
+
String(
|
|
1287
|
+
Number(totalRequiredAssets.get("lovelace") || 0) + Number(threshold)
|
|
1288
|
+
)
|
|
1289
|
+
);
|
|
1290
|
+
const utxoMap = /* @__PURE__ */ new Map();
|
|
1291
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
1292
|
+
utxoMap.set(i, inputs[i]);
|
|
1293
|
+
}
|
|
1294
|
+
const selectedInputs = /* @__PURE__ */ new Set();
|
|
1295
|
+
const onlyLovelace = /* @__PURE__ */ new Set();
|
|
1296
|
+
const singletons = /* @__PURE__ */ new Set();
|
|
1297
|
+
const pairs = /* @__PURE__ */ new Set();
|
|
1298
|
+
const rest = /* @__PURE__ */ new Set();
|
|
1299
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
1300
|
+
switch (inputs[i].output.amount.length) {
|
|
1301
|
+
case 1: {
|
|
1302
|
+
onlyLovelace.add(i);
|
|
1303
|
+
break;
|
|
1304
|
+
}
|
|
1305
|
+
case 2: {
|
|
1306
|
+
singletons.add(i);
|
|
1307
|
+
break;
|
|
1308
|
+
}
|
|
1309
|
+
case 3: {
|
|
1310
|
+
pairs.add(i);
|
|
1311
|
+
break;
|
|
1312
|
+
}
|
|
1313
|
+
default: {
|
|
1314
|
+
rest.add(i);
|
|
1315
|
+
break;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
const addUtxoWithAssetAmount = (inputIndex, assetUnit, set) => {
|
|
1320
|
+
const utxo = utxoMap.get(inputIndex);
|
|
1321
|
+
if (!utxo) return;
|
|
1322
|
+
const amount = getAssetAmount(utxo, assetUnit);
|
|
1323
|
+
if (Number(amount) > 0) {
|
|
1324
|
+
selectedInputs.add(inputIndex);
|
|
1325
|
+
set.delete(inputIndex);
|
|
1326
|
+
for (const asset of utxo.output.amount) {
|
|
1327
|
+
totalRequiredAssets.set(
|
|
1328
|
+
asset.unit,
|
|
1329
|
+
String(
|
|
1330
|
+
Number(totalRequiredAssets.get(asset.unit)) - Number(asset.quantity)
|
|
1331
|
+
)
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
for (const assetUnit of totalRequiredAssets.keys()) {
|
|
1337
|
+
if (assetUnit == "lovelace") continue;
|
|
1338
|
+
for (const inputIndex of singletons) {
|
|
1339
|
+
const assetRequired = totalRequiredAssets.get(assetUnit);
|
|
1340
|
+
if (!assetRequired || Number(assetRequired) <= 0) break;
|
|
1341
|
+
addUtxoWithAssetAmount(inputIndex, assetUnit, singletons);
|
|
1342
|
+
}
|
|
1343
|
+
for (const inputIndex of pairs) {
|
|
1344
|
+
const assetRequired = totalRequiredAssets.get(assetUnit);
|
|
1345
|
+
if (!assetRequired || Number(assetRequired) <= 0) break;
|
|
1346
|
+
addUtxoWithAssetAmount(inputIndex, assetUnit, pairs);
|
|
1347
|
+
}
|
|
1348
|
+
for (const inputIndex of rest) {
|
|
1349
|
+
const assetRequired = totalRequiredAssets.get(assetUnit);
|
|
1350
|
+
if (!assetRequired || Number(assetRequired) <= 0) break;
|
|
1351
|
+
addUtxoWithAssetAmount(inputIndex, assetUnit, rest);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
for (const inputIndex of onlyLovelace) {
|
|
1355
|
+
const assetRequired = totalRequiredAssets.get("lovelace");
|
|
1356
|
+
if (!assetRequired || Number(assetRequired) <= 0) break;
|
|
1357
|
+
addUtxoWithAssetAmount(inputIndex, "lovelace", onlyLovelace);
|
|
1358
|
+
}
|
|
1359
|
+
for (const inputIndex of singletons) {
|
|
1360
|
+
const assetRequired = totalRequiredAssets.get("lovelace");
|
|
1361
|
+
if (!assetRequired || Number(assetRequired) <= 0) break;
|
|
1362
|
+
addUtxoWithAssetAmount(inputIndex, "lovelace", singletons);
|
|
1363
|
+
}
|
|
1364
|
+
for (const inputIndex of pairs) {
|
|
1365
|
+
const assetRequired = totalRequiredAssets.get("lovelace");
|
|
1366
|
+
if (!assetRequired || Number(assetRequired) <= 0) break;
|
|
1367
|
+
addUtxoWithAssetAmount(inputIndex, "lovelace", pairs);
|
|
1368
|
+
}
|
|
1369
|
+
for (const inputIndex of rest) {
|
|
1370
|
+
const assetRequired = totalRequiredAssets.get("lovelace");
|
|
1371
|
+
if (!assetRequired || Number(assetRequired) <= 0) break;
|
|
1372
|
+
addUtxoWithAssetAmount(inputIndex, "lovelace", rest);
|
|
1373
|
+
}
|
|
1374
|
+
for (const assetUnit of totalRequiredAssets.keys()) {
|
|
1375
|
+
if (Number(totalRequiredAssets.get(assetUnit)) > 0) {
|
|
1376
|
+
console.warn("Insufficient funds for", assetUnit);
|
|
1377
|
+
console.warn(
|
|
1378
|
+
"Remaining quantity",
|
|
1379
|
+
Number(totalRequiredAssets.get(assetUnit))
|
|
1380
|
+
);
|
|
1381
|
+
return [];
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
const selectedUtxos = [];
|
|
1385
|
+
for (const inputIndex of selectedInputs) {
|
|
1386
|
+
const utxo = utxoMap.get(inputIndex);
|
|
1387
|
+
if (utxo) {
|
|
1388
|
+
selectedUtxos.push(utxo);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
return selectedUtxos;
|
|
1392
|
+
};
|
|
1393
|
+
var getAssetAmount = (utxo, assetUnit) => {
|
|
1394
|
+
for (const utxoAsset of utxo.output.amount) {
|
|
1395
|
+
if (utxoAsset.unit == assetUnit) return utxoAsset.quantity;
|
|
1396
|
+
}
|
|
1397
|
+
return "0";
|
|
1398
|
+
};
|
|
1399
|
+
|
|
1400
|
+
// src/utxo-selection/common.ts
|
|
1401
|
+
var enoughValueHasBeenSelected = (selection, assets) => {
|
|
1402
|
+
return Array.from(assets, (asset) => ({
|
|
1403
|
+
unit: asset[0],
|
|
1404
|
+
quantity: BigNum.new(asset[1])
|
|
1405
|
+
})).every((asset) => {
|
|
1406
|
+
return selection.filter((utxo) => {
|
|
1407
|
+
return utxo.output.amount.find((a) => a.unit === asset.unit) !== void 0;
|
|
1408
|
+
}).reduce((selectedQuantity, utxo) => {
|
|
1409
|
+
const utxoQuantity = utxo.output.amount.reduce(
|
|
1410
|
+
(quantity, a) => quantity.checkedAdd(
|
|
1411
|
+
BigNum.new(asset.unit === a.unit ? a.quantity : "0")
|
|
1412
|
+
),
|
|
1413
|
+
BigNum.new("0")
|
|
1414
|
+
);
|
|
1415
|
+
return selectedQuantity.checkedAdd(utxoQuantity);
|
|
1416
|
+
}, BigNum.new("0")).lessThan(asset.quantity) === false;
|
|
1417
|
+
});
|
|
1418
|
+
};
|
|
1419
|
+
var largestLovelaceQuantity = (utxoA, utxoB) => {
|
|
1420
|
+
const aLovelaceQuantity = BigNum.new(
|
|
1421
|
+
utxoA.output.amount.find((asset) => asset.unit === "lovelace")?.quantity ?? "0"
|
|
1422
|
+
);
|
|
1423
|
+
const bLovelaceQuantity = BigNum.new(
|
|
1424
|
+
utxoB.output.amount.find((asset) => asset.unit === "lovelace")?.quantity ?? "0"
|
|
1425
|
+
);
|
|
1426
|
+
return bLovelaceQuantity.compare(aLovelaceQuantity);
|
|
1427
|
+
};
|
|
1428
|
+
var maxTxFees = (parameters) => {
|
|
1429
|
+
const { maxTxSize, minFeeA, minFeeB } = parameters;
|
|
1430
|
+
return BigNum.new(resolveTxFees(maxTxSize, minFeeA, minFeeB));
|
|
1431
|
+
};
|
|
1432
|
+
var multiAssetUTxO = (utxo) => utxo.output.amount.length > 1;
|
|
1433
|
+
var selectedLovelaceQuantity = (multiAsset) => {
|
|
1434
|
+
return multiAsset.reduce((sum, utxo) => {
|
|
1435
|
+
const lovelace = utxo.output.amount.find((asset) => asset.unit === "lovelace")?.quantity ?? "0";
|
|
1436
|
+
return sum.checkedAdd(BigNum.new(lovelace));
|
|
1437
|
+
}, BigNum.new("0"));
|
|
1438
|
+
};
|
|
1439
|
+
var remainingLovelace = (quantity, initialUTxOSet) => {
|
|
1440
|
+
const sortedUTxOs = initialUTxOSet.sort(largestLovelaceQuantity);
|
|
1441
|
+
const requestedOutputSet = /* @__PURE__ */ new Map([["lovelace", quantity]]);
|
|
1442
|
+
const selection = selectValue(sortedUTxOs, requestedOutputSet);
|
|
1443
|
+
return selection;
|
|
1444
|
+
};
|
|
1445
|
+
var selectValue = (inputUTxO, outputSet, selection = []) => {
|
|
1446
|
+
if (inputUTxO.length === 0 || enoughValueHasBeenSelected(selection, outputSet)) {
|
|
1447
|
+
return selection;
|
|
1448
|
+
}
|
|
1449
|
+
if (valueCanBeSelected(inputUTxO[0], outputSet)) {
|
|
1450
|
+
return selectValue(inputUTxO.slice(1), outputSet, [
|
|
1451
|
+
...selection,
|
|
1452
|
+
inputUTxO[0]
|
|
1453
|
+
]);
|
|
1454
|
+
}
|
|
1455
|
+
return selectValue(inputUTxO.slice(1), outputSet, selection);
|
|
1456
|
+
};
|
|
1457
|
+
var valueCanBeSelected = (utxo, assets) => {
|
|
1458
|
+
return Array.from(assets.keys()).some((unit) => {
|
|
1459
|
+
return utxo.output.amount.find((asset) => asset.unit === unit) !== void 0;
|
|
1460
|
+
});
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
// src/utxo-selection/keepRelevant.ts
|
|
1464
|
+
var keepRelevant = (requiredAssets, inputs, threshold = "5000000") => {
|
|
1465
|
+
const requestedLovelace = BigNum.new(
|
|
1466
|
+
requiredAssets.get("lovelace") ?? "0"
|
|
1467
|
+
).checkedAdd(BigNum.new(threshold));
|
|
1468
|
+
const multiAsset = inputs.filter(
|
|
1469
|
+
(utxo) => utxo.output.amount.filter((asset) => asset.unit !== "lovelace").some((asset) => requiredAssets.has(asset.unit))
|
|
1470
|
+
);
|
|
1471
|
+
const selectedLovelace = selectedLovelaceQuantity(multiAsset);
|
|
1472
|
+
const lovelace = selectedLovelace.lessThan(requestedLovelace) ? remainingLovelace(
|
|
1473
|
+
requestedLovelace.clampedSub(selectedLovelace).toString(),
|
|
1474
|
+
inputs.filter((input) => {
|
|
1475
|
+
return !multiAsset.some(
|
|
1476
|
+
(selectedUtxo) => selectedUtxo.input.txHash === input.input.txHash && selectedUtxo.input.outputIndex === input.input.outputIndex
|
|
1477
|
+
);
|
|
1478
|
+
})
|
|
1479
|
+
) : [];
|
|
1480
|
+
return [...lovelace, ...multiAsset];
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
// src/utxo-selection/largestFirst.ts
|
|
1484
|
+
var largestFirst = (lovelace, initialUTxOSet, includeTxFees = false, { maxTxSize, minFeeA, minFeeB } = DEFAULT_PROTOCOL_PARAMETERS) => {
|
|
1485
|
+
const sortedUTxOs = initialUTxOSet.filter((utxo) => multiAssetUTxO(utxo) === false).sort(largestLovelaceQuantity);
|
|
1486
|
+
const maxTxFees2 = BigNum.new(resolveTxFees(maxTxSize, minFeeA, minFeeB));
|
|
1487
|
+
const quantity = includeTxFees ? BigNum.new(lovelace).checkedAdd(maxTxFees2).toString() : lovelace;
|
|
1488
|
+
const requestedOutputSet = /* @__PURE__ */ new Map([["lovelace", quantity]]);
|
|
1489
|
+
const selection = selectValue(sortedUTxOs, requestedOutputSet);
|
|
1490
|
+
return selection;
|
|
1491
|
+
};
|
|
1492
|
+
|
|
1493
|
+
// src/utxo-selection/largestFirstMultiAsset.ts
|
|
1494
|
+
var largestFirstMultiAsset = (requestedOutputSet, initialUTxOSet, includeTxFees = false, parameters = DEFAULT_PROTOCOL_PARAMETERS) => {
|
|
1495
|
+
const sortedMultiAssetUTxOs = initialUTxOSet.filter(multiAssetUTxO).sort(largestLovelaceQuantity);
|
|
1496
|
+
const txFees = maxTxFees(parameters);
|
|
1497
|
+
const lovelace = requestedOutputSet.get("lovelace") ?? "0";
|
|
1498
|
+
const quantity = includeTxFees ? BigNum.new(lovelace).checkedAdd(txFees).toString() : lovelace;
|
|
1499
|
+
requestedOutputSet.set("lovelace", quantity);
|
|
1500
|
+
const selection = selectValue(sortedMultiAssetUTxOs, requestedOutputSet);
|
|
1501
|
+
return selection;
|
|
1502
|
+
};
|
|
1503
|
+
|
|
1504
|
+
// src/utxo-selection/index.ts
|
|
1505
|
+
var UtxoSelection = class {
|
|
1506
|
+
threshold;
|
|
1507
|
+
includeTxFees;
|
|
1508
|
+
constructor(threshold = "5000000", includeTxFees = true) {
|
|
1509
|
+
this.threshold = threshold;
|
|
1510
|
+
this.includeTxFees = includeTxFees;
|
|
1511
|
+
}
|
|
1512
|
+
largestFirst(requiredAssets, inputs) {
|
|
1513
|
+
const lovelaceAmount = requiredAssets.get("lovelace") ?? "0";
|
|
1514
|
+
const requiredAssetWithThreshold = BigInt(lovelaceAmount) + BigInt(this.threshold);
|
|
1515
|
+
return largestFirst(
|
|
1516
|
+
requiredAssetWithThreshold.toString(),
|
|
1517
|
+
inputs,
|
|
1518
|
+
this.includeTxFees
|
|
1519
|
+
);
|
|
1520
|
+
}
|
|
1521
|
+
keepRelevant(requiredAssets, inputs) {
|
|
1522
|
+
return keepRelevant(requiredAssets, inputs, this.threshold);
|
|
1523
|
+
}
|
|
1524
|
+
largestFirstMultiAsset(requiredAssets, inputs) {
|
|
1525
|
+
const lovelaceAmount = requiredAssets.get("lovelace") ?? "0";
|
|
1526
|
+
requiredAssets.set(
|
|
1527
|
+
"lovelace",
|
|
1528
|
+
(BigInt(lovelaceAmount) + BigInt(this.threshold)).toString()
|
|
1529
|
+
);
|
|
1530
|
+
return largestFirstMultiAsset(requiredAssets, inputs, this.includeTxFees);
|
|
1531
|
+
}
|
|
1532
|
+
experimental(requiredAssets, inputs) {
|
|
1533
|
+
return experimentalSelectUtxos(requiredAssets, inputs, this.threshold);
|
|
1534
|
+
}
|
|
1535
|
+
};
|
|
1536
|
+
|
|
1537
|
+
// src/index.ts
|
|
1538
|
+
var import_bip39 = require("bip39");
|
|
1539
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1540
|
+
0 && (module.exports = {
|
|
1541
|
+
AssetFingerprint,
|
|
1542
|
+
BigNum,
|
|
1543
|
+
CIP68_100,
|
|
1544
|
+
CIP68_222,
|
|
1545
|
+
DEFAULT_PROTOCOL_PARAMETERS,
|
|
1546
|
+
DEFAULT_REDEEMER_BUDGET,
|
|
1547
|
+
DEFAULT_V1_COST_MODEL_LIST,
|
|
1548
|
+
DEFAULT_V2_COST_MODEL_LIST,
|
|
1549
|
+
HARDENED_KEY_START,
|
|
1550
|
+
LANGUAGE_VERSIONS,
|
|
1551
|
+
MeshValue,
|
|
1552
|
+
POLICY_ID_LENGTH,
|
|
1553
|
+
SLOT_CONFIG_NETWORK,
|
|
1554
|
+
SUPPORTED_CLOCKS,
|
|
1555
|
+
SUPPORTED_HANDLES,
|
|
1556
|
+
SUPPORTED_LANGUAGE_VIEWS,
|
|
1557
|
+
SUPPORTED_OGMIOS_LINKS,
|
|
1558
|
+
SUPPORTED_TOKENS,
|
|
1559
|
+
SUPPORTED_WALLETS,
|
|
1560
|
+
UtxoSelection,
|
|
1561
|
+
assetClass,
|
|
1562
|
+
assetName,
|
|
1563
|
+
assocMap,
|
|
1564
|
+
bool,
|
|
1565
|
+
builtinByteString,
|
|
1566
|
+
byteString,
|
|
1567
|
+
bytesToHex,
|
|
1568
|
+
castProtocol,
|
|
1569
|
+
conStr,
|
|
1570
|
+
conStr0,
|
|
1571
|
+
conStr1,
|
|
1572
|
+
conStr2,
|
|
1573
|
+
currencySymbol,
|
|
1574
|
+
dict,
|
|
1575
|
+
emptyTxBuilderBody,
|
|
1576
|
+
experimentalSelectUtxos,
|
|
1577
|
+
fromUTF8,
|
|
1578
|
+
fungibleAssetKeys,
|
|
1579
|
+
generateMnemonic,
|
|
1580
|
+
hashByteString,
|
|
1581
|
+
hexToBytes,
|
|
1582
|
+
hexToString,
|
|
1583
|
+
integer,
|
|
1584
|
+
isNetwork,
|
|
1585
|
+
keepRelevant,
|
|
1586
|
+
largestFirst,
|
|
1587
|
+
largestFirstMultiAsset,
|
|
1588
|
+
list,
|
|
1589
|
+
mAssetClass,
|
|
1590
|
+
mBool,
|
|
1591
|
+
mConStr,
|
|
1592
|
+
mConStr0,
|
|
1593
|
+
mConStr1,
|
|
1594
|
+
mConStr2,
|
|
1595
|
+
mMaybeStakingHash,
|
|
1596
|
+
mOutputReference,
|
|
1597
|
+
mPlutusBSArrayToString,
|
|
1598
|
+
mPubKeyAddress,
|
|
1599
|
+
mScriptAddress,
|
|
1600
|
+
mStringToPlutusBSArray,
|
|
1601
|
+
mTuple,
|
|
1602
|
+
mTxOutRef,
|
|
1603
|
+
mValue,
|
|
1604
|
+
maybeStakingHash,
|
|
1605
|
+
mergeAssets,
|
|
1606
|
+
metadataStandardKeys,
|
|
1607
|
+
metadataToCip68,
|
|
1608
|
+
mnemonicToEntropy,
|
|
1609
|
+
outputReference,
|
|
1610
|
+
parseAssetUnit,
|
|
1611
|
+
plutusBSArrayToString,
|
|
1612
|
+
policyId,
|
|
1613
|
+
posixTime,
|
|
1614
|
+
pubKeyAddress,
|
|
1615
|
+
pubKeyHash,
|
|
1616
|
+
resolveEpochNo,
|
|
1617
|
+
resolveFingerprint,
|
|
1618
|
+
resolveLanguageView,
|
|
1619
|
+
resolveSlotNo,
|
|
1620
|
+
resolveTxFees,
|
|
1621
|
+
royaltiesStandardKeys,
|
|
1622
|
+
scriptAddress,
|
|
1623
|
+
scriptHash,
|
|
1624
|
+
slotToBeginUnixTime,
|
|
1625
|
+
stringToBSArray,
|
|
1626
|
+
stringToHex,
|
|
1627
|
+
toBytes,
|
|
1628
|
+
toUTF8,
|
|
1629
|
+
tokenName,
|
|
1630
|
+
tuple,
|
|
1631
|
+
txOutRef,
|
|
1632
|
+
unixTimeToEnclosingSlot,
|
|
1633
|
+
validityRangeToObj,
|
|
1634
|
+
value
|
|
1635
|
+
});
|