@meshsdk/contract 1.6.0-alpha.21 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +37 -0
- package/dist/index.js +28 -1803
- package/package.json +30 -14
- package/.turbo/turbo-build$colon$docs.log +0 -8
- package/.turbo/turbo-build$colon$mesh.log +0 -19
- package/dist/index.mjs +0 -1834
- package/src/common.ts +0 -186
- package/src/coupon-bond-guaranteed/aiken-workspace/readme.md +0 -0
- package/src/coupon-bond-guaranteed/offchain.ts +0 -3
- package/src/coupon-bond-guaranteed/readme.md +0 -3
- package/src/escrow/aiken-workspace/aiken.lock +0 -26
- package/src/escrow/aiken-workspace/aiken.toml +0 -19
- package/src/escrow/aiken-workspace/lib/escrow/types.ak +0 -21
- package/src/escrow/aiken-workspace/lib/escrow/validators/escrow.ak +0 -122
- package/src/escrow/aiken-workspace/plutus.json +0 -238
- package/src/escrow/aiken-workspace/readme.md +0 -55
- package/src/escrow/aiken-workspace/validators/escrow.ak +0 -9
- package/src/escrow/aiken-workspace/validators/tests/escrow.ak +0 -462
- package/src/escrow/index.ts +0 -1
- package/src/escrow/offchain.ts +0 -254
- package/src/escrow/readme.md +0 -38
- package/src/giftcard/aiken-workspace/aiken.lock +0 -26
- package/src/giftcard/aiken-workspace/aiken.toml +0 -19
- package/src/giftcard/aiken-workspace/plutus.json +0 -138
- package/src/giftcard/aiken-workspace/readme.md +0 -55
- package/src/giftcard/aiken-workspace/validators/oneshot.ak +0 -173
- package/src/giftcard/index.ts +0 -1
- package/src/giftcard/offchain.ts +0 -184
- package/src/giftcard/readme.md +0 -36
- package/src/hello-world/aiken-workspace/README.md +0 -19
- package/src/hello-world/aiken-workspace/aiken.lock +0 -15
- package/src/hello-world/aiken-workspace/aiken.toml +0 -14
- package/src/hello-world/aiken-workspace/contract.md +0 -27
- package/src/hello-world/aiken-workspace/plutus.json +0 -69
- package/src/hello-world/aiken-workspace/validators/hello_world.ak +0 -24
- package/src/hello-world/index.ts +0 -1
- package/src/hello-world/offchain.ts +0 -24
- package/src/hello-world/readme.md +0 -1
- package/src/index.ts +0 -6
- package/src/marketplace/aiken-workspace/aiken.lock +0 -26
- package/src/marketplace/aiken-workspace/aiken.toml +0 -19
- package/src/marketplace/aiken-workspace/lib/marketplace/types.ak +0 -15
- package/src/marketplace/aiken-workspace/lib/marketplace/validators/marketplace.ak +0 -52
- package/src/marketplace/aiken-workspace/plutus.json +0 -204
- package/src/marketplace/aiken-workspace/readme.md +0 -55
- package/src/marketplace/aiken-workspace/validators/marketplace.ak +0 -14
- package/src/marketplace/aiken-workspace/validators/tests/marketplace.ak +0 -218
- package/src/marketplace/index.ts +0 -1
- package/src/marketplace/offchain.ts +0 -248
- package/src/marketplace/readme.md +0 -45
- package/src/payment-splitter/aiken-workspace/aiken.lock +0 -15
- package/src/payment-splitter/aiken-workspace/aiken.toml +0 -14
- package/src/payment-splitter/aiken-workspace/plutus.json +0 -83
- package/src/payment-splitter/aiken-workspace/validators/payment-splitter.ak +0 -329
- package/src/payment-splitter/index.ts +0 -1
- package/src/payment-splitter/offchain.ts +0 -143
- package/src/payment-splitter/readme.md +0 -100
- package/src/swap/aiken-workspace/aiken.lock +0 -26
- package/src/swap/aiken-workspace/aiken.toml +0 -19
- package/src/swap/aiken-workspace/plutus.json +0 -208
- package/src/swap/aiken-workspace/readme.md +0 -55
- package/src/swap/aiken-workspace/validators/swap.ak +0 -188
- package/src/swap/index.ts +0 -1
- package/src/swap/offchain.ts +0 -139
- package/src/swap/readme.md +0 -35
- package/src/vesting/aiken-workspace/README.md +0 -24
- package/src/vesting/aiken-workspace/aiken.lock +0 -26
- package/src/vesting/aiken-workspace/aiken.toml +0 -19
- package/src/vesting/aiken-workspace/lib/vesting/types.ak +0 -8
- package/src/vesting/aiken-workspace/lib/vesting/validators/vesting.ak +0 -19
- package/src/vesting/aiken-workspace/plutus.json +0 -67
- package/src/vesting/aiken-workspace/validators/tests/vesting.ak +0 -108
- package/src/vesting/aiken-workspace/validators/vesting.ak +0 -9
- package/src/vesting/index.ts +0 -1
- package/src/vesting/offchain.ts +0 -117
- package/src/vesting/readme.md +0 -36
- package/tsconfig.json +0 -5
- /package/dist/{index.d.mts → index.d.cts} +0 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";var O=Object.defineProperty;var e0=Object.getOwnPropertyDescriptor;var t0=Object.getOwnPropertyNames;var a0=Object.prototype.hasOwnProperty;var c0=(o,e)=>{for(var t in e)O(o,t,{get:e[t],enumerable:!0})},i0=(o,e,t,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of t0(e))!a0.call(o,a)&&a!==t&&O(o,a,{get:()=>e[a],enumerable:!(c=e0(e,a))||c.enumerable});return o};var n0=o=>i0(O({},"__esModule",{value:!0}),o);var x0={};c0(x0,{MeshEscrowBlueprint:()=>u0,MeshEscrowContract:()=>_,MeshGiftCardBlueprint:()=>f0,MeshGiftCardContract:()=>M,MeshMarketplaceBlueprint:()=>r0,MeshMarketplaceContract:()=>H,MeshPaymentSplitterBlueprint:()=>m0,MeshPaymentSplitterContract:()=>W,MeshSwapBlueprint:()=>y0,MeshSwapContract:()=>j,MeshVestingBlueprint:()=>o0,MeshVestingContract:()=>R,activeEscrowDatum:()=>G,initiateEscrowDatum:()=>U,marketplaceDatum:()=>D,recipientDepositRedeemer:()=>Q});module.exports=n0(x0);var f=require("@meshsdk/common"),x=require("@meshsdk/core"),E=require("@meshsdk/core-csl");var L=require("@meshsdk/core-csl"),m=class{mesh;fetcher;wallet;stakeCredential;networkId=0;constructor({mesh:e,fetcher:t,wallet:c,networkId:a,stakeCredential:i}){this.mesh=e,t&&(this.fetcher=t),c&&(this.wallet=c),a&&(this.networkId=a),i&&(this.stakeCredential=this.stakeCredential)}signSubmitReset=async()=>{let e=this.mesh.completeSigning(),t=await this.mesh.submitTx(e);return this.mesh.reset(),t};queryUtxos=async e=>this.fetcher?await this.fetcher.fetchAddressUTxOs(e):[];getWalletDappAddress=async()=>{if(this.wallet){let e=await this.wallet.getUsedAddresses();if(e.length>0)return e[0];let t=await this.wallet.getUnusedAddresses();if(t.length>0)return t[0]}return""};getWalletCollateral=async()=>{if(this.wallet)return(await this.wallet.getCollateral())[0]};getWalletUtxosWithMinLovelace=async(e,t=[])=>{let c=t;return this.wallet&&(!t||t.length===0)&&(c=await this.wallet.getUtxos()),c.filter(a=>{let i=a.output.amount.find(n=>n.unit==="lovelace")?.quantity;return Number(i)>e})};getWalletUtxosWithToken=async(e,t=[])=>{let c=t;return this.wallet&&t.length===0&&(c=await this.wallet.getUtxos()),c.filter(a=>{let i=a.output.amount.find(n=>n.unit===e)?.quantity;return Number(i)>=1})};getAddressUtxosWithMinLovelace=async(e,t,c=[])=>{let a=c;return this.fetcher&&(!c||c.length===0)&&(a=await this.fetcher.fetchAddressUTxOs(e)),a.filter(i=>{let n=i.output.amount.find(s=>s.unit==="lovelace")?.quantity;return Number(n)>t})};getAddressUtxosWithToken=async(e,t,c=[])=>{let a=c;return this.fetcher&&c.length===0&&(a=await this.fetcher.fetchAddressUTxOs(e)),a.filter(i=>{let n=i.output.amount.find(s=>s.unit===t)?.quantity;return Number(n)>=1})};getWalletInfoForTx=async()=>{let e=await this.wallet?.getUtxos(),t=await this.getWalletCollateral(),c=await this.getWalletDappAddress();if(!e||e?.length===0)throw new Error("No utxos found");if(!t)throw new Error("No collateral found");if(!c)throw new Error("No wallet address found");return{utxos:e,collateral:t,walletAddress:c}};_getUtxoByTxHash=async(e,t)=>{if(this.fetcher){let c=await this.fetcher?.fetchUTxOs(t),a=(0,L.v2ScriptToBech32)(e,void 0,this.networkId);return c.filter(n=>n.output.address===a)[0]||c[0]}}};var P={preamble:{title:"meshjs/marketplace",description:"Aiken contracts for project 'meshjs/marketplace'",version:"0.0.0",plutusVersion:"v2",compiler:{name:"Aiken",version:"v1.0.29-alpha+unknown"},license:"Apache-2.0"},validators:[{title:"marketplace.marketplace",datum:{title:"datum",schema:{$ref:"#/definitions/marketplace~1types~1MarketplaceDatum"}},redeemer:{title:"redeemer",schema:{$ref:"#/definitions/marketplace~1types~1MarketplaceRedeemer"}},parameters:[{title:"owner",schema:{$ref:"#/definitions/aiken~1transaction~1credential~1Address"}},{title:"fee_percentage_basis_point",schema:{$ref:"#/definitions/Int"}}],compiledCode:"59082f01000032323232323232223223232322322533300b3232323232323232325333014300e30153754002264a66602a6020602c6ea80344c94ccc058c044c05cdd50008991919299980c99299980e8008a501533301d302000114a22940cc88c8cc00400400c894ccc08000452f5c026464a66603e66ebcc048c084dd5180898109baa00200513302300233004004001133004004001302400230220013758601860366ea8c030c06cdd50079806180d9baa300b301b37540062a6660320022004294052819803998049bac3008301a3754601660346ea803805cc018cdc199b82375a601460346ea805005520a09c0133006330083758600e60326ea8c028c064dd50069805180c9baa0133005337006eb4c024c064dd50099998059bab300930193754601260326ea8005220100488100301b301837540022c64660020026eb0c024c060dd51804980c1baa00c22533301a00114c0103d87a80001323253330193375e601860366ea80080144c038cc0740092f5c0266008008002603c0046038002264a66602c6022602e6ea80044cc88c8cc00400400c894ccc074004528099299980d99b8f375c604000400829444cc00c00c004c080004dd6180d980e180e180e180e180e180e180e180e180c1baa3009301837540186eb8c06cc060dd50008b19299980b1808980b9baa0011300b3301a301b3018375400297ae014c0103d87a80003008301737546010602e6ea8044c064c058dd50008a503005301537540124a666026601c002297adef6c6013232330010014bd6f7b63011299980c80089980d19bb04c01014000374c00697adef6c60132323232533301a3372091010000213301e337609801014000374c00e00a2a66603466e3d2210000213301e337609801014000374c00e00626603c66ec0dd48011ba600133006006003375660360066eb8c064008c074008c06c004c8cc0040052f5bded8c044a66603000226603266ec13001014000375000697adef6c6013232323253330193372091010000213301d337609801014000375000e00a2a66603266e3d2210000213301d337609801014000375000e00626603a66ec0dd48011ba800133006006003375a60340066eb8c060008c070008c06800488c8cc004004c8cc00400400c894ccc06400452f5c0264666444646600200200644a66603e0022006264660426e9ccc084dd480319810980f00099810980f800a5eb80cc00c00cc08c008c084004dd7180c0009bab301900133003003301d002301b00122533301800114a2264a66602c6466e24dd698038009998058031bae300a001375c60120026eb0c06c0084cc00c00c004528180d8009180b180b980b80091191980080080191299980b0008a5eb7bdb1804cc894ccc054cdd79804180b9baa0020051323330010010023756601060306ea800c8894ccc06c00840044c8ccc010010c07c00ccc88c8cc004004014894ccc0800044cc084cdd81ba9004374c00697adef6c6013232323253330213372001000426604a66ec0dd48041ba6007005153330213371e010004264a666044603a60466ea80044cc098cdd81ba9009302730243754002008200864a666044a66604a00229445280a6103d87a80001301733026374c00297ae03233300100100800222253330270021001132333004004302b0033322323300100100522533302c00113302d337606ea4010dd4001a5eb7bdb1804c8c8c8c94ccc0b4cdc800400109981899bb037520106ea001c01454ccc0b4cdc78040010992999817181498179baa001133032337606ea4024c0ccc0c0dd5000802080219299981718148008a60103d87a80001302333032375000297ae03370000e00226606266ec0dd48011ba800133006006003375a605c0066eb8c0b0008c0c0008c0b8004dd718130009bad30270013029002133025337606ea4008dd3000998030030019bab3022003375c6040004604800460440026eb8c068004dd5980d800980e8010800980c00099801001180c8009180a180a80091809800911192999808180518089baa0011480004dd6980a98091baa001325333010300a301137540022980103d87a8000132330010013756602c60266ea8008894ccc054004530103d87a80001323232325333016337220100042a66602c66e3c0200084c02ccc068dd4000a5eb80530103d87a8000133006006003375a602e0066eb8c054008c064008c05c004c8cc004004010894ccc0500045300103d87a80001323232325333015337220100042a66602a66e3c0200084c028cc064dd3000a5eb80530103d87a80001330060060033756602c0066eb8c050008c060008c058004dd2a400029309b2b19299980518028008a99980698061baa00214985854ccc028c01000454ccc034c030dd50010a4c2c2c60146ea8004c94ccc020c00cc024dd5002099191919191919192999809980b00109924ca666020601660226ea801c4c8c8c8c94ccc05cc0680084c8c926325333016301100113232533301b301e002132498c94ccc064c0500044c8c94ccc078c0840084c926301400116301f001301b37540042a66603260260022646464646464a666044604a0042930b1bad30230013023002375a604200260420046eb4c07c004c06cdd50010b180c9baa00116301c001301837540062a66602c60200022a66603260306ea800c526161630163754004601a0062c60300026030004602c00260246ea801c5858dd7180a000980a0011bae30120013012002375a60200026020004601c00260146ea8010588c94ccc024c0100044c8c94ccc038c04400852616375c601e00260166ea800854ccc024c00c0044c8c94ccc038c04400852616375c601e00260166ea800858c024dd50009b8748008dc3a40006eb40055cd2ab9d5573caae7d5d02ba157441",hash:"cd144c1e18d8e44dfeacb018a2795d17d7c30574a427eb2aa2dbc87c"}],definitions:{ByteArray:{dataType:"bytes"},Int:{dataType:"integer"},"Option$aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential":{title:"Optional",anyOf:[{title:"Some",description:"An optional value.",dataType:"constructor",index:0,fields:[{$ref:"#/definitions/aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"}]},{title:"None",description:"Nothing.",dataType:"constructor",index:1,fields:[]}]},"aiken/transaction/credential/Address":{title:"Address",description:`A Cardano \`Address\` typically holding one or two credential references.
|
|
2
|
+
|
|
3
|
+
Note that legacy bootstrap addresses (a.k.a. 'Byron addresses') are
|
|
4
|
+
completely excluded from Plutus contexts. Thus, from an on-chain
|
|
5
|
+
perspective only exists addresses of type 00, 01, ..., 07 as detailed
|
|
6
|
+
in [CIP-0019 :: Shelley Addresses](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0019/#shelley-addresses).`,anyOf:[{title:"Address",dataType:"constructor",index:0,fields:[{title:"payment_credential",$ref:"#/definitions/aiken~1transaction~1credential~1Credential"},{title:"stake_credential",$ref:"#/definitions/Option$aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"}]}]},"aiken/transaction/credential/Credential":{title:"Credential",description:`A general structure for representing an on-chain \`Credential\`.
|
|
7
|
+
|
|
8
|
+
Credentials are always one of two kinds: a direct public/private key
|
|
9
|
+
pair, or a script (native or Plutus).`,anyOf:[{title:"VerificationKeyCredential",dataType:"constructor",index:0,fields:[{$ref:"#/definitions/ByteArray"}]},{title:"ScriptCredential",dataType:"constructor",index:1,fields:[{$ref:"#/definitions/ByteArray"}]}]},"aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential":{title:"Referenced",description:`Represent a type of object that can be represented either inline (by hash)
|
|
10
|
+
or via a reference (i.e. a pointer to an on-chain location).
|
|
11
|
+
|
|
12
|
+
This is mainly use for capturing pointers to a stake credential
|
|
13
|
+
registration certificate in the case of so-called pointer addresses.`,anyOf:[{title:"Inline",dataType:"constructor",index:0,fields:[{$ref:"#/definitions/aiken~1transaction~1credential~1Credential"}]},{title:"Pointer",dataType:"constructor",index:1,fields:[{title:"slot_number",$ref:"#/definitions/Int"},{title:"transaction_index",$ref:"#/definitions/Int"},{title:"certificate_index",$ref:"#/definitions/Int"}]}]},"marketplace/types/MarketplaceDatum":{title:"MarketplaceDatum",anyOf:[{title:"MarketplaceDatum",dataType:"constructor",index:0,fields:[{title:"seller",$ref:"#/definitions/aiken~1transaction~1credential~1Address"},{title:"price",$ref:"#/definitions/Int"},{title:"policy",$ref:"#/definitions/ByteArray"},{title:"tokenName",$ref:"#/definitions/ByteArray"}]}]},"marketplace/types/MarketplaceRedeemer":{title:"MarketplaceRedeemer",anyOf:[{title:"Buy",dataType:"constructor",index:0,fields:[]},{title:"Close",dataType:"constructor",index:1,fields:[]}]}}};var r0=P,D=(o,e,t)=>{let{pubKeyHash:c,stakeCredentialHash:a}=(0,x.deserializeAddress)(o),{policyId:i,assetName:n}=(0,f.parseAssetUnit)(t);return(0,f.conStr0)([(0,f.pubKeyAddress)(c,a),(0,f.integer)(e),(0,f.currencySymbol)(i),(0,f.tokenName)(n)])},H=class extends m{ownerAddress;feePercentageBasisPoint;scriptCbor;constructor(e,t,c){super(e),this.ownerAddress=t,this.feePercentageBasisPoint=c;let{pubKeyHash:a,stakeCredentialHash:i}=(0,x.deserializeAddress)(t);this.scriptCbor=(0,E.applyParamsToScript)(P.validators[0].compiledCode,[(0,f.pubKeyAddress)(a,i),(0,f.integer)(c)],"JSON")}listAsset=async(e,t)=>{let{utxos:c,walletAddress:a}=await this.getWalletInfoForTx();new Map().set(e,"1");let{address:n}=(0,x.serializePlutusScript)({code:this.scriptCbor,version:"V2"},void 0,this.networkId),s=[{unit:e,quantity:"1"}],d=D(a,t,e);return await this.mesh.txOut(n,s).txOutInlineDatumValue(d,"JSON").changeAddress(a).selectUtxosFrom(c).complete(),this.mesh.txHex};delistAsset=async e=>{let{utxos:t,walletAddress:c,collateral:a}=await this.getWalletInfoForTx();return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,e.output.address).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue((0,f.mConStr1)([])).txInScript(this.scriptCbor).changeAddress(c).requiredSignerHash((0,x.deserializeAddress)(c).pubKeyHash).txInCollateral(a.input.txHash,a.input.outputIndex,a.output.amount,a.output.address).selectUtxosFrom(t).complete(),this.mesh.txHex};purchaseAsset=async e=>{let{utxos:t,walletAddress:c,collateral:a}=await this.getWalletInfoForTx(),i=(0,x.deserializeDatum)(e.output.plutusData),n=i.fields[1].int.toString(),s=e.output.amount.find(b=>b.unit==="lovelace").quantity,d=this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,e.output.address).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue((0,f.mConStr0)([])).txInScript(this.scriptCbor).changeAddress(c).txInCollateral(a.input.txHash,a.input.outputIndex,a.output.amount,a.output.address).selectUtxosFrom(t),l=i.fields[1].int*this.feePercentageBasisPoint/1e4;if(this.feePercentageBasisPoint>0&&l<1e6&&(l=1e6),l>0){let b=this.ownerAddress,g=[{unit:"lovelace",quantity:Math.ceil(l).toString()}];d.txOut(b,g)}let r=i.fields[1].int+Number(s);if(r>0){let b=(0,x.serializeAddressObj)(i.fields[0]),g=[{unit:"lovelace",quantity:r.toString()}];d.txOut(b,g)}return await d.complete(),this.mesh.txHex};relistAsset=async(e,t)=>{let{utxos:c,walletAddress:a,collateral:i}=await this.getWalletInfoForTx(),n=e.output.amount.find(r=>r.unit!=="lovelace").unit,s=[{unit:n,quantity:"1"}],d=D(a,t,n),{address:l}=(0,x.serializePlutusScript)({code:this.scriptCbor,version:"V2"},void 0,this.networkId);return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,e.output.address).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue((0,f.mConStr1)([])).txInScript(this.scriptCbor).txOut(l,s).txOutInlineDatumValue(d,"JSON").changeAddress(a).requiredSignerHash((0,x.deserializeAddress)(a).pubKeyHash).txInCollateral(i.input.txHash,i.input.outputIndex,i.output.amount,i.output.address).selectUtxosFrom(c).complete(),this.mesh.txHex};getUtxoByTxHash=async e=>await this._getUtxoByTxHash(this.scriptCbor,e)};var S=require("@meshsdk/common"),T=require("@meshsdk/core"),z=require("@meshsdk/core-csl");var B={preamble:{title:"meshjs/vesting",description:"Aiken contracts for project 'meshjs/vesting'",version:"0.0.0",plutusVersion:"v2",compiler:{name:"Aiken",version:"v1.0.29-alpha+unknown"},license:"Apache-2.0"},validators:[{title:"vesting.vesting",datum:{title:"datum",schema:{$ref:"#/definitions/vesting~1types~1VestingDatum"}},redeemer:{title:"_redeemer",schema:{$ref:"#/definitions/ByteArray"}},compiledCode:"5901c801000032323232323232232232253330063232323253323300b3001300c3754600a601a6ea801854ccc02ccc010dd6180198069baa3002300d375400c6eb8c014c034dd50050a511533300b3300437586006601a6ea8c008c034dd50031bae301030113011300d3754014266446464646464a666024601060266ea80084c94ccc04c0104cdc40038008011bad301730143754004002264a666024601060266ea80084c94ccc04c0100084cdc48038009bad3017301437540040022940c054008cdc42400060206ea8c050c054004cc048c04c004cc048ccc038cdc424000601e6ea8c04cc05000530103d87a80004c0103d87980004bd7018079baa3004300f375400460206022602260226022602260226022601a6ea8c008c034dd50031bad3002300d37540142940dc3a400429408c03c0048c038c03cc03cc03cc03cc03cc03cc03cc03c00488c8cc00400400c894ccc038004528099299980619b8f375c602200400829444cc00c00c004c0440048c030c03400452613656375c002a66600466e1d2000300337540022646464646464a666016601c0042930b1bae300c001300c002375c601400260140046eb4c020004c010dd50008b2b9a5573aaae7955cfaba05742ae89",hash:"5978a5118ecb36ad827390a21769bfa680ffc499d364bad913b4dffa"}],definitions:{ByteArray:{dataType:"bytes"},Int:{dataType:"integer"},"vesting/types/VestingDatum":{title:"VestingDatum",anyOf:[{title:"VestingDatum",dataType:"constructor",index:0,fields:[{title:"lock_until",description:"POSIX time in second, e.g. 1672843961000",$ref:"#/definitions/Int"},{title:"owner",description:"Owner's credentials",$ref:"#/definitions/ByteArray"},{title:"beneficiary",description:"Beneficiary's credentials",$ref:"#/definitions/ByteArray"}]}]}}};var o0=B,R=class extends m{scriptCbor=(0,z.applyParamsToScript)(B.validators[0].compiledCode,[]);constructor(e){super(e)}depositFund=async(e,t,c)=>{let{utxos:a,walletAddress:i}=await this.getWalletInfoForTx(),n=(0,T.serializePlutusScript)({code:this.scriptCbor,version:"V2"},void 0,0).address,{pubKeyHash:s}=(0,T.deserializeAddress)(i),{pubKeyHash:d}=(0,T.deserializeAddress)(c);return await this.mesh.txOut(n,e).txOutInlineDatumValue((0,S.mConStr0)([t,s,d])).changeAddress(i).selectUtxosFrom(a).complete(),this.mesh.txHex};withdrawFund=async e=>{let{utxos:t,walletAddress:c,collateral:a}=await this.getWalletInfoForTx(),{input:i,output:n}=a,s=(0,T.serializePlutusScript)({code:this.scriptCbor,version:"V2"},void 0,0).address,{pubKeyHash:d}=(0,T.deserializeAddress)(c),l=(0,T.deserializeDatum)(e.output.plutusData),r=(0,S.unixTimeToEnclosingSlot)(Math.min(l.fields[0].int,Date.now()-15e3),this.networkId===0?S.SLOT_CONFIG_NETWORK.preprod:S.SLOT_CONFIG_NETWORK.mainnet)+1;return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,s).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(this.scriptCbor).txOut(c,[]).txInCollateral(i.txHash,i.outputIndex,n.amount,n.address).invalidBefore(r).requiredSignerHash(d).changeAddress(c).selectUtxosFrom(t).complete(),this.mesh.txHex};getUtxoByTxHash=async e=>await this._getUtxoByTxHash(this.scriptCbor,e)};var p=require("@meshsdk/common"),u=require("@meshsdk/core"),J=require("@meshsdk/core-csl");var V={preamble:{title:"meshjs/escrow",description:"Aiken contracts for project 'meshjs/escrow'",version:"0.0.0",plutusVersion:"v2",compiler:{name:"Aiken",version:"v1.0.29-alpha+unknown"},license:"Apache-2.0"},validators:[{title:"escrow.escrow",datum:{title:"datum",schema:{$ref:"#/definitions/escrow~1types~1EscrowDatum"}},redeemer:{title:"redeemer",schema:{$ref:"#/definitions/escrow~1types~1EscrowRedeemer"}},compiledCode:"590c2f01000032323232323232232323232323232232322533300d323232323232323232323232323232533301c3019301d37540022646464646464a666044604060466ea80044c8c94ccc090c0880044c8c8c8c8c8c8c94ccc0b8c0c400c4c94ccc0bcc0c800c4c94ccc0b4c08cc0b8dd5000899192999817981298181baa0011325333030302e30313754006264646464a66606e6074004264646464a66607066ebc024cdd2a40046607800e660786e98014cc0f004ccc0f0dd300925eb804004528198111bab302830393754018660426eacc0a0c0e4dd51814181c9baa00d3020011302f0073302f00223233031375660720044646eb4c0ec008dd7181c8009bae3037001302f00316375660700026070004606c00260646ea800c58c0d0c0c4dd50008b180d98181baa0033032302f37540022c6032605c6ea8c074c0b8dd50010b18180010b18178011bac302e302f0023758605a002660566e9ccc058028014cc0acdd39980a804002a5eb80dd598159816001181500098131baa01b153330243021001132323232533302b302e0031533302b0021325333029301f302a375400226464a666056605260586ea80084c94ccc0b0c0a8c0b4dd50008998098061bae3031302e37540022c60266060605a6ea80084c8c8c8c8c8c8c8c94ccc0ccc0c4c0d0dd500089919299981a9819981b1baa0011533303532330010013303a375200666074607660706ea80092f5c044a66607400229404c94ccc0e0cc07c060dd7181e8010a51133003003001303d00115333035005100414a0294058c070014dd7181c181a9baa00116301a0063301c33017012002301a3756606c606e006660366602c02200860326eacc0d400cc0d0004c0d0004c0cc008c0c4004c0b4dd50011811800981718159baa001163015302a3754603260546ea80045858c0b0008dd6181598160011bac302a00133028374e6602600e004660506e9ccc0480140092f5c0264646464a666056605c0062a666056004264a666052603e60546ea80044c94ccc0a8c09cc0acdd500089919191919191919299981a981c001099191919191919299981c981b981d1baa00113232533303b3039303c37540022a6660766466002002660806ea400ccc100c104c0f8dd500125eb80894ccc100004528899299981f1981280f1bae304300213300300300114a060860022a66607600a200829405280b18110059bae303e303b37540022c604001a660446603a0300106040014660426603802e016603e00a6605e008464660626eacc0e40088c8dd6981d8011bae3039001375c606e002605e00a6605a00c4646605e6eacc0dc0088c8dd6981c8011bae3037001375c606a002605a00e2c6eacc0d8004c0d8008c0d0004c0d0008dd598190009819001181800098161baa00116302e302b37540022c602a60546ea8c064c0a8dd50008b0b18160011bac302b302c00237586054002660506e9ccc04c01c008cc0a0dd39980900280125eb80c090dd500d180918121baa301330243754604e60486ea800458c8c8cc004004018894ccc09c004530103d87a80001323253330263375e602c60506ea80080144c048cc0a80092f5c026600800800260560046052002604c60466ea8018dd618129813181318131813181318130011bac30240013024302400237586044002603c6ea8c030c078dd50080a50300c301d375401e44646600200200644a666042002297adef6c601332253330203375e602060446ea80080144cc028004dd5980898111baa0021001302300133002002302400122323300100100322533302000114a0264a66603c66e3cdd718118010020a511330030030013023001232533301a3018301b37540022600c6603c603e60386ea80052f5c02980103d87a80003009301b37540024646600200200444a66603a002297adef6c6013322323233330110030020012226323200232323300100100322533302400114984c94ccc09400454ccc088c010dd6981218138010a4c2c264646464a66604c66e40dd718138021bae30270031533302630080011330070073302a0030021616375a604e00660540066050004604e004604e002466603e603a002941289bab301f003375c603a004603e0026600400460400024464666002002006004444a66603c00420022646660080086044006666601e0046eb8c074004dd5980f00091119299981029998118008a5114a02980103d87a80001300c33024374c00297ae0323330010010030022225333025002100113233300400430290033322323300100100522533302a00113302b337606ea4010dd4001a5eb7bdb1804c8c8c8c94ccc0accdc800400109981799bb037520106ea001c01454ccc0accdc78040010992999816181518169baa001133030337606ea4024c0c4c0b8dd5000802080219299981618150008a60103d87a80001301833030375000297ae03370000e00226605e66ec0dd48011ba800133006006003375a60580066eb8c0a8008c0b8008c0b0004dd718120009bad302500130270023020002223233001001323300100100322533301d00114bd7009919991119198008008019129998118008801899198129ba733025375200c6604a60440026604a604600297ae03300300330270023025001375c60380026eacc074004cc00c00cc084008c07c004894ccc070004528899299980d1919b89375a6010002664464a66603c6036603e6ea8004520001375a604660406ea8004c94ccc078c06cc07cdd50008a6103d87a8000132330010013756604860426ea8008894ccc08c004530103d87a80001323232325333024337220100042a66604866e3c0200084c040cc0a0dd4000a5eb80530103d87a8000133006006003375a604a0066eb8c08c008c09c008c094004c8cc004004024894ccc0880045300103d87a80001323232325333023337220100042a66604666e3c0200084c03ccc09cdd3000a5eb80530103d87a8000133006006003375660480066eb8c088008c098008c090004dd718058009bae300c0013758603e0042660060060022940c07c004dd2a40004603260346034002446600c004466ebcc014c05cdd50008011119802801119baf300430163754600a602c6ea80040088c0580048c054c05800488c8cc00400400c894ccc05400452f5c026464a666028600a004266030004660080080022660080080026032004602e0024444646600200200a44a66602c00226602e66ec0dd48029ba60044bd6f7b630099191919299980b99b9000900213301b337606ea4024dd30040028a99980b99b8f009002132533301830163019375400226603866ec0dd4805180e980d1baa001004100433300700900800113301b337606ea4008dd3000998030030019bab3018003375c602c0046034004603000229309b2b19299980618050008991919192999809980b0010991924c660160044646601a6eacc0540088c8dd6980b8011bae3015001375c602600260160062c6eacc050004c050008c048004c038dd50018a99980618048008a99980798071baa00314985854ccc030c00800454ccc03cc038dd50018a4c2c2c60186ea8008dc3a4008600200e464a666012600e002264646464a6660206026004264649319804001119198051bab3012002232375a60280046eb8c048004dd7180800098040018b1bab30110013011002300f001300b37540042a666012600c00226464646464646464a666028602e0042646464649319807002119198081bab3018002232375a60340046eb8c060004dd7180b000980700299806003119198071bab3016002232375a60300046eb8c058004dd7180a00098060038b1bab3015001301500230130013013002375660220026022004601e00260166ea800858c024dd50009119198008008019129998068008a4c2646600600660220046006601e0024a66600c6008600e6ea80044c8c8c8c94ccc034c0400084c8c92632533300c300a0011323253330113014002132498c94ccc03cc0340044c8c94ccc050c05c0084c926300d001163015001301137540042a66601e60180022646464646464a66603060360042930b1bad30190013019002375a602e002602e0046eb4c054004c044dd50010b18079baa001163012001300e37540062a66601860120022a66601e601c6ea800c5261616300c3754004600c0062c601c002601c004601800260106ea8004588c94ccc018c0100044c8c94ccc02cc03800852616375c601800260106ea800854ccc018c00c0044c8c94ccc02cc03800852616375c601800260106ea800858c018dd50009b8748008dc3a4000ae6955ceaab9e5573eae815d0aba201",hash:"bb0ead2a88fda451e0e5e01ff096309c06c1a6eb2206209d20243aaa"}],definitions:{ByteArray:{dataType:"bytes"},Int:{dataType:"integer"},List$Pair$ByteArray_Int:{dataType:"map",keys:{$ref:"#/definitions/ByteArray"},values:{$ref:"#/definitions/Int"}},List$Pair$ByteArray_List$Pair$ByteArray_Int:{dataType:"map",keys:{$ref:"#/definitions/ByteArray"},values:{$ref:"#/definitions/List$Pair$ByteArray_Int"}},"Option$aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential":{title:"Optional",anyOf:[{title:"Some",description:"An optional value.",dataType:"constructor",index:0,fields:[{$ref:"#/definitions/aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"}]},{title:"None",description:"Nothing.",dataType:"constructor",index:1,fields:[]}]},"aiken/transaction/credential/Address":{title:"Address",description:`A Cardano \`Address\` typically holding one or two credential references.
|
|
14
|
+
|
|
15
|
+
Note that legacy bootstrap addresses (a.k.a. 'Byron addresses') are
|
|
16
|
+
completely excluded from Plutus contexts. Thus, from an on-chain
|
|
17
|
+
perspective only exists addresses of type 00, 01, ..., 07 as detailed
|
|
18
|
+
in [CIP-0019 :: Shelley Addresses](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0019/#shelley-addresses).`,anyOf:[{title:"Address",dataType:"constructor",index:0,fields:[{title:"payment_credential",$ref:"#/definitions/aiken~1transaction~1credential~1Credential"},{title:"stake_credential",$ref:"#/definitions/Option$aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"}]}]},"aiken/transaction/credential/Credential":{title:"Credential",description:`A general structure for representing an on-chain \`Credential\`.
|
|
19
|
+
|
|
20
|
+
Credentials are always one of two kinds: a direct public/private key
|
|
21
|
+
pair, or a script (native or Plutus).`,anyOf:[{title:"VerificationKeyCredential",dataType:"constructor",index:0,fields:[{$ref:"#/definitions/ByteArray"}]},{title:"ScriptCredential",dataType:"constructor",index:1,fields:[{$ref:"#/definitions/ByteArray"}]}]},"aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential":{title:"Referenced",description:`Represent a type of object that can be represented either inline (by hash)
|
|
22
|
+
or via a reference (i.e. a pointer to an on-chain location).
|
|
23
|
+
|
|
24
|
+
This is mainly use for capturing pointers to a stake credential
|
|
25
|
+
registration certificate in the case of so-called pointer addresses.`,anyOf:[{title:"Inline",dataType:"constructor",index:0,fields:[{$ref:"#/definitions/aiken~1transaction~1credential~1Credential"}]},{title:"Pointer",dataType:"constructor",index:1,fields:[{title:"slot_number",$ref:"#/definitions/Int"},{title:"transaction_index",$ref:"#/definitions/Int"},{title:"certificate_index",$ref:"#/definitions/Int"}]}]},"escrow/types/EscrowDatum":{title:"EscrowDatum",anyOf:[{title:"Initiation",dataType:"constructor",index:0,fields:[{title:"initiator",$ref:"#/definitions/aiken~1transaction~1credential~1Address"},{title:"initiator_assets",$ref:"#/definitions/List$Pair$ByteArray_List$Pair$ByteArray_Int"}]},{title:"ActiveEscrow",dataType:"constructor",index:1,fields:[{title:"initiator",$ref:"#/definitions/aiken~1transaction~1credential~1Address"},{title:"initiator_assets",$ref:"#/definitions/List$Pair$ByteArray_List$Pair$ByteArray_Int"},{title:"recipient",$ref:"#/definitions/aiken~1transaction~1credential~1Address"},{title:"recipient_assets",$ref:"#/definitions/List$Pair$ByteArray_List$Pair$ByteArray_Int"}]}]},"escrow/types/EscrowRedeemer":{title:"EscrowRedeemer",anyOf:[{title:"RecipientDeposit",dataType:"constructor",index:0,fields:[{title:"recipient",$ref:"#/definitions/aiken~1transaction~1credential~1Address"},{title:"recipient_assets",$ref:"#/definitions/List$Pair$ByteArray_List$Pair$ByteArray_Int"}]},{title:"CancelTrade",dataType:"constructor",index:1,fields:[]},{title:"CompleteTrade",dataType:"constructor",index:2,fields:[]}]}}};var u0=V,U=(o,e)=>{let{pubKeyHash:t,stakeCredentialHash:c}=(0,u.deserializeAddress)(o);return(0,p.conStr0)([(0,p.pubKeyAddress)(t,c),(0,p.value)(e)])},G=(o,e,t)=>{let{pubKeyHash:c,stakeCredentialHash:a}=(0,u.deserializeAddress)(e),[i,n]=o.fields;return(0,p.conStr1)([i,n,(0,p.pubKeyAddress)(c,a),(0,p.value)(t)])},Q=(o,e)=>U(o,e),_=class extends m{scriptCbor=(0,J.applyParamsToScript)(V.validators[0].compiledCode,[]);constructor(e){super(e)}initiateEscrow=async e=>{let{utxos:t,walletAddress:c}=await this.getWalletInfoForTx(),{address:a}=(0,u.serializePlutusScript)({code:this.scriptCbor,version:"V2"},void 0,this.networkId);return await this.mesh.txOut(a,e).txOutInlineDatumValue(U(c,e),"JSON").changeAddress(c).selectUtxosFrom(t).complete(),this.mesh.txHex};cancelEscrow=async e=>{let{utxos:t,walletAddress:c,collateral:a}=await this.getWalletInfoForTx(),{address:i}=(0,u.serializePlutusScript)({code:this.scriptCbor,version:"V2"},void 0,this.networkId),n=(0,u.deserializeDatum)(e.output.plutusData);if(n.constructor===1){let[s,d,l,r]=n.fields,b=(0,u.serializeAddressObj)(s),g=(0,u.serializeAddressObj)(l),w=(0,p.parsePlutusValueToAssets)(d),k=(0,p.parsePlutusValueToAssets)(r);this.mesh.txOut(b,w).txOut(g,k)}return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,i).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue((0,p.mConStr1)([])).txInScript(this.scriptCbor).requiredSignerHash((0,u.deserializeAddress)(c).pubKeyHash).changeAddress(c).txInCollateral(a.input.txHash,a.input.outputIndex,a.output.amount,a.output.address).selectUtxosFrom(t).complete(),this.mesh.txHex};recipientDeposit=async(e,t)=>{let{utxos:c,walletAddress:a,collateral:i}=await this.getWalletInfoForTx(),{address:n}=(0,u.serializePlutusScript)({code:this.scriptCbor,version:"V2"},void 0,this.networkId),s=(0,u.deserializeDatum)(e.output.plutusData),d=G(s,a,t),l=(0,p.parsePlutusValueToAssets)(s.fields[1]),r=(0,u.mergeAssets)([...t,...l]);return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,n).spendingReferenceTxInInlineDatumPresent().txInRedeemerValue(Q(a,t),"JSON",{mem:7e6,steps:3e9}).txInScript(this.scriptCbor).txOut(n,r).txOutInlineDatumValue(d,"JSON").changeAddress(a).txInCollateral(i.input.txHash,i.input.outputIndex,i.output.amount,i.output.address).selectUtxosFrom(c).complete(),this.mesh.txHex};completeEscrow=async e=>{let{utxos:t,walletAddress:c,collateral:a}=await this.getWalletInfoForTx(),{address:i}=(0,u.serializePlutusScript)({code:this.scriptCbor,version:"V2"},void 0,this.networkId),n=(0,u.deserializeDatum)(e.output.plutusData),[s,d,l,r]=n.fields,b=(0,u.serializeAddressObj)(s),g=(0,u.serializeAddressObj)(l),w=(0,p.parsePlutusValueToAssets)(r),k=(0,p.parsePlutusValueToAssets)(d);return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,i).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue((0,p.mConStr2)([])).txInScript(this.scriptCbor).txOut(b,w).txOut(g,k).requiredSignerHash((0,u.deserializeAddress)(g).pubKeyHash).requiredSignerHash((0,u.deserializeAddress)(b).pubKeyHash).changeAddress(c).txInCollateral(a.input.txHash,a.input.outputIndex,a.output.amount,a.output.address).selectUtxosFrom(t).complete(),this.mesh.txHex};getUtxoByTxHash=async e=>await this._getUtxoByTxHash(this.scriptCbor,e)};var I=require("@meshsdk/common"),C=require("@meshsdk/core"),N=require("@meshsdk/core-csl");var v={preamble:{title:"meshjs/giftcard",description:"Aiken contracts for project 'meshjs/giftcard'",version:"0.0.0",plutusVersion:"v2",compiler:{name:"Aiken",version:"v1.0.29-alpha+unknown"},license:"Apache-2.0"},validators:[{title:"oneshot.gift_card",redeemer:{title:"rdmr",schema:{$ref:"#/definitions/oneshot~1Action"}},parameters:[{title:"token_name",schema:{$ref:"#/definitions/ByteArray"}},{title:"utxo_ref",schema:{$ref:"#/definitions/aiken~1transaction~1OutputReference"}}],compiledCode:"5901f5010000323232323232322322232323225333009323232533300c3007300d3754002264646464a666026602c00426464a666024601a60266ea803854ccc048c034c04cdd5191980080080311299980b8008a60103d87a80001323253330163375e603660306ea800804c4cdd2a40006603400497ae0133004004001301b002301900115333012300c00113371e00402029405854ccc048cdc3800a4002266e3c0080405281bad3013002375c60220022c602800264a66601e601260206ea800452f5bded8c026eacc050c044dd500099191980080099198008009bab3016301730173017301700522533301500114bd6f7b630099191919299980b19b91488100002153330163371e9101000021003100513301a337606ea4008dd3000998030030019bab3017003375c602a0046032004602e00244a666028002298103d87a800013232323253330153372200e0042a66602a66e3c01c0084cdd2a4000660326e980052f5c02980103d87a80001330060060033756602c0066eb8c050008c060008c058004dd7180998081baa00337586024002601c6ea800858c040c044008c03c004c02cdd50008a4c26cac64a66601060060022a66601660146ea8010526161533300830020011533300b300a37540082930b0b18041baa003370e90011b8748000dd7000ab9a5573aaae7955cfaba05742ae89",hash:"0c0d17d9095fe6b07a2727403e2c6f2dff8042ed7c300cb67a2577a2"},{title:"oneshot.redeem",datum:{title:"_d",schema:{$ref:"#/definitions/Data"}},redeemer:{title:"_r",schema:{$ref:"#/definitions/Data"}},parameters:[{title:"token_name",schema:{$ref:"#/definitions/ByteArray"}},{title:"policy_id",schema:{$ref:"#/definitions/ByteArray"}}],compiledCode:"5901320100003232323232323223223222253330083232533300d3010002132533300b3370e6eb4c034009200113371e0020122940dd718058008b180700099299980499b8748008c028dd50008a5eb7bdb1804dd5980718059baa001323300100132330010013756601e602060206020602060186ea8c03cc030dd50019129998070008a5eb7bdb1804c8c8c8c94ccc03ccdc8a45000021533300f3371e91010000210031005133013337606ea4008dd3000998030030019bab3010003375c601c0046024004602000244a66601a002298103d87a8000132323232533300e337220140042a66601c66e3c0280084cdd2a4000660246e980052f5c02980103d87a80001330060060033756601e0066eb8c034008c044008c03c00452613656375c0026eb80055cd2ab9d5573caae7d5d02ba157441",hash:"39faa048196bb6b30f50815475e9d16b22e7a0ef6de5935b408ca617"}],definitions:{ByteArray:{dataType:"bytes"},Data:{title:"Data",description:"Any Plutus data."},Int:{dataType:"integer"},"aiken/transaction/OutputReference":{title:"OutputReference",description:"An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output",anyOf:[{title:"OutputReference",dataType:"constructor",index:0,fields:[{title:"transaction_id",$ref:"#/definitions/aiken~1transaction~1TransactionId"},{title:"output_index",$ref:"#/definitions/Int"}]}]},"aiken/transaction/TransactionId":{title:"TransactionId",description:"A unique transaction identifier, as the hash of a transaction body. Note that the transaction id\n isn't a direct hash of the `Transaction` as visible on-chain. Rather, they correspond to hash\n digests of transaction body as they are serialized on the network.",anyOf:[{title:"TransactionId",dataType:"constructor",index:0,fields:[{title:"hash",$ref:"#/definitions/ByteArray"}]}]},"oneshot/Action":{title:"Action",anyOf:[{title:"Mint",dataType:"constructor",index:0,fields:[]},{title:"Burn",dataType:"constructor",index:1,fields:[]}]}}};var f0=v,M=class extends m{tokenNameHex="";paramUtxo={outputIndex:0,txHash:""};giftCardCbor=(e,t,c)=>(0,N.applyParamsToScript)(v.validators[0].compiledCode,[(0,I.builtinByteString)(e),(0,I.txOutRef)(t,c)],"JSON");redeemCbor=(e,t)=>(0,N.applyParamsToScript)(v.validators[1].compiledCode,[e,t]);constructor(e,t,c){super(e),t&&(this.tokenNameHex=t),c&&(this.paramUtxo=c)}createGiftCard=async(e,t)=>{let{utxos:c,walletAddress:a,collateral:i}=await this.getWalletInfoForTx(),n=(0,I.stringToHex)(e),s=c[0];if(s===void 0)throw new Error("No UTXOs available");let d=c.slice(1),l=this.giftCardCbor(n,s.input.txHash,s.input.outputIndex),r=(0,C.resolveScriptHash)(l,"V2"),b={code:this.redeemCbor(n,r),version:"V2"},g=(0,C.serializePlutusScript)(b,void 0,this.networkId).address;return await this.mesh.txIn(s.input.txHash,s.input.outputIndex,s.output.amount,s.output.address).mintPlutusScriptV2().mint("1",r,n).mintingScript(l).mintRedeemerValue((0,I.mConStr0)([])).txOut(g,[...t,{unit:r+n,quantity:"1"}]).txOutInlineDatumValue([s.input.txHash,s.input.outputIndex,n]).changeAddress(a).txInCollateral(i.input.txHash,i.input.outputIndex,i.output.amount,i.output.address).selectUtxosFrom(d).complete(),this.tokenNameHex=n,this.paramUtxo=s.input,this.mesh.txHex};redeemGiftCard=async e=>{let{utxos:t,walletAddress:c,collateral:a}=await this.getWalletInfoForTx(),i=(0,C.deserializeDatum)(e.output.plutusData).list,n=i[0].bytes,s=i[1].int,d=i[2].bytes,l=this.giftCardCbor(d,n,s),r=(0,C.resolveScriptHash)(l,"V2"),b=this.redeemCbor(d,r);return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,e.output.address).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(b).mintPlutusScriptV2().mint("-1",r,d).mintingScript(l).mintRedeemerValue((0,I.mConStr1)([])).changeAddress(c).txInCollateral(a.input.txHash,a.input.outputIndex,a.output.amount,a.output.address).selectUtxosFrom(t).complete(),this.mesh.txHex};getUtxoByTxHash=async e=>{let{redeemScript:t}=this.getScripts();return await this._getUtxoByTxHash(t,e)};getScripts=()=>{let e=this.giftCardCbor(this.tokenNameHex,this.paramUtxo.txHash,this.paramUtxo.outputIndex),t=(0,C.resolveScriptHash)(e,"V2"),c=this.redeemCbor(this.tokenNameHex,t);return{giftCardScript:e,redeemScript:c}}};var $=require("@meshsdk/common"),h=require("@meshsdk/core"),X=require("@meshsdk/core-csl");var F={preamble:{title:"fabianbormann/payment-splitter",description:"Aiken contracts for project 'fabianbormann/payment-splitter'",version:"0.1.0",plutusVersion:"v2",compiler:{name:"Aiken",version:"v1.0.29-alpha+unknown"},license:"Apache-2.0"},validators:[{title:"payment_splitter.payout",datum:{title:"_datum",schema:{$ref:"#/definitions/payment_splitter~1Datum"}},redeemer:{title:"_redeemer",schema:{$ref:"#/definitions/payment_splitter~1Redeemer"}},parameters:[{title:"scriptHashes",schema:{$ref:"#/definitions/List$ByteArray"}}],compiledCode:"5903a5010000323232323232322322322322533300832323232323232323232323253330143375e6e9cccc8c0040048894ccc06800440084ccc00c00cc8c8cc004004010894ccc07400452f5c026464a66603866ebc00801440044cc080008cc010010004c084008c07c004c070004c074004cc8c004004894ccc06400452f5c026466036002660060066600e603a004466603066ebc00400928251301b001323300100100722533301900114bd7009980d1806180c1baa300c3018375460360026600400460380020169801018000100114a0646600200200444a66603000229444c94ccc058cdc39bad301b00233005533301900414c0103d87a80001300e3301a301b0044bd70240002660060060022940c06c004c8cc004004028894ccc05c00452f5c02660306ea0c8c8c8c8c8c94ccc068cdc424000002266e04008cdc08009802005880119980119804806919baf3010301c3754602060386ea8c014c070dd5000803240004466e00004c014dd59803180e9baa3006301d375400466600266010014466ebcc03cc06cdd51807980d9baa0010054800088cdc000098021bab3005301c3754004444646600200200844a66603e0022008266006604200266004004604400246600c64a66603066e1d200230193754002298103d87a8000132330010013756603c60366ea8008894ccc074004530103d87a8000132323232533301e33722911000021533301e3371e9101000021301633022375000297ae014c0103d87a8000133006006003375a603e0066eb8c074008c084008c07c004c8cc004004008894ccc0700045300103d87a8000132323232533301d33722911000021533301d3371e9101000021301533021374c00297ae014c0103d87a80001330060060033756603c0066eb8c070008c080008c07800520002301b301c001301900133002002301a0012253330133370e9001180a1baa00210011375a6030602a6ea800888c8cc00400400c894ccc05c00452f5c026464a66602c600a00426603400466008008002266008008002603600460320026eacc050c054008dd61809800980998098011bac3011001300d37546002601a6ea80108c040004c8cc004004020894ccc03800452f5c026601e60066601e602000297ae0330020023011001374a90000a4c26caca66600c66e1d20003007375400226464a666016601c0042930b1bae300c001300837540022ca66600866e1d20003005375400226464a66601260180042930b1bae300a001300637540022c6eb00055cd2ab9d5573caae7d5d02ba157441",hash:"0776032753d2900f7c1e933af4108c53851e10ca95fa10e34af90277"}],definitions:{ByteArray:{dataType:"bytes"},List$ByteArray:{dataType:"list",items:{$ref:"#/definitions/ByteArray"}},"payment_splitter/Datum":{title:"Datum",anyOf:[{title:"Datum",dataType:"constructor",index:0,fields:[{title:"owner",$ref:"#/definitions/ByteArray"}]}]},"payment_splitter/Redeemer":{title:"Redeemer",anyOf:[{title:"Redeemer",dataType:"constructor",index:0,fields:[{title:"message",$ref:"#/definitions/ByteArray"}]}]}}};var m0=F,W=class extends m{wrapPayees=e=>(0,$.list)(e.map(t=>(0,$.builtinByteString)((0,h.deserializeAddress)(t).pubKeyHash)));scriptCbor=()=>(0,X.applyParamsToScript)(F.validators[0].compiledCode,[this.wrapPayees(this.payees)],"JSON");payees=[];constructor(e,t){super(e),e.wallet?(e.wallet instanceof h.MeshWallet&&(this.payees=[e.wallet.getUsedAddresses()[0],...t]),e.wallet instanceof h.BrowserWallet&&e.wallet.getUsedAddresses().then(c=>{this.payees=[c[0],...t]})):(this.payees=t,console.warn("Wallet not provided. Therefore the payment address will not be added to the payees list which makes it impossible to trigger the payout."))}sendLovelaceToSplitter=async e=>{if(this.wallet===null||this.wallet===void 0)throw new Error("Wallet not provided");let{walletAddress:t}=await this.getWalletInfoForTx(),c={code:this.scriptCbor(),version:"V2"},{address:a}=(0,h.serializePlutusScript)(c,void 0,0),{pubKeyHash:i}=(0,h.deserializeAddress)(t),n={alternative:0,fields:[i]};return await new h.Transaction({initiator:this.wallet}).sendLovelace({address:a,datum:{value:n}},e.toString()).build()};triggerPayout=async()=>{if(this.wallet===null||this.wallet===void 0)throw new Error("Wallet not provided");let{walletAddress:e,collateral:t}=await this.getWalletInfoForTx(),c={code:this.scriptCbor(),version:"V2"},{address:a}=(0,h.serializePlutusScript)(c,void 0,0),i=await this.fetcher?.fetchAddressUTxOs(a)||[],{pubKeyHash:n}=(0,h.deserializeAddress)(e),s={alternative:0,fields:[n]},l={data:{alternative:0,fields:["Hello, World!"]}},r=new h.Transaction({initiator:this.wallet}),b=0;for(let w of i){let k=w.output?.amount;if(k){let q=k.find(Z=>Z.unit==="lovelace");q&&(b+=Math.floor(Number(q.quantity)/this.payees.length)),r=r.redeemValue({value:w,script:c,datum:s,redeemer:l})}}r=r.setCollateral([t]);for(let w of this.payees)r=r.sendLovelace(w,b.toString());return r=r.setRequiredSigners([e]),await r.build()}};var y=require("@meshsdk/common"),A=require("@meshsdk/core"),Y=require("@meshsdk/core-csl");var K={preamble:{title:"meshjs/swap",description:"Aiken contracts for project 'meshjs/swap'",version:"0.0.0",plutusVersion:"v2",compiler:{name:"Aiken",version:"v1.0.24-alpha+982eff4"},license:"Apache-2.0"},validators:[{title:"swap.swap",datum:{title:"datum",schema:{$ref:"#/definitions/swap~1SwapDatum"}},redeemer:{title:"redeemer",schema:{$ref:"#/definitions/swap~1SwapRedeemer"}},compiledCode:"59077601000032323232323232323222232325333008323232533300b3370e9001000899191919299980799b87480080084c94ccc040cdc3a4000601e0022646464646464646464646464a666038a6660380102002294040085281980299980200425eb7bdb180894ccc074cdd79807980d980a980d8010058998020009bab3015301b3015301b002100137566026603203066008664466600a00497adef6c6022533301e3375e6020603800400626600a0026eacc058c0700084004dd61802980c1806180c00a9806180c00b9bab30053018017223233300100100300222253330210021001132333004004302500333223233001001005225333026001133027337606ea4010dd3001a5eb7bdb1804c8c8c8c94ccc09ccdd799807804001260103d879800013302b337606ea4020dd30038028a99981399b8f0080021323253330293370e900000089981699bb03752014605c604e00400a200a604e00264a666050a66605600229445280a60103d87a800013374a9000198161ba60014bd70191998008008040011112999816801080089919980200218188019991191980080080291299981900089981999bb037520086ea000d2f5bded8c0264646464a66606666ebccc06c020009300103d8798000133037337606ea4020dd40038028a99981999b8f0080021323253330353370e900000089981c99bb037520146074606600400a200a606600264a66606866e1c005200014c103d87a800013374a90001981c1ba80014bd7019b80007001133037337606ea4008dd4000998030030019bad3034003375c6064004606c00460680026eb8c0b0004dd69816800981780109981599bb037520046e98004cc01801800cdd598140019bae3026002302a0023028001375c60400026eacc084004c08c008894ccc068cdc80010008a6103d87980001533301a3371e0040022980103d87a800014c103d87b8000222323300100100422533301f001100413300330210013300200230220012232323300100100222533301e00114a226464a66603a66e24dd698040011991191919299981119b8748008004520001375a604e6040004604000264a66604266e1d200200114c0103d87a8000132323300100100222533302700114c103d87a800013232323253330283371e014004266e9520003302c375000297ae0133006006003375a60520066eb8c09c008c0ac008c0a4004dd59813180f801180f80099198008008051129998120008a6103d87a800013232323253330253371e010004266e95200033029374c00297ae01330060060033756604c0066eb8c090008c0a0008c098004dd718078011bae301500213300400400114a060440046eb0c080004c8cc004004008894ccc07400452f5c0264666444646600200200644a66604600220062646604a6e9ccc094dd4803198129ba9375c60440026604a6ea0dd69811800a5eb80cc00c00cc09c008c094004dd7180e0009bab301d001330030033021002301f0012301b301c301c001533301700114a0264a6660300022944528180d00099191980080080111299980c8008a5eb804c8c94ccc060cdd79805180b1808180b00100309980e00119802002000899802002000980e801180d8009bac300530113005301100e30043010300a30100013016001300e0011632323300100100222533301500114c0103d87a80001323253330143375e600c6024004010266e952000330180024bd70099802002000980c801180b8009bac3001300d3001300d00a13232323300100100322533301600114a026464a66602a66e3c008014528899802002000980d0011bae3018001323253330123370e9000180880089bae30173010001163003300f0013002300e00d37586028602a602a602a602a602a602a602a602a601a6002601a014460280026018012602200260120042940c024004c004c01c0108c038c03c004526136563253330083370e90000008a99980598030020a4c2c2a66601066e1d20020011533300b300600414985858c01800cc8c8c94ccc024cdc3a40000022646464646464a666024602a0042646464931980500191919198068009191bad3018002375c602c0026eacc054008dd718098009980480211919198060009191bad3017002375c602a0026eacc050008dd7180900099299980819b87480000044c8c8c8c94ccc05cc0680084c8c9263253330163370e900000089919299980d980f00109924c64a66603266e1d200000113232533301e3021002132498c05400458c07c004c05c00854ccc064cdc3a40040022646464646464a666044604a0042930b1bad30230013023002375a604200260420046eb4c07c004c05c00858c05c00458c070004c05000c54ccc058cdc3a40040022a66603260280062930b0b180a00118070018b180c000980c001180b00098070030b18070028b1bab30130013013002375660220026022004601e002600e00c2c600e00a44646600200200644a66601c00229309919801801980900118019808000919299980419b87480000044c8c94ccc034c04000852616375c601c002600c0042a66601066e1d200200113232533300d3010002149858dd7180700098030010b1803000918029baa001230033754002ae6955ceaab9e5573eae815d0aba21",hash:"3f1869e426f5350c595ffd8ca4a6fba8186947ae0cd6c136fe23054a"}],definitions:{ByteArray:{dataType:"bytes"},Int:{dataType:"integer"},"Option$aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential":{title:"Optional",anyOf:[{title:"Some",description:"An optional value.",dataType:"constructor",index:0,fields:[{$ref:"#/definitions/aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"}]},{title:"None",description:"Nothing.",dataType:"constructor",index:1,fields:[]}]},"aiken/dict/Dict$ByteArray_Int":{title:"Dict",description:"An opaque `Dict`. The type is opaque because the module maintains some\n invariant, namely: there's only one occurrence of a given key in the dictionary.\n\n Note that the `key` parameter is a phantom-type, and only present as a\n means of documentation. Keys can be any type, yet will need to comparable\n to use functions like `insert`.\n\n See for example:\n\n ```aiken\n pub type Value =\n Dict<PolicyId, Dict<AssetName, Int>>\n ```",dataType:"map",keys:{$ref:"#/definitions/ByteArray"},values:{$ref:"#/definitions/Int"}},"aiken/transaction/credential/Address":{title:"Address",description:`A Cardano \`Address\` typically holding one or two credential references.
|
|
26
|
+
|
|
27
|
+
Note that legacy bootstrap addresses (a.k.a. 'Byron addresses') are
|
|
28
|
+
completely excluded from Plutus contexts. Thus, from an on-chain
|
|
29
|
+
perspective only exists addresses of type 00, 01, ..., 07 as detailed
|
|
30
|
+
in [CIP-0019 :: Shelley Addresses](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0019/#shelley-addresses).`,anyOf:[{title:"Address",dataType:"constructor",index:0,fields:[{title:"payment_credential",$ref:"#/definitions/aiken~1transaction~1credential~1Credential"},{title:"stake_credential",$ref:"#/definitions/Option$aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"}]}]},"aiken/transaction/credential/Credential":{title:"Credential",description:`A general structure for representing an on-chain \`Credential\`.
|
|
31
|
+
|
|
32
|
+
Credentials are always one of two kinds: a direct public/private key
|
|
33
|
+
pair, or a script (native or Plutus).`,anyOf:[{title:"VerificationKeyCredential",dataType:"constructor",index:0,fields:[{$ref:"#/definitions/ByteArray"}]},{title:"ScriptCredential",dataType:"constructor",index:1,fields:[{$ref:"#/definitions/ByteArray"}]}]},"aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential":{title:"Referenced",description:`Represent a type of object that can be represented either inline (by hash)
|
|
34
|
+
or via a reference (i.e. a pointer to an on-chain location).
|
|
35
|
+
|
|
36
|
+
This is mainly use for capturing pointers to a stake credential
|
|
37
|
+
registration certificate in the case of so-called pointer addresses.`,anyOf:[{title:"Inline",dataType:"constructor",index:0,fields:[{$ref:"#/definitions/aiken~1transaction~1credential~1Credential"}]},{title:"Pointer",dataType:"constructor",index:1,fields:[{title:"slot_number",$ref:"#/definitions/Int"},{title:"transaction_index",$ref:"#/definitions/Int"},{title:"certificate_index",$ref:"#/definitions/Int"}]}]},"aiken/transaction/value/Value":{title:"Value",description:"A multi-asset output `Value`. Contains tokens indexed by [PolicyId](#PolicyId) and [AssetName](#AssetName).\n\n This type maintain some invariants by construction; in particular, a `Value` will never contain a\n zero quantity of a particular token.",dataType:"map",keys:{$ref:"#/definitions/ByteArray"},values:{$ref:"#/definitions/aiken~1dict~1Dict$ByteArray_Int"}},"swap/SwapDatum":{title:"SwapDatum",anyOf:[{title:"SwapDatum",dataType:"constructor",index:0,fields:[{title:"initiator",$ref:"#/definitions/aiken~1transaction~1credential~1Address"},{title:"to_provide",$ref:"#/definitions/aiken~1transaction~1value~1Value"},{title:"to_receive",$ref:"#/definitions/aiken~1transaction~1value~1Value"}]}]},"swap/SwapRedeemer":{title:"SwapRedeemer",anyOf:[{title:"Cancel",dataType:"constructor",index:0,fields:[]},{title:"Swap",dataType:"constructor",index:1,fields:[]}]}}};var y0=K,j=class extends m{scriptCbor=(0,Y.applyParamsToScript)(K.validators[0].compiledCode,[]);scriptAddress;constructor(e){super(e),this.scriptAddress=(0,A.serializePlutusScript)({code:this.scriptCbor,version:"V2"},void 0,0).address}initiateSwap=async(e,t)=>{let{utxos:c,walletAddress:a,collateral:i}=await this.getWalletInfoForTx(),{pubKeyHash:n,stakeCredentialHash:s}=(0,A.deserializeAddress)(a),d=(0,y.conStr0)([(0,y.pubKeyAddress)(n,s),(0,y.value)(e),(0,y.value)(t)]);return await this.mesh.txOut(this.scriptAddress,e).txOutInlineDatumValue(d,"JSON").changeAddress(a).txInCollateral(i.input.txHash,i.input.outputIndex,i.output.amount,i.output.address).selectUtxosFrom(c).complete(),this.mesh.txHex};acceptSwap=async e=>{let{utxos:t,walletAddress:c,collateral:a}=await this.getWalletInfoForTx(),i=(0,A.deserializeDatum)(e.output.plutusData),n=(0,A.serializeAddressObj)(i.fields[0]),s=i.fields[2];return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,e.output.address).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue((0,y.mConStr1)([])).txInScript(this.scriptCbor).txOut(n,(0,y.parsePlutusValueToAssets)(s)).changeAddress(c).txInCollateral(a.input.txHash,a.input.outputIndex,a.output.amount,a.output.address).selectUtxosFrom(t).complete(),this.mesh.txHex};cancelSwap=async e=>{let{utxos:t,walletAddress:c,collateral:a}=await this.getWalletInfoForTx(),i=(0,A.deserializeDatum)(e.output.plutusData),n=(0,A.serializeAddressObj)(i.fields[0]);return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,e.output.address).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue((0,y.mConStr0)([])).txInScript(this.scriptCbor).changeAddress(c).txInCollateral(a.input.txHash,a.input.outputIndex,a.output.amount,a.output.address).requiredSignerHash((0,A.deserializeAddress)(n).pubKeyHash).selectUtxosFrom(t).complete(),this.mesh.txHex};getUtxoByTxHash=async e=>await this._getUtxoByTxHash(this.scriptCbor,e)};0&&(module.exports={MeshEscrowBlueprint,MeshEscrowContract,MeshGiftCardBlueprint,MeshGiftCardContract,MeshMarketplaceBlueprint,MeshMarketplaceContract,MeshPaymentSplitterBlueprint,MeshPaymentSplitterContract,MeshSwapBlueprint,MeshSwapContract,MeshVestingBlueprint,MeshVestingContract,activeEscrowDatum,initiateEscrowDatum,marketplaceDatum,recipientDepositRedeemer});
|