@meshsdk/contract 1.6.2 → 1.6.3

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.js CHANGED
@@ -1,37 +1,1832 @@
1
- import{conStr0 as i0,currencySymbol as n0,integer as _,mConStr0 as s0,mConStr1 as H,parseAssetUnit as r0,pubKeyAddress as M,tokenName as d0}from"@meshsdk/common";import{deserializeAddress as x,deserializeDatum as o0,serializeAddressObj as l0,serializePlutusScript as B}from"@meshsdk/core";import{applyParamsToScript as u0}from"@meshsdk/core-csl";import{v2ScriptToBech32 as a0}from"@meshsdk/core-csl";var p=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(e),a=c[0];if(t){let i=a0(t,void 0,this.networkId);a=c.filter(n=>n.output.address===i)[0]||c[0]}return a}}};var T={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.
1
+ // src/marketplace/offchain.ts
2
+ import {
3
+ conStr0,
4
+ currencySymbol,
5
+ integer,
6
+ mConStr0,
7
+ mConStr1,
8
+ parseAssetUnit,
9
+ pubKeyAddress,
10
+ tokenName
11
+ } from "@meshsdk/common";
12
+ import {
13
+ deserializeAddress,
14
+ deserializeDatum,
15
+ serializeAddressObj,
16
+ serializePlutusScript
17
+ } from "@meshsdk/core";
18
+ import { applyParamsToScript } from "@meshsdk/core-csl";
2
19
 
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\`.
20
+ // src/common.ts
21
+ import { v2ScriptToBech32 } from "@meshsdk/core-csl";
22
+ var MeshTxInitiator = class {
23
+ mesh;
24
+ fetcher;
25
+ wallet;
26
+ stakeCredential;
27
+ networkId = 0;
28
+ constructor({
29
+ mesh,
30
+ fetcher,
31
+ wallet,
32
+ networkId,
33
+ stakeCredential
34
+ }) {
35
+ this.mesh = mesh;
36
+ if (fetcher) {
37
+ this.fetcher = fetcher;
38
+ }
39
+ if (wallet) {
40
+ this.wallet = wallet;
41
+ }
42
+ if (networkId) {
43
+ this.networkId = networkId;
44
+ }
45
+ if (stakeCredential) {
46
+ this.stakeCredential = this.stakeCredential;
47
+ }
48
+ }
49
+ signSubmitReset = async () => {
50
+ const signedTx = this.mesh.completeSigning();
51
+ const txHash = await this.mesh.submitTx(signedTx);
52
+ this.mesh.reset();
53
+ return txHash;
54
+ };
55
+ queryUtxos = async (walletAddress) => {
56
+ if (this.fetcher) {
57
+ const utxos = await this.fetcher.fetchAddressUTxOs(walletAddress);
58
+ return utxos;
59
+ }
60
+ return [];
61
+ };
62
+ getWalletDappAddress = async () => {
63
+ if (this.wallet) {
64
+ const usedAddresses = await this.wallet.getUsedAddresses();
65
+ if (usedAddresses.length > 0) {
66
+ return usedAddresses[0];
67
+ }
68
+ const unusedAddresses = await this.wallet.getUnusedAddresses();
69
+ if (unusedAddresses.length > 0) {
70
+ return unusedAddresses[0];
71
+ }
72
+ }
73
+ return "";
74
+ };
75
+ getWalletCollateral = async () => {
76
+ if (this.wallet) {
77
+ const utxos = await this.wallet.getCollateral();
78
+ return utxos[0];
79
+ }
80
+ return void 0;
81
+ };
82
+ getWalletUtxosWithMinLovelace = async (lovelace, providedUtxos = []) => {
83
+ let utxos = providedUtxos;
84
+ if (this.wallet && (!providedUtxos || providedUtxos.length === 0)) {
85
+ utxos = await this.wallet.getUtxos();
86
+ }
87
+ return utxos.filter((u) => {
88
+ const lovelaceAmount = u.output.amount.find(
89
+ (a) => a.unit === "lovelace"
90
+ )?.quantity;
91
+ return Number(lovelaceAmount) > lovelace;
92
+ });
93
+ };
94
+ getWalletUtxosWithToken = async (assetHex, userUtxos = []) => {
95
+ let utxos = userUtxos;
96
+ if (this.wallet && userUtxos.length === 0) {
97
+ utxos = await this.wallet.getUtxos();
98
+ }
99
+ return utxos.filter((u) => {
100
+ const assetAmount = u.output.amount.find(
101
+ (a) => a.unit === assetHex
102
+ )?.quantity;
103
+ return Number(assetAmount) >= 1;
104
+ });
105
+ };
106
+ getAddressUtxosWithMinLovelace = async (walletAddress, lovelace, providedUtxos = []) => {
107
+ let utxos = providedUtxos;
108
+ if (this.fetcher && (!providedUtxos || providedUtxos.length === 0)) {
109
+ utxos = await this.fetcher.fetchAddressUTxOs(walletAddress);
110
+ }
111
+ return utxos.filter((u) => {
112
+ const lovelaceAmount = u.output.amount.find(
113
+ (a) => a.unit === "lovelace"
114
+ )?.quantity;
115
+ return Number(lovelaceAmount) > lovelace;
116
+ });
117
+ };
118
+ getAddressUtxosWithToken = async (walletAddress, assetHex, userUtxos = []) => {
119
+ let utxos = userUtxos;
120
+ if (this.fetcher && userUtxos.length === 0) {
121
+ utxos = await this.fetcher.fetchAddressUTxOs(walletAddress);
122
+ }
123
+ return utxos.filter((u) => {
124
+ const assetAmount = u.output.amount.find(
125
+ (a) => a.unit === assetHex
126
+ )?.quantity;
127
+ return Number(assetAmount) >= 1;
128
+ });
129
+ };
130
+ getWalletInfoForTx = async () => {
131
+ const utxos = await this.wallet?.getUtxos();
132
+ const collateral = await this.getWalletCollateral();
133
+ const walletAddress = await this.getWalletDappAddress();
134
+ if (!utxos || utxos?.length === 0) {
135
+ throw new Error("No utxos found");
136
+ }
137
+ if (!collateral) {
138
+ throw new Error("No collateral found");
139
+ }
140
+ if (!walletAddress) {
141
+ throw new Error("No wallet address found");
142
+ }
143
+ return { utxos, collateral, walletAddress };
144
+ };
145
+ _getUtxoByTxHash = async (txHash, scriptCbor) => {
146
+ if (this.fetcher) {
147
+ const utxos = await this.fetcher?.fetchUTxOs(txHash);
148
+ let scriptUtxo = utxos[0];
149
+ if (scriptCbor) {
150
+ const scriptAddr = v2ScriptToBech32(
151
+ scriptCbor,
152
+ void 0,
153
+ this.networkId
154
+ );
155
+ scriptUtxo = utxos.filter((utxo) => utxo.output.address === scriptAddr)[0] || utxos[0];
156
+ }
157
+ return scriptUtxo;
158
+ }
159
+ return void 0;
160
+ };
161
+ };
7
162
 
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).
163
+ // src/marketplace/aiken-workspace/plutus.json
164
+ var plutus_default = {
165
+ preamble: {
166
+ title: "meshjs/marketplace",
167
+ description: "Aiken contracts for project 'meshjs/marketplace'",
168
+ version: "0.0.0",
169
+ plutusVersion: "v2",
170
+ compiler: {
171
+ name: "Aiken",
172
+ version: "v1.0.29-alpha+unknown"
173
+ },
174
+ license: "Apache-2.0"
175
+ },
176
+ validators: [
177
+ {
178
+ title: "marketplace.marketplace",
179
+ datum: {
180
+ title: "datum",
181
+ schema: {
182
+ $ref: "#/definitions/marketplace~1types~1MarketplaceDatum"
183
+ }
184
+ },
185
+ redeemer: {
186
+ title: "redeemer",
187
+ schema: {
188
+ $ref: "#/definitions/marketplace~1types~1MarketplaceRedeemer"
189
+ }
190
+ },
191
+ parameters: [
192
+ {
193
+ title: "owner",
194
+ schema: {
195
+ $ref: "#/definitions/aiken~1transaction~1credential~1Address"
196
+ }
197
+ },
198
+ {
199
+ title: "fee_percentage_basis_point",
200
+ schema: {
201
+ $ref: "#/definitions/Int"
202
+ }
203
+ }
204
+ ],
205
+ compiledCode: "59082f01000032323232323232223223232322322533300b3232533300d3007300e375400226464a64666020601660226ea80204c94ccc044c030c048dd500089919191919191919299980c99299980e8008a501533301d302000114a22940cc88c8cc00400400c894ccc08000452f5c026464a66603e66ebcc044c084dd5180a18109baa00200513302300233004004001133004004001302400230220013758601660366ea8c02cc06cdd50079805980d9baa300e301b37540102a6660320022004294052819801998011bac3004301a3754601460346ea803805cc018cdc199b82375a601a60346ea805005520a09c0133002330013758600660326ea8c024c064dd50069804980c9baa0133005337006eb4c030c064dd50099998021bab300c30193754601860326ea801922010048810022323300100100322533301d00114bd6f7b63009991299980e19baf300e301e375400400a2646660020020046eacc048c07cdd50019112999811001080089919980200218130019991191980080080291299981380089981419bb037520086e9800d2f5bded8c0264646464a66605066e400200084cc0b0cdd81ba9008374c00e00a2a66605066e3c0200084c94ccc0a4c090c0a8dd500089981699bb03752012605c60566ea80040104010c94ccc0a54ccc0b00045288a5014c0103d87a80001301a3302d374c00297ae032333001001008002222533302e0021001132333004004303200333223233001001005225333033001133034337606ea4010dd4001a5eb7bdb1804c8c8c8c94ccc0d0cdc800400109981c19bb037520106ea001c01454ccc0d0cdc7804001099299981a9818181b1baa001133039337606ea4024c0e8c0dcdd5000802080219299981a98180008a60103d87a80001302633039375000297ae03370000e00226607066ec0dd48011ba800133006006003375a606a0066eb8c0cc008c0dc008c0d4004dd718168009bad302e001303000213302c337606ea4008dd3000998030030019bab3029003375c604e004605600460520026eb8c084004dd5981100098120010800980f800998010011810000911919800800991980080080191299980e8008a5eb804c8ccc888c8cc00400400c894ccc08c004400c4c8cc094dd3998129ba90063302530220013302530230014bd7019801801981380118128009bae301c0013756603a002660060066042004603e00244a66603800229444c94ccc068c8cdc49bad3007001333008006375c601a0026eb8c040004dd6180f8010998018018008a50301f0012301a301b301b0012223253330173011301837540022900009bad301c3019375400264a66602e602260306ea8004530103d87a8000132330010013756603a60346ea8008894ccc070004530103d87a8000132323232533301d337220100042a66603a66e3c0200084c038cc084dd4000a5eb80530103d87a8000133006006003375a603c0066eb8c070008c080008c078004c8cc004004010894ccc06c0045300103d87a8000132323232533301c337220100042a66603866e3c0200084c034cc080dd3000a5eb80530103d87a80001330060060033756603a0066eb8c06c008c07c008c07400494ccc04cc03800452f5bded8c0264646600200297adef6c6022533301900113301a337609801014000374c00697adef6c60132323232533301a3372091010000213301e337609801014000374c00e00a2a66603466e3d2210000213301e337609801014000374c00e00626603c66ec0dd48011ba600133006006003375660360066eb8c064008c074008c06c004c8cc0040052f5bded8c044a66603000226603266ec13001014000375000697adef6c6013232323253330193372091010000213301d337609801014000375000e00a2a66603266e3d2210000213301d337609801014000375000e00626603a66ec0dd48011ba800133006006003375a60340066eb8c060008c070008c068004c058c04cdd50008b19198008009bac300330133754600660266ea801c894ccc054004530103d87a80001323253330143375e600c602c6ea800801c4c014cc0600092f5c02660080080026032004602e002264a666022601860246ea80044cc88c8cc00400400c894ccc060004528099299980b19b8f375c603600400829444cc00c00c004c06c004dd6180b180b980b980b980b980b980b980b980b98099baa30033013375400e6eb8c058c04cdd50008b192999808980618091baa001130023301530163013375400297ae014c0103d87a8000300230123754600460246ea8030dd2a4000460280026024601e6ea8004528180098071baa00223011301200114984d958c94ccc028c01400454ccc034c030dd50010a4c2c2a66601460080022a66601a60186ea80085261616300a375400264a666010600660126ea80104c8c8c8c8c8c8c8c94ccc04cc0580084c9265333010300b3011375400e264646464a66602e6034004264649319299980b180880089919299980d980f00109924c64a666032602800226464a66603c604200426493180a0008b180f800980d9baa002153330193013001132323232323253330223025002149858dd6981180098118011bad30210013021002375a603e00260366ea800858c064dd50008b180e000980c1baa00315333016301000115333019301837540062930b0b180b1baa002300d003163018001301800230160013012375400e2c2c6eb8c050004c050008dd7180900098090011bad30100013010002300e001300a37540082c464a666012600800226464a66601c60220042930b1bae300f001300b37540042a666012600600226464a66601c60220042930b1bae300f001300b37540042c60126ea8004dc3a40046e1d2000375a002ae6955ceaab9e5573eae815d0aba21",
206
+ hash: "96dbc09c69d812e157d42967587c459b60f5dd21b1902312045586c4"
207
+ }
208
+ ],
209
+ definitions: {
210
+ ByteArray: {
211
+ dataType: "bytes"
212
+ },
213
+ Int: {
214
+ dataType: "integer"
215
+ },
216
+ "Option$aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential": {
217
+ title: "Optional",
218
+ anyOf: [
219
+ {
220
+ title: "Some",
221
+ description: "An optional value.",
222
+ dataType: "constructor",
223
+ index: 0,
224
+ fields: [
225
+ {
226
+ $ref: "#/definitions/aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"
227
+ }
228
+ ]
229
+ },
230
+ {
231
+ title: "None",
232
+ description: "Nothing.",
233
+ dataType: "constructor",
234
+ index: 1,
235
+ fields: []
236
+ }
237
+ ]
238
+ },
239
+ "aiken/transaction/credential/Address": {
240
+ title: "Address",
241
+ description: "A Cardano `Address` typically holding one or two credential references.\n\n Note that legacy bootstrap addresses (a.k.a. 'Byron addresses') are\n completely excluded from Plutus contexts. Thus, from an on-chain\n perspective only exists addresses of type 00, 01, ..., 07 as detailed\n in [CIP-0019 :: Shelley Addresses](https://cips.cardano.org/cip/CIP-19).",
242
+ anyOf: [
243
+ {
244
+ title: "Address",
245
+ dataType: "constructor",
246
+ index: 0,
247
+ fields: [
248
+ {
249
+ title: "payment_credential",
250
+ $ref: "#/definitions/aiken~1transaction~1credential~1Credential"
251
+ },
252
+ {
253
+ title: "stake_credential",
254
+ $ref: "#/definitions/Option$aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"
255
+ }
256
+ ]
257
+ }
258
+ ]
259
+ },
260
+ "aiken/transaction/credential/Credential": {
261
+ title: "Credential",
262
+ description: "A general structure for representing an on-chain `Credential`.\n\n Credentials are always one of two kinds: a direct public/private key\n pair, or a script (native or Plutus).",
263
+ anyOf: [
264
+ {
265
+ title: "VerificationKeyCredential",
266
+ dataType: "constructor",
267
+ index: 0,
268
+ fields: [
269
+ {
270
+ $ref: "#/definitions/ByteArray"
271
+ }
272
+ ]
273
+ },
274
+ {
275
+ title: "ScriptCredential",
276
+ dataType: "constructor",
277
+ index: 1,
278
+ fields: [
279
+ {
280
+ $ref: "#/definitions/ByteArray"
281
+ }
282
+ ]
283
+ }
284
+ ]
285
+ },
286
+ "aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential": {
287
+ title: "Referenced",
288
+ description: "Represent a type of object that can be represented either inline (by hash)\n or via a reference (i.e. a pointer to an on-chain location).\n\n This is mainly use for capturing pointers to a stake credential\n registration certificate in the case of so-called pointer addresses.",
289
+ anyOf: [
290
+ {
291
+ title: "Inline",
292
+ dataType: "constructor",
293
+ index: 0,
294
+ fields: [
295
+ {
296
+ $ref: "#/definitions/aiken~1transaction~1credential~1Credential"
297
+ }
298
+ ]
299
+ },
300
+ {
301
+ title: "Pointer",
302
+ dataType: "constructor",
303
+ index: 1,
304
+ fields: [
305
+ {
306
+ title: "slot_number",
307
+ $ref: "#/definitions/Int"
308
+ },
309
+ {
310
+ title: "transaction_index",
311
+ $ref: "#/definitions/Int"
312
+ },
313
+ {
314
+ title: "certificate_index",
315
+ $ref: "#/definitions/Int"
316
+ }
317
+ ]
318
+ }
319
+ ]
320
+ },
321
+ "marketplace/types/MarketplaceDatum": {
322
+ title: "MarketplaceDatum",
323
+ anyOf: [
324
+ {
325
+ title: "MarketplaceDatum",
326
+ dataType: "constructor",
327
+ index: 0,
328
+ fields: [
329
+ {
330
+ title: "seller",
331
+ $ref: "#/definitions/aiken~1transaction~1credential~1Address"
332
+ },
333
+ {
334
+ title: "price",
335
+ $ref: "#/definitions/Int"
336
+ },
337
+ {
338
+ title: "policy",
339
+ $ref: "#/definitions/ByteArray"
340
+ },
341
+ {
342
+ title: "tokenName",
343
+ $ref: "#/definitions/ByteArray"
344
+ }
345
+ ]
346
+ }
347
+ ]
348
+ },
349
+ "marketplace/types/MarketplaceRedeemer": {
350
+ title: "MarketplaceRedeemer",
351
+ anyOf: [
352
+ {
353
+ title: "Buy",
354
+ dataType: "constructor",
355
+ index: 0,
356
+ fields: []
357
+ },
358
+ {
359
+ title: "Close",
360
+ dataType: "constructor",
361
+ index: 1,
362
+ fields: []
363
+ }
364
+ ]
365
+ }
366
+ }
367
+ };
11
368
 
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 ue=T,R=(u,e,t)=>{let{pubKeyHash:c,stakeCredentialHash:a}=x(u),{policyId:i,assetName:n}=r0(t);return i0([M(c,a),_(e),n0(i),d0(n)])},V=class extends p{ownerAddress;feePercentageBasisPoint;scriptCbor;constructor(e,t,c){super(e),this.ownerAddress=t,this.feePercentageBasisPoint=c;let{pubKeyHash:a,stakeCredentialHash:i}=x(t);this.scriptCbor=u0(T.validators[0].compiledCode,[M(a,i),_(c)],"JSON")}listAsset=async(e,t)=>{let{utxos:c,walletAddress:a}=await this.getWalletInfoForTx();new Map().set(e,"1");let{address:n}=B({code:this.scriptCbor,version:"V2"},void 0,this.networkId),s=[{unit:e,quantity:"1"}],d=R(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(H([])).txInScript(this.scriptCbor).changeAddress(c).requiredSignerHash(x(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=o0(e.output.plutusData),n=i.fields[1].int.toString(),s=e.output.amount.find(l=>l.unit==="lovelace").quantity,d=this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,e.output.address).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(s0([])).txInScript(this.scriptCbor).changeAddress(c).txInCollateral(a.input.txHash,a.input.outputIndex,a.output.amount,a.output.address).selectUtxosFrom(t),o=i.fields[1].int*this.feePercentageBasisPoint/1e4;if(this.feePercentageBasisPoint>0&&o<1e6&&(o=1e6),o>0){let l=this.ownerAddress,f=[{unit:"lovelace",quantity:Math.ceil(o).toString()}];d.txOut(l,f)}let r=i.fields[1].int+Number(s);if(r>0){let l=l0(i.fields[0]),f=[{unit:"lovelace",quantity:r.toString()}];d.txOut(l,f)}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=R(a,t,n),{address:o}=B({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(H([])).txInScript(this.scriptCbor).txOut(o,s).txOutInlineDatumValue(d,"JSON").changeAddress(a).requiredSignerHash(x(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(e,this.scriptCbor)};import{mConStr0 as f0,SLOT_CONFIG_NETWORK as N,unixTimeToEnclosingSlot as b0}from"@meshsdk/common";import{deserializeAddress as C,deserializeDatum as m0,serializePlutusScript as U}from"@meshsdk/core";import{applyParamsToScript as h0}from"@meshsdk/core-csl";var w={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 ve=w,F=class extends p{scriptCbor=h0(w.validators[0].compiledCode,[]);constructor(e){super(e)}depositFund=async(e,t,c)=>{let{utxos:a,walletAddress:i}=await this.getWalletInfoForTx(),n=U({code:this.scriptCbor,version:"V2"},void 0,0).address,{pubKeyHash:s}=C(i),{pubKeyHash:d}=C(c);return await this.mesh.txOut(n,e).txOutInlineDatumValue(f0([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=U({code:this.scriptCbor,version:"V2"},void 0,0).address,{pubKeyHash:d}=C(c),o=m0(e.output.plutusData),r=b0(Math.min(o.fields[0].int,Date.now()-15e3),this.networkId===0?N.preprod:N.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(e,this.scriptCbor)};import{conStr0 as x0,conStr1 as g0,mConStr1 as A0,mConStr2 as I0,pubKeyAddress as K,value as j,MeshValue as h}from"@meshsdk/common";import{deserializeAddress as y,deserializeDatum as S,mergeAssets as T0,serializeAddressObj as g,serializePlutusScript as A}from"@meshsdk/core";import{applyParamsToScript as w0}from"@meshsdk/core-csl";var k={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.
369
+ // src/marketplace/offchain.ts
370
+ var MeshMarketplaceBlueprint = plutus_default;
371
+ var marketplaceDatum = (sellerAddress, lovelaceFee, assetHex) => {
372
+ const { pubKeyHash, stakeCredentialHash } = deserializeAddress(sellerAddress);
373
+ const { policyId, assetName } = parseAssetUnit(assetHex);
374
+ return conStr0([
375
+ pubKeyAddress(pubKeyHash, stakeCredentialHash),
376
+ integer(lovelaceFee),
377
+ currencySymbol(policyId),
378
+ tokenName(assetName)
379
+ ]);
380
+ };
381
+ var MeshMarketplaceContract = class extends MeshTxInitiator {
382
+ ownerAddress;
383
+ feePercentageBasisPoint;
384
+ scriptCbor;
385
+ constructor(inputs, ownerAddress, feePercentageBasisPoint) {
386
+ super(inputs);
387
+ this.ownerAddress = ownerAddress;
388
+ this.feePercentageBasisPoint = feePercentageBasisPoint;
389
+ const { pubKeyHash, stakeCredentialHash } = deserializeAddress(ownerAddress);
390
+ this.scriptCbor = applyParamsToScript(
391
+ plutus_default.validators[0].compiledCode,
392
+ [
393
+ pubKeyAddress(pubKeyHash, stakeCredentialHash),
394
+ integer(feePercentageBasisPoint)
395
+ ],
396
+ "JSON"
397
+ );
398
+ }
399
+ listAsset = async (asset, price) => {
400
+ const { utxos, walletAddress } = await this.getWalletInfoForTx();
401
+ const assetMap = /* @__PURE__ */ new Map();
402
+ assetMap.set(asset, "1");
403
+ const { address: scriptAddr } = serializePlutusScript(
404
+ { code: this.scriptCbor, version: "V2" },
405
+ void 0,
406
+ this.networkId
407
+ );
408
+ const tokenForSale = [{ unit: asset, quantity: "1" }];
409
+ const outputDatum = marketplaceDatum(walletAddress, price, asset);
410
+ await this.mesh.txOut(scriptAddr, tokenForSale).txOutInlineDatumValue(outputDatum, "JSON").changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
411
+ return this.mesh.txHex;
412
+ };
413
+ delistAsset = async (marketplaceUtxo) => {
414
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
415
+ await this.mesh.spendingPlutusScriptV2().txIn(
416
+ marketplaceUtxo.input.txHash,
417
+ marketplaceUtxo.input.outputIndex,
418
+ marketplaceUtxo.output.amount,
419
+ marketplaceUtxo.output.address
420
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr1([])).txInScript(this.scriptCbor).changeAddress(walletAddress).requiredSignerHash(deserializeAddress(walletAddress).pubKeyHash).txInCollateral(
421
+ collateral.input.txHash,
422
+ collateral.input.outputIndex,
423
+ collateral.output.amount,
424
+ collateral.output.address
425
+ ).selectUtxosFrom(utxos).complete();
426
+ return this.mesh.txHex;
427
+ };
428
+ purchaseAsset = async (marketplaceUtxo) => {
429
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
430
+ const inputDatum = deserializeDatum(
431
+ marketplaceUtxo.output.plutusData
432
+ );
433
+ const inputLovelace = marketplaceUtxo.output.amount.find(
434
+ (a) => a.unit === "lovelace"
435
+ ).quantity;
436
+ const tx = this.mesh.spendingPlutusScriptV2().txIn(
437
+ marketplaceUtxo.input.txHash,
438
+ marketplaceUtxo.input.outputIndex,
439
+ marketplaceUtxo.output.amount,
440
+ marketplaceUtxo.output.address
441
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr0([])).txInScript(this.scriptCbor).changeAddress(walletAddress).txInCollateral(
442
+ collateral.input.txHash,
443
+ collateral.input.outputIndex,
444
+ collateral.output.amount,
445
+ collateral.output.address
446
+ ).selectUtxosFrom(utxos);
447
+ let ownerToReceiveLovelace = inputDatum.fields[1].int * this.feePercentageBasisPoint / 1e4;
448
+ if (this.feePercentageBasisPoint > 0 && ownerToReceiveLovelace < 1e6) {
449
+ ownerToReceiveLovelace = 1e6;
450
+ }
451
+ if (ownerToReceiveLovelace > 0) {
452
+ const ownerAddress = this.ownerAddress;
453
+ const ownerToReceive = [
454
+ {
455
+ unit: "lovelace",
456
+ quantity: Math.ceil(ownerToReceiveLovelace).toString()
457
+ }
458
+ ];
459
+ tx.txOut(ownerAddress, ownerToReceive);
460
+ }
461
+ const sellerToReceiveLovelace = inputDatum.fields[1].int + Number(inputLovelace);
462
+ if (sellerToReceiveLovelace > 0) {
463
+ const sellerAddress = serializeAddressObj(inputDatum.fields[0]);
464
+ const sellerToReceive = [
465
+ {
466
+ unit: "lovelace",
467
+ quantity: sellerToReceiveLovelace.toString()
468
+ }
469
+ ];
470
+ tx.txOut(sellerAddress, sellerToReceive);
471
+ }
472
+ await tx.complete();
473
+ return this.mesh.txHex;
474
+ };
475
+ relistAsset = async (marketplaceUtxo, newPrice) => {
476
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
477
+ const inputAsset = marketplaceUtxo.output.amount.find(
478
+ (a) => a.unit !== "lovelace"
479
+ ).unit;
480
+ const tokenForSale = [{ unit: inputAsset, quantity: "1" }];
481
+ const outputDatum = marketplaceDatum(walletAddress, newPrice, inputAsset);
482
+ const { address: scriptAddr } = serializePlutusScript(
483
+ { code: this.scriptCbor, version: "V2" },
484
+ void 0,
485
+ this.networkId
486
+ );
487
+ await this.mesh.spendingPlutusScriptV2().txIn(
488
+ marketplaceUtxo.input.txHash,
489
+ marketplaceUtxo.input.outputIndex,
490
+ marketplaceUtxo.output.amount,
491
+ marketplaceUtxo.output.address
492
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr1([])).txInScript(this.scriptCbor).txOut(scriptAddr, tokenForSale).txOutInlineDatumValue(outputDatum, "JSON").changeAddress(walletAddress).requiredSignerHash(deserializeAddress(walletAddress).pubKeyHash).txInCollateral(
493
+ collateral.input.txHash,
494
+ collateral.input.outputIndex,
495
+ collateral.output.amount,
496
+ collateral.output.address
497
+ ).selectUtxosFrom(utxos).complete();
498
+ return this.mesh.txHex;
499
+ };
500
+ getUtxoByTxHash = async (txHash) => {
501
+ return await this._getUtxoByTxHash(txHash, this.scriptCbor);
502
+ };
503
+ };
14
504
 
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\`.
505
+ // src/vesting/offchain.ts
506
+ import {
507
+ mConStr0 as mConStr02,
508
+ SLOT_CONFIG_NETWORK,
509
+ unixTimeToEnclosingSlot
510
+ } from "@meshsdk/common";
511
+ import {
512
+ deserializeAddress as deserializeAddress2,
513
+ deserializeDatum as deserializeDatum2,
514
+ serializePlutusScript as serializePlutusScript2
515
+ } from "@meshsdk/core";
516
+ import { applyParamsToScript as applyParamsToScript2 } from "@meshsdk/core-csl";
19
517
 
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).
518
+ // src/vesting/aiken-workspace/plutus.json
519
+ var plutus_default2 = {
520
+ preamble: {
521
+ title: "meshjs/vesting",
522
+ description: "Aiken contracts for project 'meshjs/vesting'",
523
+ version: "0.0.0",
524
+ plutusVersion: "v2",
525
+ compiler: {
526
+ name: "Aiken",
527
+ version: "v1.0.29-alpha+unknown"
528
+ },
529
+ license: "Apache-2.0"
530
+ },
531
+ validators: [
532
+ {
533
+ title: "vesting.vesting",
534
+ datum: {
535
+ title: "datum",
536
+ schema: {
537
+ $ref: "#/definitions/vesting~1types~1VestingDatum"
538
+ }
539
+ },
540
+ redeemer: {
541
+ title: "_redeemer",
542
+ schema: {
543
+ $ref: "#/definitions/Data"
544
+ }
545
+ },
546
+ compiledCode: "5901c40100003232323232323223222533300532533233007300130083754600460126ea800c4c8c8c94ccc028cc004dd6180118061baa3003300c375400c6eb8c014c030dd50048a511533300a330013758600460186ea8c00cc030dd50031bae300f30103010300c3754012266446464646464a666022601660246ea80084c94ccc0480104cdc40038008011bad301630133754004002264a666022601660246ea80084c94ccc0480100084cdc48038009bad3016301337540040022940c050008cdc424000601e6ea8c04cc050004cc044c048004cc044ccc034cdc424000601c6ea8c048c04c00530103d87a80004c0103d87980004bd7018071baa3005300e3754004601e602060206020602060206020602060186ea8c00cc030dd50031bad3003300c3754012294088c8cc00400400c894ccc040004528099299980719b8f375c602600400829444cc00c00c004c04c0048c038c03cc03cc03cc03cc03cc03cc03cc03c0048c034004dc3a400429408c02cc0300045261365653330023370e900018019baa0011323232323232533300b300e002149858dd7180600098060011bae300a001300a002375a601000260086ea8004595cd2ab9d5573caae7d5d02ba157441",
547
+ hash: "ac96a3fa3cabf670268a88720402c715ed5fd73ffb3276e6092ead00"
548
+ }
549
+ ],
550
+ definitions: {
551
+ ByteArray: {
552
+ dataType: "bytes"
553
+ },
554
+ Data: {
555
+ title: "Data",
556
+ description: "Any Plutus data."
557
+ },
558
+ Int: {
559
+ dataType: "integer"
560
+ },
561
+ "vesting/types/VestingDatum": {
562
+ title: "VestingDatum",
563
+ anyOf: [
564
+ {
565
+ title: "VestingDatum",
566
+ dataType: "constructor",
567
+ index: 0,
568
+ fields: [
569
+ {
570
+ title: "lock_until",
571
+ description: "POSIX time in second, e.g. 1672843961000",
572
+ $ref: "#/definitions/Int"
573
+ },
574
+ {
575
+ title: "owner",
576
+ description: "Owner's credentials",
577
+ $ref: "#/definitions/ByteArray"
578
+ },
579
+ {
580
+ title: "beneficiary",
581
+ description: "Beneficiary's credentials",
582
+ $ref: "#/definitions/ByteArray"
583
+ }
584
+ ]
585
+ }
586
+ ]
587
+ }
588
+ }
589
+ };
23
590
 
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 qe=k,q=(u,e)=>{let{pubKeyHash:t,stakeCredentialHash:c}=y(u);return x0([K(t,c),j(e)])},C0=(u,e,t)=>{let{pubKeyHash:c,stakeCredentialHash:a}=y(e),[i,n]=u.fields;return g0([i,n,K(c,a),j(t)])},k0=(u,e)=>q(u,e),W=class extends p{scriptCbor=w0(k.validators[0].compiledCode,[]);constructor(e){super(e)}initiateEscrow=async e=>{let{utxos:t,walletAddress:c}=await this.getWalletInfoForTx(),{address:a}=A({code:this.scriptCbor,version:"V2"},void 0,this.networkId);return await this.mesh.txOut(a,e).txOutInlineDatumValue(q(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}=A({code:this.scriptCbor,version:"V2"},void 0,this.networkId),n=S(e.output.plutusData);if(n.constructor===1){let[s,d,o,r]=n.fields,l=g(s),f=g(o),b=h.fromValue(d).toAssets(),m=h.fromValue(r).toAssets();this.mesh.txOut(l,b).txOut(f,m)}return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,i).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(A0([])).txInScript(this.scriptCbor).requiredSignerHash(y(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}=A({code:this.scriptCbor,version:"V2"},void 0,this.networkId),s=S(e.output.plutusData),d=C0(s,a,t),o=h.fromValue(s.fields[1]).toAssets(),r=T0([...t,...o]);return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,n).spendingReferenceTxInInlineDatumPresent().txInRedeemerValue(k0(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}=A({code:this.scriptCbor,version:"V2"},void 0,this.networkId),n=S(e.output.plutusData),[s,d,o,r]=n.fields,l=g(s),f=g(o),b=h.fromValue(r).toAssets(),m=h.fromValue(d).toAssets();return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,i).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(I0([])).txInScript(this.scriptCbor).txOut(l,b).txOut(f,m).requiredSignerHash(y(f).pubKeyHash).requiredSignerHash(y(l).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(e,this.scriptCbor)};import{builtinByteString as v0,mConStr0 as $0,mConStr1 as O0,stringToHex as P0,txOutRef as D0}from"@meshsdk/common";import{deserializeDatum as H0,resolveScriptHash as v,serializePlutusScript as B0}from"@meshsdk/core";import{applyParamsToScript as L}from"@meshsdk/core-csl";var I={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 rt=I,E=class extends p{tokenNameHex="";paramUtxo={outputIndex:0,txHash:""};giftCardCbor=(e,t,c)=>L(I.validators[0].compiledCode,[v0(e),D0(t,c)],"JSON");redeemCbor=(e,t)=>L(I.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=P0(e),s=c[0];if(s===void 0)throw new Error("No UTXOs available");let d=c.slice(1),o=this.giftCardCbor(n,s.input.txHash,s.input.outputIndex),r=v(o,"V2"),l={code:this.redeemCbor(n,r),version:"V2"},f=B0(l,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(o).mintRedeemerValue($0([])).txOut(f,[...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=H0(e.output.plutusData).list,n=i[0].bytes,s=i[1].int,d=i[2].bytes,o=this.giftCardCbor(d,n,s),r=v(o,"V2"),l=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(l).mintPlutusScriptV2().mint("-1",r,d).mintingScript(o).mintRedeemerValue(O0([])).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(e);getScripts=()=>{let e=this.giftCardCbor(this.tokenNameHex,this.paramUtxo.txHash,this.paramUtxo.outputIndex),t=v(e,"V2"),c=this.redeemCbor(this.tokenNameHex,t);return{giftCardScript:e,redeemScript:c}}};import{builtinByteString as V0,list as _0}from"@meshsdk/common";import{BrowserWallet as M0,deserializeAddress as O,MeshWallet as N0,serializePlutusScript as z,Transaction as J}from"@meshsdk/core";import{applyParamsToScript as U0}from"@meshsdk/core-csl";var $={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 gt=$,G=class extends p{wrapPayees=e=>_0(e.map(t=>V0(O(t).pubKeyHash)));scriptCbor=()=>U0($.validators[0].compiledCode,[this.wrapPayees(this.payees)],"JSON");payees=[];constructor(e,t){super(e),e.wallet?(e.wallet instanceof N0&&(this.payees=[e.wallet.getUsedAddresses()[0],...t]),e.wallet instanceof M0&&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}=z(c,void 0,0),{pubKeyHash:i}=O(t),n={alternative:0,fields:[i]};return await new J({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}=z(c,void 0,0),i=await this.fetcher?.fetchAddressUTxOs(a)||[],{pubKeyHash:n}=O(e),s={alternative:0,fields:[n]},o={data:{alternative:0,fields:["Hello, World!"]}},r=new J({initiator:this.wallet}),l=0;for(let b of i){let m=b.output?.amount;if(m){let D=m.find(t0=>t0.unit==="lovelace");D&&(l+=Math.floor(Number(D.quantity)/this.payees.length)),r=r.redeemValue({value:b,script:c,datum:s,redeemer:o})}}r=r.setCollateral([t]);for(let b of this.payees)r=r.sendLovelace(b,l.toString());return r=r.setRequiredSigners([e]),await r.build()}};import{conStr0 as W0,mConStr0 as K0,mConStr1 as j0,pubKeyAddress as q0,value as Q,MeshValue as L0}from"@meshsdk/common";import{deserializeAddress as X,deserializeDatum as Y,serializeAddressObj as Z,serializePlutusScript as E0}from"@meshsdk/core";import{applyParamsToScript as z0}from"@meshsdk/core-csl";var P={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.
591
+ // src/vesting/offchain.ts
592
+ var MeshVestingBlueprint = plutus_default2;
593
+ var MeshVestingContract = class extends MeshTxInitiator {
594
+ scriptCbor = applyParamsToScript2(plutus_default2.validators[0].compiledCode, []);
595
+ constructor(inputs) {
596
+ super(inputs);
597
+ }
598
+ depositFund = async (amount, lockUntilTimeStampMs, beneficiary) => {
599
+ const { utxos, walletAddress } = await this.getWalletInfoForTx();
600
+ const scriptAddr = serializePlutusScript2(
601
+ { code: this.scriptCbor, version: "V2" },
602
+ void 0,
603
+ 0
604
+ ).address;
605
+ const { pubKeyHash: ownerPubKeyHash } = deserializeAddress2(walletAddress);
606
+ const { pubKeyHash: beneficiaryPubKeyHash } = deserializeAddress2(beneficiary);
607
+ await this.mesh.txOut(scriptAddr, amount).txOutInlineDatumValue(
608
+ mConStr02([
609
+ lockUntilTimeStampMs,
610
+ ownerPubKeyHash,
611
+ beneficiaryPubKeyHash
612
+ ])
613
+ ).changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
614
+ return this.mesh.txHex;
615
+ };
616
+ withdrawFund = async (vestingUtxo) => {
617
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
618
+ const { input: collateralInput, output: collateralOutput } = collateral;
619
+ const scriptAddr = serializePlutusScript2(
620
+ { code: this.scriptCbor, version: "V2" },
621
+ void 0,
622
+ 0
623
+ ).address;
624
+ const { pubKeyHash } = deserializeAddress2(walletAddress);
625
+ const datum = deserializeDatum2(
626
+ vestingUtxo.output.plutusData
627
+ );
628
+ const invalidBefore = unixTimeToEnclosingSlot(
629
+ Math.min(datum.fields[0].int, Date.now() - 15e3),
630
+ this.networkId === 0 ? SLOT_CONFIG_NETWORK.preprod : SLOT_CONFIG_NETWORK.mainnet
631
+ ) + 1;
632
+ await this.mesh.spendingPlutusScriptV2().txIn(
633
+ vestingUtxo.input.txHash,
634
+ vestingUtxo.input.outputIndex,
635
+ vestingUtxo.output.amount,
636
+ scriptAddr
637
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(this.scriptCbor).txOut(walletAddress, []).txInCollateral(
638
+ collateralInput.txHash,
639
+ collateralInput.outputIndex,
640
+ collateralOutput.amount,
641
+ collateralOutput.address
642
+ ).invalidBefore(invalidBefore).requiredSignerHash(pubKeyHash).changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
643
+ return this.mesh.txHex;
644
+ };
645
+ getUtxoByTxHash = async (txHash) => {
646
+ return await this._getUtxoByTxHash(txHash, this.scriptCbor);
647
+ };
648
+ };
26
649
 
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\`.
650
+ // src/escrow/offchain.ts
651
+ import {
652
+ conStr0 as conStr02,
653
+ conStr1,
654
+ mConStr1 as mConStr12,
655
+ mConStr2,
656
+ pubKeyAddress as pubKeyAddress2,
657
+ value,
658
+ MeshValue
659
+ } from "@meshsdk/common";
660
+ import {
661
+ deserializeAddress as deserializeAddress3,
662
+ deserializeDatum as deserializeDatum3,
663
+ mergeAssets,
664
+ serializeAddressObj as serializeAddressObj2,
665
+ serializePlutusScript as serializePlutusScript3
666
+ } from "@meshsdk/core";
667
+ import { applyParamsToScript as applyParamsToScript3 } from "@meshsdk/core-csl";
31
668
 
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).
669
+ // src/escrow/aiken-workspace/plutus.json
670
+ var plutus_default3 = {
671
+ preamble: {
672
+ title: "meshjs/escrow",
673
+ description: "Aiken contracts for project 'meshjs/escrow'",
674
+ version: "0.0.0",
675
+ plutusVersion: "v2",
676
+ compiler: {
677
+ name: "Aiken",
678
+ version: "v1.0.29-alpha+unknown"
679
+ },
680
+ license: "Apache-2.0"
681
+ },
682
+ validators: [
683
+ {
684
+ title: "escrow.escrow",
685
+ datum: {
686
+ title: "_datum",
687
+ schema: {
688
+ $ref: "#/definitions/escrow~1types~1EscrowDatum"
689
+ }
690
+ },
691
+ redeemer: {
692
+ title: "redeemer",
693
+ schema: {
694
+ $ref: "#/definitions/escrow~1types~1EscrowRedeemer"
695
+ }
696
+ },
697
+ compiledCode: "590c2f01000032323232323232232323232323232232322533300d3232533300f300c3010375400226464646464646464a66602e602a60306ea80044c8c8c8c8c8c8c8c8c8c94ccc084c07c0244c8c8c8c8c8c8c94ccc0acc0b800c4c94ccc0b0c0bc00c4c94ccc0a8c080c0acdd5000899192999816181118169baa001132533302d302b302e3754006264646464a666068606e004264646464a66606a66ebc024cdd2a40046607200e660726e98014cc0e404ccc0e4dd300925eb8040045281980b9bab302730363754018660326eacc09cc0d8dd51813981b1baa00d301a011302c0073302c0022323302e3756606c0044646eb4c0e0008dd7181b0009bae3034001302c003163756606a002606a0046066002605e6ea800c58c0c4c0b8dd50008b180798169baa003302f302c37540022c601a60566ea8c070c0acdd50010b18168010b18160011bac302b302c00237586054002660506e9ccc01004c034cc0a0dd399802808806a5eb80dd598141814801181380098119baa01813232325333024302100c132323232533302b302e0031533302b0021325333029301f302a375400226464a666056605260586ea80084c94ccc0b0c0a8c0b4dd500089980500c1bae3031302e37540022c60106060605a6ea80084c8c8c8c8c8c8c8c94ccc0ccc0c4c0d0dd500089919299981a9819981b1baa0011533303532330010013303a375200666074607660706ea80092f5c044a66607400229404c94ccc0e0cc058090dd7181e8010a51133003003001303d00115333035005100414a0294058c044014dd7181c181a9baa00116300f006330143301001e00230173756606c606e006660266601e03a008602c6eacc0d400cc0d0004c0d0004c0cc008c0c4004c0b4dd50011811800981718159baa00116300c302a3754603660546ea80045858c0b0008dd6181598160011bac302a00133028374e6600802601a660506e9ccc0140440352f5c0264646464a666056605c0062a666056004264a666052603e60546ea80044c94ccc0a8c09cc0acdd500089919191919191919299981a981c001099191919191919299981c981b981d1baa00113232533303b3039303c37540022a6660766466002002660806ea400ccc100c104c0f8dd500125eb80894ccc100004528899299981f1980e0151bae304300213300300300114a060860022a66607600a200829405280b180b8059bae303e303b37540022c602a01a660346602c048010603a014660326602a046016603800a6605e008464660626eacc0e40088c8dd6981d8011bae3039001375c606e002605e00a6605a00c4646605e6eacc0dc0088c8dd6981c8011bae3037001375c606a002605a00e2c6eacc0d8004c0d8008c0d0004c0d0008dd598190009819001181800098161baa00116302e302b37540022c601860546ea8c06cc0a8dd50008b0b18160011bac302b302c00237586054002660506e9ccc01004c034cc0a0dd399802808806a5eb808c94ccc094c08cc098dd50008980819814981518139baa0014bd700a6103d87a800030153026375400244646600200200644a66605200229404c94ccc09ccdc79bae302c00200414a2266006006002605800244646600200200644a666050002297adef6c601332253330273375e603060526ea80080144cc030004dd5980d18149baa0021001302a00133002002302b001223300400223375e6028604a6ea8c058c094dd50008011119801801119baf30133024375400200444646600200200644a66604a002297ae013232533302430050021330280023300400400113300400400130290023027001223233001001323300100100322533302500114bd7009919991119198008008019129998158008801899198169ba73302d375200c6605a60540026605a605600297ae033003003302f002302d001375c60480026eacc094004cc00c00cc0a4008c09c004894ccc09000452889929998111919b89375a600e002664464a66604c6046604e6ea8004520001375a605660506ea8004c94ccc098c08cc09cdd50008a60103d87a8000132330010013756605860526ea8008894ccc0ac004530103d87a8000132323232533302c337220100042a66605866e3c0200084c05ccc0c0dd4000a5eb80530103d87a8000133006006003375a605a0066eb8c0ac008c0bc008c0b4004c8cc004004024894ccc0a80045300103d87a8000132323232533302b337220100042a66605666e3c0200084c058cc0bcdd3000a5eb80530103d87a8000133006006003375660580066eb8c0a8008c0b8008c0b0004dd7180a0009bae30160013758604e0042660060060022940c09c0048c088c08cc08c00488c8ccc00400400c0088894ccc08c00840044c8ccc010010c09c00ccccc020008dd718110009bab3023001222325333025533302800114a229405300103d87a80001301033029374c00297ae032333001001003002222533302a0021001132333004004302e0033322323300100100522533302f001133030337606ea4010dd4001a5eb7bdb1804c8c8c8c94ccc0c0cdc800400109981a19bb037520106ea001c01454ccc0c0cdc78040010992999818981798191baa001133035337606ea4024c0d8c0ccdd5000802080219299981898178008a60103d87a80001301c33035375000297ae03370000e00226606866ec0dd48011ba800133006006003375a60620066eb8c0bc008c0cc008c0c4004dd718148009bad302a001302c00230250022323300100100222533302000114bd6f7b6300999119191999804001801000911319190011919198008008019129998138008a4c264a6660500022a66604a60086eb4c09cc0a8008526161323232325333029337206eb8c0a8010dd718150018a9998149804000899803803998168018010b0b1bad302a003302d003302b002302a002302a001233302230200014a0944dd598110019bae3020002302200133002002302300122223233001001005225333022001133023337606ea4014dd300225eb7bdb1804c8c8c8c94ccc08ccdc800480109981399bb037520126e9802001454ccc08ccdc78048010992999812181118129baa001133028337606ea4028c0a4c098dd5000802080219980380480400089981399bb037520046e98004cc01801800cdd598120019bae3022002302600230240013019375401e601060326ea8c028c064dd5180e180c9baa0011632323300100100722533301c00114c0103d87a800013232533301b3375e6018603a6ea80080144c018cc07c0092f5c02660080080026040004603c002603660306ea8020dd2a40006eb0c064c068c068c068c068c068c068008dd6180c000980c180c0011bac301600130123754600260246ea80108c054004528180098081baa00223013301400114984d958c94ccc030c0280044c8c8c8c94ccc04cc0580084c8c9263300b0022323300d3756602a0044646eb4c05c008dd7180a8009bae3013001300b003163756602800260280046024002601c6ea800c54ccc030c02400454ccc03cc038dd50018a4c2c2a66601860040022a66601e601c6ea800c5261616300c37540046e1d20043001007232533300930070011323232325333010301300213232498cc0200088c8cc028dd598090011191bad3014002375c60240026eb8c040004c02000c58dd598088009808801180780098059baa0021533300930060011323232323232323253330143017002132323232498cc0380108c8cc040dd5980c0011191bad301a002375c60300026eb8c058004c038014cc0300188c8cc038dd5980b0011191bad3018002375c602c0026eb8c050004c03001c58dd5980a800980a801180980098098011bab30110013011002300f001300b37540042c60126ea800488c8cc00400400c894ccc0340045261323300300330110023003300f00125333006300430073754002264646464a66601a602000426464931929998061805000899192999808980a00109924c64a66601e601a00226464a666028602e0042649318068008b180a80098089baa0021533300f300c00113232323232325333018301b002149858dd6980c800980c8011bad30170013017002375a602a00260226ea800858c03cdd50008b180900098071baa0031533300c30090011533300f300e37540062930b0b18061baa002300600316300e001300e002300c001300837540022c464a66600c600800226464a666016601c0042930b1bae300c001300837540042a66600c600600226464a666016601c0042930b1bae300c001300837540042c600c6ea8004dc3a40046e1d20005734aae7555cf2ab9f5740ae855d101",
698
+ hash: "8fa9284f5889972d7260c10e940a2e1acb2114bdcea845da3d52de7d"
699
+ }
700
+ ],
701
+ definitions: {
702
+ ByteArray: {
703
+ dataType: "bytes"
704
+ },
705
+ Int: {
706
+ dataType: "integer"
707
+ },
708
+ List$Pair$ByteArray_Int: {
709
+ dataType: "map",
710
+ keys: {
711
+ $ref: "#/definitions/ByteArray"
712
+ },
713
+ values: {
714
+ $ref: "#/definitions/Int"
715
+ }
716
+ },
717
+ List$Pair$ByteArray_List$Pair$ByteArray_Int: {
718
+ dataType: "map",
719
+ keys: {
720
+ $ref: "#/definitions/ByteArray"
721
+ },
722
+ values: {
723
+ $ref: "#/definitions/List$Pair$ByteArray_Int"
724
+ }
725
+ },
726
+ "Option$aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential": {
727
+ title: "Optional",
728
+ anyOf: [
729
+ {
730
+ title: "Some",
731
+ description: "An optional value.",
732
+ dataType: "constructor",
733
+ index: 0,
734
+ fields: [
735
+ {
736
+ $ref: "#/definitions/aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"
737
+ }
738
+ ]
739
+ },
740
+ {
741
+ title: "None",
742
+ description: "Nothing.",
743
+ dataType: "constructor",
744
+ index: 1,
745
+ fields: []
746
+ }
747
+ ]
748
+ },
749
+ "aiken/transaction/credential/Address": {
750
+ title: "Address",
751
+ description: "A Cardano `Address` typically holding one or two credential references.\n\n Note that legacy bootstrap addresses (a.k.a. 'Byron addresses') are\n completely excluded from Plutus contexts. Thus, from an on-chain\n perspective only exists addresses of type 00, 01, ..., 07 as detailed\n in [CIP-0019 :: Shelley Addresses](https://cips.cardano.org/cip/CIP-19).",
752
+ anyOf: [
753
+ {
754
+ title: "Address",
755
+ dataType: "constructor",
756
+ index: 0,
757
+ fields: [
758
+ {
759
+ title: "payment_credential",
760
+ $ref: "#/definitions/aiken~1transaction~1credential~1Credential"
761
+ },
762
+ {
763
+ title: "stake_credential",
764
+ $ref: "#/definitions/Option$aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"
765
+ }
766
+ ]
767
+ }
768
+ ]
769
+ },
770
+ "aiken/transaction/credential/Credential": {
771
+ title: "Credential",
772
+ description: "A general structure for representing an on-chain `Credential`.\n\n Credentials are always one of two kinds: a direct public/private key\n pair, or a script (native or Plutus).",
773
+ anyOf: [
774
+ {
775
+ title: "VerificationKeyCredential",
776
+ dataType: "constructor",
777
+ index: 0,
778
+ fields: [
779
+ {
780
+ $ref: "#/definitions/ByteArray"
781
+ }
782
+ ]
783
+ },
784
+ {
785
+ title: "ScriptCredential",
786
+ dataType: "constructor",
787
+ index: 1,
788
+ fields: [
789
+ {
790
+ $ref: "#/definitions/ByteArray"
791
+ }
792
+ ]
793
+ }
794
+ ]
795
+ },
796
+ "aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential": {
797
+ title: "Referenced",
798
+ description: "Represent a type of object that can be represented either inline (by hash)\n or via a reference (i.e. a pointer to an on-chain location).\n\n This is mainly use for capturing pointers to a stake credential\n registration certificate in the case of so-called pointer addresses.",
799
+ anyOf: [
800
+ {
801
+ title: "Inline",
802
+ dataType: "constructor",
803
+ index: 0,
804
+ fields: [
805
+ {
806
+ $ref: "#/definitions/aiken~1transaction~1credential~1Credential"
807
+ }
808
+ ]
809
+ },
810
+ {
811
+ title: "Pointer",
812
+ dataType: "constructor",
813
+ index: 1,
814
+ fields: [
815
+ {
816
+ title: "slot_number",
817
+ $ref: "#/definitions/Int"
818
+ },
819
+ {
820
+ title: "transaction_index",
821
+ $ref: "#/definitions/Int"
822
+ },
823
+ {
824
+ title: "certificate_index",
825
+ $ref: "#/definitions/Int"
826
+ }
827
+ ]
828
+ }
829
+ ]
830
+ },
831
+ "escrow/types/EscrowDatum": {
832
+ title: "EscrowDatum",
833
+ anyOf: [
834
+ {
835
+ title: "Initiation",
836
+ dataType: "constructor",
837
+ index: 0,
838
+ fields: [
839
+ {
840
+ title: "initiator",
841
+ $ref: "#/definitions/aiken~1transaction~1credential~1Address"
842
+ },
843
+ {
844
+ title: "initiator_assets",
845
+ $ref: "#/definitions/List$Pair$ByteArray_List$Pair$ByteArray_Int"
846
+ }
847
+ ]
848
+ },
849
+ {
850
+ title: "ActiveEscrow",
851
+ dataType: "constructor",
852
+ index: 1,
853
+ fields: [
854
+ {
855
+ title: "initiator",
856
+ $ref: "#/definitions/aiken~1transaction~1credential~1Address"
857
+ },
858
+ {
859
+ title: "initiator_assets",
860
+ $ref: "#/definitions/List$Pair$ByteArray_List$Pair$ByteArray_Int"
861
+ },
862
+ {
863
+ title: "recipient",
864
+ $ref: "#/definitions/aiken~1transaction~1credential~1Address"
865
+ },
866
+ {
867
+ title: "recipient_assets",
868
+ $ref: "#/definitions/List$Pair$ByteArray_List$Pair$ByteArray_Int"
869
+ }
870
+ ]
871
+ }
872
+ ]
873
+ },
874
+ "escrow/types/EscrowRedeemer": {
875
+ title: "EscrowRedeemer",
876
+ anyOf: [
877
+ {
878
+ title: "RecipientDeposit",
879
+ dataType: "constructor",
880
+ index: 0,
881
+ fields: [
882
+ {
883
+ title: "recipient",
884
+ $ref: "#/definitions/aiken~1transaction~1credential~1Address"
885
+ },
886
+ {
887
+ title: "recipient_assets",
888
+ $ref: "#/definitions/List$Pair$ByteArray_List$Pair$ByteArray_Int"
889
+ }
890
+ ]
891
+ },
892
+ {
893
+ title: "CancelTrade",
894
+ dataType: "constructor",
895
+ index: 1,
896
+ fields: []
897
+ },
898
+ {
899
+ title: "CompleteTrade",
900
+ dataType: "constructor",
901
+ index: 2,
902
+ fields: []
903
+ }
904
+ ]
905
+ }
906
+ }
907
+ };
35
908
 
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 Vt=P,e0=class extends p{scriptCbor=z0(P.validators[0].compiledCode,[]);scriptAddress;constructor(e){super(e),this.scriptAddress=E0({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}=X(a),d=W0([q0(n,s),Q(e),Q(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=Y(e.output.plutusData),n=Z(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(j0([])).txInScript(this.scriptCbor).txOut(n,L0.fromValue(s).toAssets()).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=Y(e.output.plutusData),n=Z(i.fields[0]);return await this.mesh.spendingPlutusScriptV2().txIn(e.input.txHash,e.input.outputIndex,e.output.amount,e.output.address).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(K0([])).txInScript(this.scriptCbor).changeAddress(c).txInCollateral(a.input.txHash,a.input.outputIndex,a.output.amount,a.output.address).requiredSignerHash(X(n).pubKeyHash).selectUtxosFrom(t).complete(),this.mesh.txHex};getUtxoByTxHash=async e=>await this._getUtxoByTxHash(e,this.scriptCbor)};export{qe as MeshEscrowBlueprint,W as MeshEscrowContract,rt as MeshGiftCardBlueprint,E as MeshGiftCardContract,ue as MeshMarketplaceBlueprint,V as MeshMarketplaceContract,gt as MeshPaymentSplitterBlueprint,G as MeshPaymentSplitterContract,Vt as MeshSwapBlueprint,e0 as MeshSwapContract,ve as MeshVestingBlueprint,F as MeshVestingContract,C0 as activeEscrowDatum,q as initiateEscrowDatum,R as marketplaceDatum,k0 as recipientDepositRedeemer};
909
+ // src/escrow/offchain.ts
910
+ var MeshEscrowBlueprint = plutus_default3;
911
+ var initiateEscrowDatum = (walletAddress, amount) => {
912
+ const { pubKeyHash, stakeCredentialHash } = deserializeAddress3(walletAddress);
913
+ return conStr02([
914
+ pubKeyAddress2(pubKeyHash, stakeCredentialHash),
915
+ value(amount)
916
+ ]);
917
+ };
918
+ var activeEscrowDatum = (initiationDatum, walletAddress, amount) => {
919
+ const { pubKeyHash, stakeCredentialHash } = deserializeAddress3(walletAddress);
920
+ const [initiator, initiatorAmount] = initiationDatum.fields;
921
+ return conStr1([
922
+ initiator,
923
+ initiatorAmount,
924
+ pubKeyAddress2(pubKeyHash, stakeCredentialHash),
925
+ value(amount)
926
+ ]);
927
+ };
928
+ var recipientDepositRedeemer = (recipient, depositAmount) => initiateEscrowDatum(recipient, depositAmount);
929
+ var MeshEscrowContract = class extends MeshTxInitiator {
930
+ scriptCbor = applyParamsToScript3(plutus_default3.validators[0].compiledCode, []);
931
+ constructor(inputs) {
932
+ super(inputs);
933
+ }
934
+ initiateEscrow = async (escrowAmount) => {
935
+ const { utxos, walletAddress } = await this.getWalletInfoForTx();
936
+ const { address: scriptAddr } = serializePlutusScript3(
937
+ { code: this.scriptCbor, version: "V2" },
938
+ void 0,
939
+ this.networkId
940
+ );
941
+ await this.mesh.txOut(scriptAddr, escrowAmount).txOutInlineDatumValue(
942
+ initiateEscrowDatum(walletAddress, escrowAmount),
943
+ "JSON"
944
+ ).changeAddress(walletAddress).selectUtxosFrom(utxos).complete();
945
+ return this.mesh.txHex;
946
+ };
947
+ cancelEscrow = async (escrowUtxo) => {
948
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
949
+ const { address: scriptAddr } = serializePlutusScript3(
950
+ { code: this.scriptCbor, version: "V2" },
951
+ void 0,
952
+ this.networkId
953
+ );
954
+ const inputDatum = deserializeDatum3(
955
+ escrowUtxo.output.plutusData
956
+ );
957
+ if (inputDatum.constructor === 1) {
958
+ const [
959
+ initiatorAddressObj,
960
+ initiatorAmount,
961
+ recipientAddressObj,
962
+ recipientAmount
963
+ ] = inputDatum.fields;
964
+ const initiatorAddress = serializeAddressObj2(initiatorAddressObj);
965
+ const recipientAddress = serializeAddressObj2(recipientAddressObj);
966
+ const initiatorToReceive = MeshValue.fromValue(initiatorAmount).toAssets();
967
+ const recipientToReceive = MeshValue.fromValue(recipientAmount).toAssets();
968
+ this.mesh.txOut(initiatorAddress, initiatorToReceive).txOut(recipientAddress, recipientToReceive);
969
+ }
970
+ await this.mesh.spendingPlutusScriptV2().txIn(
971
+ escrowUtxo.input.txHash,
972
+ escrowUtxo.input.outputIndex,
973
+ escrowUtxo.output.amount,
974
+ scriptAddr
975
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr12([])).txInScript(this.scriptCbor).requiredSignerHash(deserializeAddress3(walletAddress).pubKeyHash).changeAddress(walletAddress).txInCollateral(
976
+ collateral.input.txHash,
977
+ collateral.input.outputIndex,
978
+ collateral.output.amount,
979
+ collateral.output.address
980
+ ).selectUtxosFrom(utxos).complete();
981
+ return this.mesh.txHex;
982
+ };
983
+ recipientDeposit = async (escrowUtxo, depositAmount) => {
984
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
985
+ const { address: scriptAddr } = serializePlutusScript3(
986
+ { code: this.scriptCbor, version: "V2" },
987
+ void 0,
988
+ this.networkId
989
+ );
990
+ const inputDatum = deserializeDatum3(
991
+ escrowUtxo.output.plutusData
992
+ );
993
+ const outputDatum = activeEscrowDatum(
994
+ inputDatum,
995
+ walletAddress,
996
+ depositAmount
997
+ );
998
+ const inputAssets = MeshValue.fromValue(inputDatum.fields[1]).toAssets();
999
+ const escrowAmount = mergeAssets([...depositAmount, ...inputAssets]);
1000
+ await this.mesh.spendingPlutusScriptV2().txIn(
1001
+ escrowUtxo.input.txHash,
1002
+ escrowUtxo.input.outputIndex,
1003
+ escrowUtxo.output.amount,
1004
+ scriptAddr
1005
+ ).spendingReferenceTxInInlineDatumPresent().txInRedeemerValue(
1006
+ recipientDepositRedeemer(walletAddress, depositAmount),
1007
+ "JSON",
1008
+ {
1009
+ mem: 7e6,
1010
+ steps: 3e9
1011
+ }
1012
+ ).txInScript(this.scriptCbor).txOut(scriptAddr, escrowAmount).txOutInlineDatumValue(outputDatum, "JSON").changeAddress(walletAddress).txInCollateral(
1013
+ collateral.input.txHash,
1014
+ collateral.input.outputIndex,
1015
+ collateral.output.amount,
1016
+ collateral.output.address
1017
+ ).selectUtxosFrom(utxos).complete();
1018
+ return this.mesh.txHex;
1019
+ };
1020
+ completeEscrow = async (escrowUtxo) => {
1021
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
1022
+ const { address: scriptAddr } = serializePlutusScript3(
1023
+ { code: this.scriptCbor, version: "V2" },
1024
+ void 0,
1025
+ this.networkId
1026
+ );
1027
+ const inputDatum = deserializeDatum3(
1028
+ escrowUtxo.output.plutusData
1029
+ );
1030
+ const [
1031
+ initiatorAddressObj,
1032
+ initiatorAmount,
1033
+ recipientAddressObj,
1034
+ recipientAmount
1035
+ ] = inputDatum.fields;
1036
+ const initiatorAddress = serializeAddressObj2(initiatorAddressObj);
1037
+ const recipientAddress = serializeAddressObj2(recipientAddressObj);
1038
+ const initiatorToReceive = MeshValue.fromValue(recipientAmount).toAssets();
1039
+ const recipientToReceive = MeshValue.fromValue(initiatorAmount).toAssets();
1040
+ await this.mesh.spendingPlutusScriptV2().txIn(
1041
+ escrowUtxo.input.txHash,
1042
+ escrowUtxo.input.outputIndex,
1043
+ escrowUtxo.output.amount,
1044
+ scriptAddr
1045
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr2([])).txInScript(this.scriptCbor).txOut(initiatorAddress, initiatorToReceive).txOut(recipientAddress, recipientToReceive).requiredSignerHash(deserializeAddress3(recipientAddress).pubKeyHash).requiredSignerHash(deserializeAddress3(initiatorAddress).pubKeyHash).changeAddress(walletAddress).txInCollateral(
1046
+ collateral.input.txHash,
1047
+ collateral.input.outputIndex,
1048
+ collateral.output.amount,
1049
+ collateral.output.address
1050
+ ).selectUtxosFrom(utxos).complete();
1051
+ return this.mesh.txHex;
1052
+ };
1053
+ getUtxoByTxHash = async (txHash) => {
1054
+ return await this._getUtxoByTxHash(txHash, this.scriptCbor);
1055
+ };
1056
+ };
1057
+
1058
+ // src/giftcard/offchain.ts
1059
+ import {
1060
+ builtinByteString,
1061
+ mConStr0 as mConStr03,
1062
+ mConStr1 as mConStr13,
1063
+ stringToHex,
1064
+ txOutRef
1065
+ } from "@meshsdk/common";
1066
+ import {
1067
+ deserializeDatum as deserializeDatum4,
1068
+ resolveScriptHash,
1069
+ serializePlutusScript as serializePlutusScript4
1070
+ } from "@meshsdk/core";
1071
+ import { applyParamsToScript as applyParamsToScript4 } from "@meshsdk/core-csl";
1072
+
1073
+ // src/giftcard/aiken-workspace/plutus.json
1074
+ var plutus_default4 = {
1075
+ preamble: {
1076
+ title: "meshjs/giftcard",
1077
+ description: "Aiken contracts for project 'meshjs/giftcard'",
1078
+ version: "0.0.0",
1079
+ plutusVersion: "v2",
1080
+ compiler: {
1081
+ name: "Aiken",
1082
+ version: "v1.0.29-alpha+unknown"
1083
+ },
1084
+ license: "Apache-2.0"
1085
+ },
1086
+ validators: [
1087
+ {
1088
+ title: "oneshot.gift_card",
1089
+ redeemer: {
1090
+ title: "rdmr",
1091
+ schema: {
1092
+ $ref: "#/definitions/oneshot~1Action"
1093
+ }
1094
+ },
1095
+ parameters: [
1096
+ {
1097
+ title: "token_name",
1098
+ schema: {
1099
+ $ref: "#/definitions/ByteArray"
1100
+ }
1101
+ },
1102
+ {
1103
+ title: "utxo_ref",
1104
+ schema: {
1105
+ $ref: "#/definitions/aiken~1transaction~1OutputReference"
1106
+ }
1107
+ }
1108
+ ],
1109
+ compiledCode: "5901f5010000323232323232322322232323225333009323232533300c3007300d3754002264646464a666026602c00426464a666024601a60266ea803854ccc048c034c04cdd5191980080080311299980b8008a60103d87a80001323253330163375e603660306ea800804c4cdd2a40006603400497ae0133004004001301b002301900115333012300c00113371e00402029405854ccc048cdc3800a4002266e3c0080405281bad3013002375c60220022c602800264a66601e601260206ea800452f5bded8c026eacc050c044dd500099191980080099198008009bab3016301730173017301700522533301500114bd6f7b630099191919299980b19b91488100002153330163371e9101000021003100513301a337606ea4008dd3000998030030019bab3017003375c602a0046032004602e00244a666028002298103d87a800013232323253330153372200e0042a66602a66e3c01c0084cdd2a4000660326e980052f5c02980103d87a80001330060060033756602c0066eb8c050008c060008c058004dd7180998081baa00337586024002601c6ea800858c040c044008c03c004c02cdd50008a4c26cac64a66601060060022a66601660146ea8010526161533300830020011533300b300a37540082930b0b18041baa003370e90011b8748000dd7000ab9a5573aaae7955cfaba05742ae89",
1110
+ hash: "0c0d17d9095fe6b07a2727403e2c6f2dff8042ed7c300cb67a2577a2"
1111
+ },
1112
+ {
1113
+ title: "oneshot.redeem",
1114
+ datum: {
1115
+ title: "_d",
1116
+ schema: {
1117
+ $ref: "#/definitions/Data"
1118
+ }
1119
+ },
1120
+ redeemer: {
1121
+ title: "_r",
1122
+ schema: {
1123
+ $ref: "#/definitions/Data"
1124
+ }
1125
+ },
1126
+ parameters: [
1127
+ {
1128
+ title: "token_name",
1129
+ schema: {
1130
+ $ref: "#/definitions/ByteArray"
1131
+ }
1132
+ },
1133
+ {
1134
+ title: "policy_id",
1135
+ schema: {
1136
+ $ref: "#/definitions/ByteArray"
1137
+ }
1138
+ }
1139
+ ],
1140
+ compiledCode: "5901320100003232323232323223223222253330083232533300d3010002132533300b3370e6eb4c034009200113371e0020122940dd718058008b180700099299980499b8748008c028dd50008a5eb7bdb1804dd5980718059baa001323300100132330010013756601e602060206020602060186ea8c03cc030dd50019129998070008a5eb7bdb1804c8c8c8c94ccc03ccdc8a45000021533300f3371e91010000210031005133013337606ea4008dd3000998030030019bab3010003375c601c0046024004602000244a66601a002298103d87a8000132323232533300e337220140042a66601c66e3c0280084cdd2a4000660246e980052f5c02980103d87a80001330060060033756601e0066eb8c034008c044008c03c00452613656375c0026eb80055cd2ab9d5573caae7d5d02ba157441",
1141
+ hash: "39faa048196bb6b30f50815475e9d16b22e7a0ef6de5935b408ca617"
1142
+ }
1143
+ ],
1144
+ definitions: {
1145
+ ByteArray: {
1146
+ dataType: "bytes"
1147
+ },
1148
+ Data: {
1149
+ title: "Data",
1150
+ description: "Any Plutus data."
1151
+ },
1152
+ Int: {
1153
+ dataType: "integer"
1154
+ },
1155
+ "aiken/transaction/OutputReference": {
1156
+ title: "OutputReference",
1157
+ 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",
1158
+ anyOf: [
1159
+ {
1160
+ title: "OutputReference",
1161
+ dataType: "constructor",
1162
+ index: 0,
1163
+ fields: [
1164
+ {
1165
+ title: "transaction_id",
1166
+ $ref: "#/definitions/aiken~1transaction~1TransactionId"
1167
+ },
1168
+ {
1169
+ title: "output_index",
1170
+ $ref: "#/definitions/Int"
1171
+ }
1172
+ ]
1173
+ }
1174
+ ]
1175
+ },
1176
+ "aiken/transaction/TransactionId": {
1177
+ title: "TransactionId",
1178
+ 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.",
1179
+ anyOf: [
1180
+ {
1181
+ title: "TransactionId",
1182
+ dataType: "constructor",
1183
+ index: 0,
1184
+ fields: [
1185
+ {
1186
+ title: "hash",
1187
+ $ref: "#/definitions/ByteArray"
1188
+ }
1189
+ ]
1190
+ }
1191
+ ]
1192
+ },
1193
+ "oneshot/Action": {
1194
+ title: "Action",
1195
+ anyOf: [
1196
+ {
1197
+ title: "Mint",
1198
+ dataType: "constructor",
1199
+ index: 0,
1200
+ fields: []
1201
+ },
1202
+ {
1203
+ title: "Burn",
1204
+ dataType: "constructor",
1205
+ index: 1,
1206
+ fields: []
1207
+ }
1208
+ ]
1209
+ }
1210
+ }
1211
+ };
1212
+
1213
+ // src/giftcard/offchain.ts
1214
+ var MeshGiftCardBlueprint = plutus_default4;
1215
+ var MeshGiftCardContract = class extends MeshTxInitiator {
1216
+ tokenNameHex = "";
1217
+ paramUtxo = { outputIndex: 0, txHash: "" };
1218
+ giftCardCbor = (tokenNameHex, utxoTxHash, utxoTxId) => {
1219
+ return applyParamsToScript4(
1220
+ plutus_default4.validators[0].compiledCode,
1221
+ [builtinByteString(tokenNameHex), txOutRef(utxoTxHash, utxoTxId)],
1222
+ "JSON"
1223
+ );
1224
+ };
1225
+ redeemCbor = (tokenNameHex, policyId) => applyParamsToScript4(plutus_default4.validators[1].compiledCode, [
1226
+ tokenNameHex,
1227
+ policyId
1228
+ ]);
1229
+ constructor(inputs, tokenNameHex, paramUtxo) {
1230
+ super(inputs);
1231
+ if (tokenNameHex) {
1232
+ this.tokenNameHex = tokenNameHex;
1233
+ }
1234
+ if (paramUtxo) {
1235
+ this.paramUtxo = paramUtxo;
1236
+ }
1237
+ }
1238
+ createGiftCard = async (tokenName2, giftValue) => {
1239
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
1240
+ const tokenNameHex = stringToHex(tokenName2);
1241
+ const firstUtxo = utxos[0];
1242
+ if (firstUtxo === void 0) throw new Error("No UTXOs available");
1243
+ const remainingUtxos = utxos.slice(1);
1244
+ const giftCardScript = this.giftCardCbor(
1245
+ tokenNameHex,
1246
+ firstUtxo.input.txHash,
1247
+ firstUtxo.input.outputIndex
1248
+ );
1249
+ const giftCardPolicy = resolveScriptHash(giftCardScript, "V2");
1250
+ const redeemScript = {
1251
+ code: this.redeemCbor(tokenNameHex, giftCardPolicy),
1252
+ version: "V2"
1253
+ };
1254
+ const redeemAddr = serializePlutusScript4(
1255
+ redeemScript,
1256
+ void 0,
1257
+ this.networkId
1258
+ ).address;
1259
+ await this.mesh.txIn(
1260
+ firstUtxo.input.txHash,
1261
+ firstUtxo.input.outputIndex,
1262
+ firstUtxo.output.amount,
1263
+ firstUtxo.output.address
1264
+ ).mintPlutusScriptV2().mint("1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue(mConStr03([])).txOut(redeemAddr, [
1265
+ ...giftValue,
1266
+ { unit: giftCardPolicy + tokenNameHex, quantity: "1" }
1267
+ ]).txOutInlineDatumValue([
1268
+ firstUtxo.input.txHash,
1269
+ firstUtxo.input.outputIndex,
1270
+ tokenNameHex
1271
+ ]).changeAddress(walletAddress).txInCollateral(
1272
+ collateral.input.txHash,
1273
+ collateral.input.outputIndex,
1274
+ collateral.output.amount,
1275
+ collateral.output.address
1276
+ ).selectUtxosFrom(remainingUtxos).complete();
1277
+ this.tokenNameHex = tokenNameHex;
1278
+ this.paramUtxo = firstUtxo.input;
1279
+ return this.mesh.txHex;
1280
+ };
1281
+ redeemGiftCard = async (giftCardUtxo) => {
1282
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
1283
+ const inlineDatum = deserializeDatum4(
1284
+ giftCardUtxo.output.plutusData
1285
+ ).list;
1286
+ const paramTxHash = inlineDatum[0].bytes;
1287
+ const paramTxId = inlineDatum[1].int;
1288
+ const tokenNameHex = inlineDatum[2].bytes;
1289
+ const giftCardScript = this.giftCardCbor(
1290
+ tokenNameHex,
1291
+ paramTxHash,
1292
+ paramTxId
1293
+ );
1294
+ const giftCardPolicy = resolveScriptHash(giftCardScript, "V2");
1295
+ const redeemScript = this.redeemCbor(tokenNameHex, giftCardPolicy);
1296
+ await this.mesh.spendingPlutusScriptV2().txIn(
1297
+ giftCardUtxo.input.txHash,
1298
+ giftCardUtxo.input.outputIndex,
1299
+ giftCardUtxo.output.amount,
1300
+ giftCardUtxo.output.address
1301
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue("").txInScript(redeemScript).mintPlutusScriptV2().mint("-1", giftCardPolicy, tokenNameHex).mintingScript(giftCardScript).mintRedeemerValue(mConStr13([])).changeAddress(walletAddress).txInCollateral(
1302
+ collateral.input.txHash,
1303
+ collateral.input.outputIndex,
1304
+ collateral.output.amount,
1305
+ collateral.output.address
1306
+ ).selectUtxosFrom(utxos).complete();
1307
+ return this.mesh.txHex;
1308
+ };
1309
+ getUtxoByTxHash = async (txHash) => {
1310
+ return await this._getUtxoByTxHash(txHash);
1311
+ };
1312
+ };
1313
+
1314
+ // src/payment-splitter/offchain.ts
1315
+ import { builtinByteString as builtinByteString2, list } from "@meshsdk/common";
1316
+ import {
1317
+ BrowserWallet,
1318
+ deserializeAddress as deserializeAddress4,
1319
+ MeshWallet,
1320
+ serializePlutusScript as serializePlutusScript5,
1321
+ Transaction
1322
+ } from "@meshsdk/core";
1323
+ import { applyParamsToScript as applyParamsToScript5 } from "@meshsdk/core-csl";
1324
+
1325
+ // src/payment-splitter/aiken-workspace/plutus.json
1326
+ var plutus_default5 = {
1327
+ preamble: {
1328
+ title: "fabianbormann/payment-splitter",
1329
+ description: "Aiken contracts for project 'fabianbormann/payment-splitter'",
1330
+ version: "0.1.0",
1331
+ plutusVersion: "v2",
1332
+ compiler: {
1333
+ name: "Aiken",
1334
+ version: "v1.0.29-alpha+unknown"
1335
+ },
1336
+ license: "Apache-2.0"
1337
+ },
1338
+ validators: [
1339
+ {
1340
+ title: "payment_splitter.payout",
1341
+ datum: {
1342
+ title: "_datum",
1343
+ schema: {
1344
+ $ref: "#/definitions/payment_splitter~1Datum"
1345
+ }
1346
+ },
1347
+ redeemer: {
1348
+ title: "_redeemer",
1349
+ schema: {
1350
+ $ref: "#/definitions/payment_splitter~1Redeemer"
1351
+ }
1352
+ },
1353
+ parameters: [
1354
+ {
1355
+ title: "scriptHashes",
1356
+ schema: {
1357
+ $ref: "#/definitions/List$ByteArray"
1358
+ }
1359
+ }
1360
+ ],
1361
+ compiledCode: "5903a5010000323232323232322322322322533300832323232323232323232323253330143375e6e9cccc8c0040048894ccc06800440084ccc00c00cc8c8cc004004010894ccc07400452f5c026464a66603866ebc00801440044cc080008cc010010004c084008c07c004c070004c074004cc8c004004894ccc06400452f5c026466036002660060066600e603a004466603066ebc00400928251301b001323300100100722533301900114bd7009980d1806180c1baa300c3018375460360026600400460380020169801018000100114a0646600200200444a66603000229444c94ccc058cdc39bad301b00233005533301900414c0103d87a80001300e3301a301b0044bd70240002660060060022940c06c004c8cc004004028894ccc05c00452f5c02660306ea0c8c8c8c8c8c94ccc068cdc424000002266e04008cdc08009802005880119980119804806919baf3010301c3754602060386ea8c014c070dd5000803240004466e00004c014dd59803180e9baa3006301d375400466600266010014466ebcc03cc06cdd51807980d9baa0010054800088cdc000098021bab3005301c3754004444646600200200844a66603e0022008266006604200266004004604400246600c64a66603066e1d200230193754002298103d87a8000132330010013756603c60366ea8008894ccc074004530103d87a8000132323232533301e33722911000021533301e3371e9101000021301633022375000297ae014c0103d87a8000133006006003375a603e0066eb8c074008c084008c07c004c8cc004004008894ccc0700045300103d87a8000132323232533301d33722911000021533301d3371e9101000021301533021374c00297ae014c0103d87a80001330060060033756603c0066eb8c070008c080008c07800520002301b301c001301900133002002301a0012253330133370e9001180a1baa00210011375a6030602a6ea800888c8cc00400400c894ccc05c00452f5c026464a66602c600a00426603400466008008002266008008002603600460320026eacc050c054008dd61809800980998098011bac3011001300d37546002601a6ea80108c040004c8cc004004020894ccc03800452f5c026601e60066601e602000297ae0330020023011001374a90000a4c26caca66600c66e1d20003007375400226464a666016601c0042930b1bae300c001300837540022ca66600866e1d20003005375400226464a66601260180042930b1bae300a001300637540022c6eb00055cd2ab9d5573caae7d5d02ba157441",
1362
+ hash: "0776032753d2900f7c1e933af4108c53851e10ca95fa10e34af90277"
1363
+ }
1364
+ ],
1365
+ definitions: {
1366
+ ByteArray: {
1367
+ dataType: "bytes"
1368
+ },
1369
+ List$ByteArray: {
1370
+ dataType: "list",
1371
+ items: {
1372
+ $ref: "#/definitions/ByteArray"
1373
+ }
1374
+ },
1375
+ "payment_splitter/Datum": {
1376
+ title: "Datum",
1377
+ anyOf: [
1378
+ {
1379
+ title: "Datum",
1380
+ dataType: "constructor",
1381
+ index: 0,
1382
+ fields: [
1383
+ {
1384
+ title: "owner",
1385
+ $ref: "#/definitions/ByteArray"
1386
+ }
1387
+ ]
1388
+ }
1389
+ ]
1390
+ },
1391
+ "payment_splitter/Redeemer": {
1392
+ title: "Redeemer",
1393
+ anyOf: [
1394
+ {
1395
+ title: "Redeemer",
1396
+ dataType: "constructor",
1397
+ index: 0,
1398
+ fields: [
1399
+ {
1400
+ title: "message",
1401
+ $ref: "#/definitions/ByteArray"
1402
+ }
1403
+ ]
1404
+ }
1405
+ ]
1406
+ }
1407
+ }
1408
+ };
1409
+
1410
+ // src/payment-splitter/offchain.ts
1411
+ var MeshPaymentSplitterBlueprint = plutus_default5;
1412
+ var MeshPaymentSplitterContract = class extends MeshTxInitiator {
1413
+ wrapPayees = (payees) => list(
1414
+ payees.map(
1415
+ (payee) => builtinByteString2(deserializeAddress4(payee).pubKeyHash)
1416
+ )
1417
+ );
1418
+ scriptCbor = () => applyParamsToScript5(
1419
+ plutus_default5.validators[0].compiledCode,
1420
+ [this.wrapPayees(this.payees)],
1421
+ "JSON"
1422
+ );
1423
+ payees = [];
1424
+ constructor(inputs, payees) {
1425
+ super(inputs);
1426
+ if (inputs.wallet) {
1427
+ if (inputs.wallet instanceof MeshWallet) {
1428
+ this.payees = [inputs.wallet.getUsedAddresses()[0], ...payees];
1429
+ }
1430
+ if (inputs.wallet instanceof BrowserWallet) {
1431
+ inputs.wallet.getUsedAddresses().then((addresses) => {
1432
+ this.payees = [addresses[0], ...payees];
1433
+ });
1434
+ }
1435
+ } else {
1436
+ this.payees = payees;
1437
+ console.warn(
1438
+ "Wallet not provided. Therefore the payment address will not be added to the payees list which makes it impossible to trigger the payout."
1439
+ );
1440
+ }
1441
+ }
1442
+ sendLovelaceToSplitter = async (lovelaceAmount) => {
1443
+ if (this.wallet === null || this.wallet === void 0) {
1444
+ throw new Error("Wallet not provided");
1445
+ }
1446
+ const { walletAddress } = await this.getWalletInfoForTx();
1447
+ const script = {
1448
+ code: this.scriptCbor(),
1449
+ version: "V2"
1450
+ };
1451
+ const { address: scriptAddress } = serializePlutusScript5(
1452
+ script,
1453
+ void 0,
1454
+ 0
1455
+ );
1456
+ const { pubKeyHash } = deserializeAddress4(walletAddress);
1457
+ const datum = {
1458
+ alternative: 0,
1459
+ fields: [pubKeyHash]
1460
+ };
1461
+ const tx = new Transaction({ initiator: this.wallet }).sendLovelace(
1462
+ {
1463
+ address: scriptAddress,
1464
+ datum: { value: datum }
1465
+ },
1466
+ lovelaceAmount.toString()
1467
+ );
1468
+ const unsignedTx = await tx.build();
1469
+ return unsignedTx;
1470
+ };
1471
+ triggerPayout = async () => {
1472
+ if (this.wallet === null || this.wallet === void 0) {
1473
+ throw new Error("Wallet not provided");
1474
+ }
1475
+ const { walletAddress, collateral } = await this.getWalletInfoForTx();
1476
+ const script = {
1477
+ code: this.scriptCbor(),
1478
+ version: "V2"
1479
+ };
1480
+ const { address: scriptAddress } = serializePlutusScript5(
1481
+ script,
1482
+ void 0,
1483
+ 0
1484
+ );
1485
+ const utxos = await this.fetcher?.fetchAddressUTxOs(scriptAddress) || [];
1486
+ const { pubKeyHash } = deserializeAddress4(walletAddress);
1487
+ const datum = {
1488
+ alternative: 0,
1489
+ fields: [pubKeyHash]
1490
+ };
1491
+ const redeemerData = "Hello, World!";
1492
+ const redeemer = { data: { alternative: 0, fields: [redeemerData] } };
1493
+ let tx = new Transaction({ initiator: this.wallet });
1494
+ let split = 0;
1495
+ for (const utxo of utxos) {
1496
+ const amount = utxo.output?.amount;
1497
+ if (amount) {
1498
+ let lovelace = amount.find((asset) => asset.unit === "lovelace");
1499
+ if (lovelace) {
1500
+ split += Math.floor(Number(lovelace.quantity) / this.payees.length);
1501
+ }
1502
+ tx = tx.redeemValue({
1503
+ value: utxo,
1504
+ script,
1505
+ datum,
1506
+ redeemer
1507
+ });
1508
+ }
1509
+ }
1510
+ tx = tx.setCollateral([collateral]);
1511
+ for (const payee of this.payees) {
1512
+ tx = tx.sendLovelace(payee, split.toString());
1513
+ }
1514
+ tx = tx.setRequiredSigners([walletAddress]);
1515
+ const unsignedTx = await tx.build();
1516
+ return unsignedTx;
1517
+ };
1518
+ };
1519
+
1520
+ // src/swap/offchain.ts
1521
+ import {
1522
+ conStr0 as conStr03,
1523
+ mConStr0 as mConStr04,
1524
+ mConStr1 as mConStr14,
1525
+ pubKeyAddress as pubKeyAddress3,
1526
+ value as value2,
1527
+ MeshValue as MeshValue2
1528
+ } from "@meshsdk/common";
1529
+ import {
1530
+ deserializeAddress as deserializeAddress5,
1531
+ deserializeDatum as deserializeDatum5,
1532
+ serializeAddressObj as serializeAddressObj3,
1533
+ serializePlutusScript as serializePlutusScript6
1534
+ } from "@meshsdk/core";
1535
+ import { applyParamsToScript as applyParamsToScript6 } from "@meshsdk/core-csl";
1536
+
1537
+ // src/swap/aiken-workspace/plutus.json
1538
+ var plutus_default6 = {
1539
+ preamble: {
1540
+ title: "meshjs/swap",
1541
+ description: "Aiken contracts for project 'meshjs/swap'",
1542
+ version: "0.0.0",
1543
+ plutusVersion: "v2",
1544
+ compiler: {
1545
+ name: "Aiken",
1546
+ version: "v1.0.29-alpha+unknown"
1547
+ },
1548
+ license: "Apache-2.0"
1549
+ },
1550
+ validators: [
1551
+ {
1552
+ title: "swap.swap",
1553
+ datum: {
1554
+ title: "datum",
1555
+ schema: {
1556
+ $ref: "#/definitions/swap~1SwapDatum"
1557
+ }
1558
+ },
1559
+ redeemer: {
1560
+ title: "redeemer",
1561
+ schema: {
1562
+ $ref: "#/definitions/swap~1SwapRedeemer"
1563
+ }
1564
+ },
1565
+ compiledCode: "590827010000323232323232322323232232253330083232533300a3007300b375400226464a6466601a6014601c6ea80204c94ccc038c030c03cdd5000899191919191919191919299980c299980d8048a501533301b301e00914a2294054ccc06000440085280a50330043330030084bd6f7b63011299980c99baf300e301b3754602260366ea800802c4cc010004dd59808980d9baa3011301b37540042002600c6eacc03cc064dd500b19801999119980200125eb7bdb180894ccc068cdd79807980e1baa0020031330050013756602460386ea80084004dd61802180c1baa300b3018375401e601660306ea8054c014dd59802180c1baa0152232333001001003002222533301d00210011323330040043021003333300b002375c60380026eacc074004888c94ccc07d4ccc0880045288a5014c103d87a80001301333023374c00297ae0323330010010030022225333024002100113233300400430280033322323300100100522533302900113302a337606ea4010dd4001a5eb7bdb1804c8c8c8c94ccc0a8cdc800400109981719bb037520106ea001c01454ccc0a8cdc78040010992999815981498161baa00113302f337606ea4024c0c0c0b4dd5000802080219299981598148008a60103d87a80001301f3302f375000297ae03370000e00226605c66ec0dd48011ba800133006006003375a60560066eb8c0a4008c0b4008c0ac004dd718118009bad30240013026002301f002222323300100100422533301c0011004133003301e00133002002301f001223233001001323300100100322533301b00114bd7009919991119198008008019129998108008801899198119ba733023375200c66046604000266046604200297ae03300300330250023023001375c60340026eacc06c004cc00c00cc07c008c074004894ccc068004528899299980c1919b89375a600e002664464a6660386032603a6ea8004520001375a6042603c6ea8004c94ccc070c064c074dd50008a6103d87a80001323300100137566044603e6ea8008894ccc084004530103d87a80001323232325333022337220100042a66604466e3c0200084c058cc098dd4000a5eb80530103d87a8000133006006003375a60460066eb8c084008c094008c08c004c8cc004004024894ccc0800045300103d87a80001323232325333021337220100042a66604266e3c0200084c054cc094dd3000a5eb80530103d87a8000133006006003375660440066eb8c080008c090008c088004dd718070009bae30110013758603a0042660060060022940c0740048c060c064c0640048c8cc004004008894ccc05c00452f5bded8c02664464646666010006004002444c646400464646600200200644a66603c002293099299980f8008a99980e18021bad301e30210021498584c8c8c8c94ccc080cdc81bae3021004375c60420062a666040601000226600e00e660480060042c2c6eb4c08400cc09000cc088008c084008c0840048ccc064c05c00528251375660320066eb8c05c008c064004cc008008c0680048888c8cc004004014894ccc0640044cc068cdd81ba9005374c00897adef6c60132323232533301a3372001200426603c66ec0dd48049ba60080051533301a3371e012004264a666036603260386ea80044cc07ccdd81ba900a3020301d3754002008200866600e01201000226603c66ec0dd48011ba600133006006003375660360066eb8c064008c074008c06c004c8cc004004dd6180298091baa30053012375401244a666028002297ae01323253330133375e6010602a6ea8c02cc054dd500100289980b80119802002000899802002000980c001180b000980198081baa300630103754602660206ea800458c8cc004004dd6180198081baa30033010375400e44a666024002298103d87a80001323253330113375e600c60266ea800801c4c014cc0540092f5c0266008008002602c0046028002264a66601c6018601e6ea80044cc88c8cc00400400c894ccc054004528099299980999b8f375c603000400829444cc00c00c004c060004dd61809980a180a180a180a180a180a180a180a18081baa30033010375400e6eb8c04cc040dd50008b192999807180618079baa001130023301230133010375400297ae014c0103d87a80003002300f37546004601e6ea8030dd2a400046022002601e60186ea8004528180098059baa0022300e300f00114984d958c94ccc01cc01400454ccc028c024dd50010a4c2c2a66600e60080022a66601460126ea80085261616300737540026464a66600c6008600e6ea80144c8c8c8c8c8c94ccc03cc0480084c8c8c926330090032323300b375660240044646eb4c050008dd718090009bae3010001330080042323300a375660220044646eb4c04c008dd718088009bae300f001533300c300a300d375400a264646464a666026602c0042646493192999809180800089919299980b980d00109924c64a66602a602600226464a666034603a0042649318098008b180d800980b9baa0021533301530120011323232323232533301e3021002149858dd6980f800980f8011bad301d001301d002375a6036002602e6ea800858c054dd50008b180c000980a1baa00315333012300f00115333015301437540062930b0b18091baa002300c00316301400130140023012001300e375400a2c2c6eacc040004c040008dd598070009807001180600098041baa0051622323300100100322533300c00114984c8cc00c00cc040008c00cc0380048c94ccc018c0100044c8c94ccc02cc03800852616375c601800260106ea800854ccc018c00c0044c8c94ccc02cc03800852616375c601800260106ea800858c018dd50009b8748008dc3a4000ae6955ceaab9e5573eae815d0aba201",
1566
+ hash: "5db0485a71b88eb31dec330bcf994509ea24b709498f90f9b1863902"
1567
+ }
1568
+ ],
1569
+ definitions: {
1570
+ ByteArray: {
1571
+ dataType: "bytes"
1572
+ },
1573
+ Int: {
1574
+ dataType: "integer"
1575
+ },
1576
+ List$Pair$ByteArray_Int: {
1577
+ dataType: "map",
1578
+ keys: {
1579
+ $ref: "#/definitions/ByteArray"
1580
+ },
1581
+ values: {
1582
+ $ref: "#/definitions/Int"
1583
+ }
1584
+ },
1585
+ List$Pair$ByteArray_List$Pair$ByteArray_Int: {
1586
+ dataType: "map",
1587
+ keys: {
1588
+ $ref: "#/definitions/ByteArray"
1589
+ },
1590
+ values: {
1591
+ $ref: "#/definitions/List$Pair$ByteArray_Int"
1592
+ }
1593
+ },
1594
+ "Option$aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential": {
1595
+ title: "Optional",
1596
+ anyOf: [
1597
+ {
1598
+ title: "Some",
1599
+ description: "An optional value.",
1600
+ dataType: "constructor",
1601
+ index: 0,
1602
+ fields: [
1603
+ {
1604
+ $ref: "#/definitions/aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"
1605
+ }
1606
+ ]
1607
+ },
1608
+ {
1609
+ title: "None",
1610
+ description: "Nothing.",
1611
+ dataType: "constructor",
1612
+ index: 1,
1613
+ fields: []
1614
+ }
1615
+ ]
1616
+ },
1617
+ "aiken/transaction/credential/Address": {
1618
+ title: "Address",
1619
+ description: "A Cardano `Address` typically holding one or two credential references.\n\n Note that legacy bootstrap addresses (a.k.a. 'Byron addresses') are\n completely excluded from Plutus contexts. Thus, from an on-chain\n perspective only exists addresses of type 00, 01, ..., 07 as detailed\n in [CIP-0019 :: Shelley Addresses](https://cips.cardano.org/cip/CIP-19).",
1620
+ anyOf: [
1621
+ {
1622
+ title: "Address",
1623
+ dataType: "constructor",
1624
+ index: 0,
1625
+ fields: [
1626
+ {
1627
+ title: "payment_credential",
1628
+ $ref: "#/definitions/aiken~1transaction~1credential~1Credential"
1629
+ },
1630
+ {
1631
+ title: "stake_credential",
1632
+ $ref: "#/definitions/Option$aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"
1633
+ }
1634
+ ]
1635
+ }
1636
+ ]
1637
+ },
1638
+ "aiken/transaction/credential/Credential": {
1639
+ title: "Credential",
1640
+ description: "A general structure for representing an on-chain `Credential`.\n\n Credentials are always one of two kinds: a direct public/private key\n pair, or a script (native or Plutus).",
1641
+ anyOf: [
1642
+ {
1643
+ title: "VerificationKeyCredential",
1644
+ dataType: "constructor",
1645
+ index: 0,
1646
+ fields: [
1647
+ {
1648
+ $ref: "#/definitions/ByteArray"
1649
+ }
1650
+ ]
1651
+ },
1652
+ {
1653
+ title: "ScriptCredential",
1654
+ dataType: "constructor",
1655
+ index: 1,
1656
+ fields: [
1657
+ {
1658
+ $ref: "#/definitions/ByteArray"
1659
+ }
1660
+ ]
1661
+ }
1662
+ ]
1663
+ },
1664
+ "aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential": {
1665
+ title: "Referenced",
1666
+ description: "Represent a type of object that can be represented either inline (by hash)\n or via a reference (i.e. a pointer to an on-chain location).\n\n This is mainly use for capturing pointers to a stake credential\n registration certificate in the case of so-called pointer addresses.",
1667
+ anyOf: [
1668
+ {
1669
+ title: "Inline",
1670
+ dataType: "constructor",
1671
+ index: 0,
1672
+ fields: [
1673
+ {
1674
+ $ref: "#/definitions/aiken~1transaction~1credential~1Credential"
1675
+ }
1676
+ ]
1677
+ },
1678
+ {
1679
+ title: "Pointer",
1680
+ dataType: "constructor",
1681
+ index: 1,
1682
+ fields: [
1683
+ {
1684
+ title: "slot_number",
1685
+ $ref: "#/definitions/Int"
1686
+ },
1687
+ {
1688
+ title: "transaction_index",
1689
+ $ref: "#/definitions/Int"
1690
+ },
1691
+ {
1692
+ title: "certificate_index",
1693
+ $ref: "#/definitions/Int"
1694
+ }
1695
+ ]
1696
+ }
1697
+ ]
1698
+ },
1699
+ "swap/SwapDatum": {
1700
+ title: "SwapDatum",
1701
+ anyOf: [
1702
+ {
1703
+ title: "SwapDatum",
1704
+ dataType: "constructor",
1705
+ index: 0,
1706
+ fields: [
1707
+ {
1708
+ title: "initiator",
1709
+ $ref: "#/definitions/aiken~1transaction~1credential~1Address"
1710
+ },
1711
+ {
1712
+ title: "to_provide",
1713
+ $ref: "#/definitions/List$Pair$ByteArray_List$Pair$ByteArray_Int"
1714
+ },
1715
+ {
1716
+ title: "to_receive",
1717
+ $ref: "#/definitions/List$Pair$ByteArray_List$Pair$ByteArray_Int"
1718
+ }
1719
+ ]
1720
+ }
1721
+ ]
1722
+ },
1723
+ "swap/SwapRedeemer": {
1724
+ title: "SwapRedeemer",
1725
+ anyOf: [
1726
+ {
1727
+ title: "Cancel",
1728
+ dataType: "constructor",
1729
+ index: 0,
1730
+ fields: []
1731
+ },
1732
+ {
1733
+ title: "Swap",
1734
+ dataType: "constructor",
1735
+ index: 1,
1736
+ fields: []
1737
+ }
1738
+ ]
1739
+ }
1740
+ }
1741
+ };
1742
+
1743
+ // src/swap/offchain.ts
1744
+ var MeshSwapBlueprint = plutus_default6;
1745
+ var MeshSwapContract = class extends MeshTxInitiator {
1746
+ scriptCbor = applyParamsToScript6(plutus_default6.validators[0].compiledCode, []);
1747
+ scriptAddress;
1748
+ constructor(inputs) {
1749
+ super(inputs);
1750
+ this.scriptAddress = serializePlutusScript6(
1751
+ { code: this.scriptCbor, version: "V2" },
1752
+ void 0,
1753
+ 0
1754
+ ).address;
1755
+ }
1756
+ initiateSwap = async (toProvide, toReceive) => {
1757
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
1758
+ const { pubKeyHash, stakeCredentialHash } = deserializeAddress5(walletAddress);
1759
+ const swapDatum = conStr03([
1760
+ pubKeyAddress3(pubKeyHash, stakeCredentialHash),
1761
+ value2(toProvide),
1762
+ value2(toReceive)
1763
+ ]);
1764
+ await this.mesh.txOut(this.scriptAddress, toProvide).txOutInlineDatumValue(swapDatum, "JSON").changeAddress(walletAddress).txInCollateral(
1765
+ collateral.input.txHash,
1766
+ collateral.input.outputIndex,
1767
+ collateral.output.amount,
1768
+ collateral.output.address
1769
+ ).selectUtxosFrom(utxos).complete();
1770
+ return this.mesh.txHex;
1771
+ };
1772
+ acceptSwap = async (swapUtxo) => {
1773
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
1774
+ const inlineDatum = deserializeDatum5(
1775
+ swapUtxo.output.plutusData
1776
+ );
1777
+ const initiatorAddress = serializeAddressObj3(inlineDatum.fields[0]);
1778
+ const initiatorToReceive = inlineDatum.fields[2];
1779
+ await this.mesh.spendingPlutusScriptV2().txIn(
1780
+ swapUtxo.input.txHash,
1781
+ swapUtxo.input.outputIndex,
1782
+ swapUtxo.output.amount,
1783
+ swapUtxo.output.address
1784
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr14([])).txInScript(this.scriptCbor).txOut(initiatorAddress, MeshValue2.fromValue(initiatorToReceive).toAssets()).changeAddress(walletAddress).txInCollateral(
1785
+ collateral.input.txHash,
1786
+ collateral.input.outputIndex,
1787
+ collateral.output.amount,
1788
+ collateral.output.address
1789
+ ).selectUtxosFrom(utxos).complete();
1790
+ return this.mesh.txHex;
1791
+ };
1792
+ cancelSwap = async (swapUtxo) => {
1793
+ const { utxos, walletAddress, collateral } = await this.getWalletInfoForTx();
1794
+ const inlineDatum = deserializeDatum5(
1795
+ swapUtxo.output.plutusData
1796
+ );
1797
+ const initiatorAddress = serializeAddressObj3(inlineDatum.fields[0]);
1798
+ await this.mesh.spendingPlutusScriptV2().txIn(
1799
+ swapUtxo.input.txHash,
1800
+ swapUtxo.input.outputIndex,
1801
+ swapUtxo.output.amount,
1802
+ swapUtxo.output.address
1803
+ ).spendingReferenceTxInInlineDatumPresent().spendingReferenceTxInRedeemerValue(mConStr04([])).txInScript(this.scriptCbor).changeAddress(walletAddress).txInCollateral(
1804
+ collateral.input.txHash,
1805
+ collateral.input.outputIndex,
1806
+ collateral.output.amount,
1807
+ collateral.output.address
1808
+ ).requiredSignerHash(deserializeAddress5(initiatorAddress).pubKeyHash).selectUtxosFrom(utxos).complete();
1809
+ return this.mesh.txHex;
1810
+ };
1811
+ getUtxoByTxHash = async (txHash) => {
1812
+ return await this._getUtxoByTxHash(txHash, this.scriptCbor);
1813
+ };
1814
+ };
1815
+ export {
1816
+ MeshEscrowBlueprint,
1817
+ MeshEscrowContract,
1818
+ MeshGiftCardBlueprint,
1819
+ MeshGiftCardContract,
1820
+ MeshMarketplaceBlueprint,
1821
+ MeshMarketplaceContract,
1822
+ MeshPaymentSplitterBlueprint,
1823
+ MeshPaymentSplitterContract,
1824
+ MeshSwapBlueprint,
1825
+ MeshSwapContract,
1826
+ MeshVestingBlueprint,
1827
+ MeshVestingContract,
1828
+ activeEscrowDatum,
1829
+ initiateEscrowDatum,
1830
+ marketplaceDatum,
1831
+ recipientDepositRedeemer
1832
+ };