@meshsdk/contract 1.5.28 → 1.5.30

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