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