@meshsdk/contract 1.6.0-alpha.21 → 1.6.2

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 (79) hide show
  1. package/dist/index.cjs +37 -0
  2. package/dist/{index.d.mts → index.d.cts} +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.js +28 -1803
  5. package/package.json +30 -14
  6. package/.turbo/turbo-build$colon$docs.log +0 -8
  7. package/.turbo/turbo-build$colon$mesh.log +0 -19
  8. package/dist/index.mjs +0 -1834
  9. package/src/common.ts +0 -186
  10. package/src/coupon-bond-guaranteed/aiken-workspace/readme.md +0 -0
  11. package/src/coupon-bond-guaranteed/offchain.ts +0 -3
  12. package/src/coupon-bond-guaranteed/readme.md +0 -3
  13. package/src/escrow/aiken-workspace/aiken.lock +0 -26
  14. package/src/escrow/aiken-workspace/aiken.toml +0 -19
  15. package/src/escrow/aiken-workspace/lib/escrow/types.ak +0 -21
  16. package/src/escrow/aiken-workspace/lib/escrow/validators/escrow.ak +0 -122
  17. package/src/escrow/aiken-workspace/plutus.json +0 -238
  18. package/src/escrow/aiken-workspace/readme.md +0 -55
  19. package/src/escrow/aiken-workspace/validators/escrow.ak +0 -9
  20. package/src/escrow/aiken-workspace/validators/tests/escrow.ak +0 -462
  21. package/src/escrow/index.ts +0 -1
  22. package/src/escrow/offchain.ts +0 -254
  23. package/src/escrow/readme.md +0 -38
  24. package/src/giftcard/aiken-workspace/aiken.lock +0 -26
  25. package/src/giftcard/aiken-workspace/aiken.toml +0 -19
  26. package/src/giftcard/aiken-workspace/plutus.json +0 -138
  27. package/src/giftcard/aiken-workspace/readme.md +0 -55
  28. package/src/giftcard/aiken-workspace/validators/oneshot.ak +0 -173
  29. package/src/giftcard/index.ts +0 -1
  30. package/src/giftcard/offchain.ts +0 -184
  31. package/src/giftcard/readme.md +0 -36
  32. package/src/hello-world/aiken-workspace/README.md +0 -19
  33. package/src/hello-world/aiken-workspace/aiken.lock +0 -15
  34. package/src/hello-world/aiken-workspace/aiken.toml +0 -14
  35. package/src/hello-world/aiken-workspace/contract.md +0 -27
  36. package/src/hello-world/aiken-workspace/plutus.json +0 -69
  37. package/src/hello-world/aiken-workspace/validators/hello_world.ak +0 -24
  38. package/src/hello-world/index.ts +0 -1
  39. package/src/hello-world/offchain.ts +0 -24
  40. package/src/hello-world/readme.md +0 -1
  41. package/src/index.ts +0 -6
  42. package/src/marketplace/aiken-workspace/aiken.lock +0 -26
  43. package/src/marketplace/aiken-workspace/aiken.toml +0 -19
  44. package/src/marketplace/aiken-workspace/lib/marketplace/types.ak +0 -15
  45. package/src/marketplace/aiken-workspace/lib/marketplace/validators/marketplace.ak +0 -52
  46. package/src/marketplace/aiken-workspace/plutus.json +0 -204
  47. package/src/marketplace/aiken-workspace/readme.md +0 -55
  48. package/src/marketplace/aiken-workspace/validators/marketplace.ak +0 -14
  49. package/src/marketplace/aiken-workspace/validators/tests/marketplace.ak +0 -218
  50. package/src/marketplace/index.ts +0 -1
  51. package/src/marketplace/offchain.ts +0 -248
  52. package/src/marketplace/readme.md +0 -45
  53. package/src/payment-splitter/aiken-workspace/aiken.lock +0 -15
  54. package/src/payment-splitter/aiken-workspace/aiken.toml +0 -14
  55. package/src/payment-splitter/aiken-workspace/plutus.json +0 -83
  56. package/src/payment-splitter/aiken-workspace/validators/payment-splitter.ak +0 -329
  57. package/src/payment-splitter/index.ts +0 -1
  58. package/src/payment-splitter/offchain.ts +0 -143
  59. package/src/payment-splitter/readme.md +0 -100
  60. package/src/swap/aiken-workspace/aiken.lock +0 -26
  61. package/src/swap/aiken-workspace/aiken.toml +0 -19
  62. package/src/swap/aiken-workspace/plutus.json +0 -208
  63. package/src/swap/aiken-workspace/readme.md +0 -55
  64. package/src/swap/aiken-workspace/validators/swap.ak +0 -188
  65. package/src/swap/index.ts +0 -1
  66. package/src/swap/offchain.ts +0 -139
  67. package/src/swap/readme.md +0 -35
  68. package/src/vesting/aiken-workspace/README.md +0 -24
  69. package/src/vesting/aiken-workspace/aiken.lock +0 -26
  70. package/src/vesting/aiken-workspace/aiken.toml +0 -19
  71. package/src/vesting/aiken-workspace/lib/vesting/types.ak +0 -8
  72. package/src/vesting/aiken-workspace/lib/vesting/validators/vesting.ak +0 -19
  73. package/src/vesting/aiken-workspace/plutus.json +0 -67
  74. package/src/vesting/aiken-workspace/validators/tests/vesting.ak +0 -108
  75. package/src/vesting/aiken-workspace/validators/vesting.ak +0 -9
  76. package/src/vesting/index.ts +0 -1
  77. package/src/vesting/offchain.ts +0 -117
  78. package/src/vesting/readme.md +0 -36
  79. package/tsconfig.json +0 -5
@@ -1,9 +0,0 @@
1
- use aiken/transaction.{ScriptContext}
2
- use escrow/types.{EscrowDatum, EscrowRedeemer}
3
- use escrow/validators/escrow.{escrow_logic}
4
-
5
- validator {
6
- fn escrow(datum: EscrowDatum, redeemer: EscrowRedeemer, ctx: ScriptContext) {
7
- escrow_logic(datum, redeemer, ctx)
8
- }
9
- }
@@ -1,462 +0,0 @@
1
- use aiken/transaction.{ScriptContext, Spend, Transaction}
2
- use aiken/transaction/credential.{Address}
3
- use aiken/transaction/value.{add, from_asset, from_lovelace}
4
- use escrow/types.{
5
- ActiveEscrow, CancelTrade, CompleteTrade, EscrowDatum, Initiation, MValue,
6
- RecipientDeposit,
7
- }
8
- use escrow/validators/escrow.{escrow_logic}
9
- use sidan_placeholder/address.{mock_pub_key_address, mock_script_address}
10
- use sidan_placeholder/builder.{
11
- complete, new_tx_tester, required_signer_hash, tx_in, tx_in_inline_datum,
12
- tx_out, tx_out_inline_datum,
13
- }
14
- use sidan_placeholder/key_hex.{mock_pub_key_hex}
15
- use sidan_placeholder/output_reference.{mock_tx_hash, mock_utxo_ref}
16
-
17
- type CancelTestCase {
18
- is_at_initiation: Bool,
19
- is_initiator_received_value: Bool,
20
- is_recipient_received_value: Bool,
21
- is_initiator_signed: Bool,
22
- is_recipient_signed: Bool,
23
- }
24
-
25
- fn test_lovelace() -> MValue {
26
- [Pair("", [Pair("", 2_000_000)])]
27
- }
28
-
29
- fn test_value() -> MValue {
30
- [Pair("test", [Pair("test", 1)])]
31
- }
32
-
33
- fn initiator_address() -> Address {
34
- mock_pub_key_address(0, None)
35
- }
36
-
37
- fn recipient_address() -> Address {
38
- mock_pub_key_address(1, None)
39
- }
40
-
41
- fn initiation_datum() -> EscrowDatum {
42
- let initiator_assets: MValue = test_lovelace()
43
- Initiation { initiator: initiator_address(), initiator_assets }
44
- }
45
-
46
- fn active_datum(recipient: Address, recipient_assets: MValue) -> EscrowDatum {
47
- ActiveEscrow {
48
- initiator: initiator_address(),
49
- initiator_assets: test_lovelace(),
50
- recipient,
51
- recipient_assets,
52
- }
53
- }
54
-
55
- fn get_cancel_test_tx(test_case: CancelTestCase) -> Transaction {
56
- let CancelTestCase {
57
- is_at_initiation,
58
- is_initiator_received_value,
59
- is_recipient_received_value,
60
- is_initiator_signed,
61
- is_recipient_signed,
62
- } = test_case
63
-
64
- let initiator_output_value =
65
- if is_initiator_received_value {
66
- from_lovelace(2_000_000)
67
- } else {
68
- from_asset("test", "test", 1)
69
- }
70
- let recipient_output_value =
71
- if is_recipient_received_value {
72
- from_asset("test", "test", 1)
73
- } else {
74
- from_lovelace(2_000_000)
75
- }
76
-
77
- new_tx_tester()
78
- |> tx_in(
79
- True,
80
- mock_tx_hash(0),
81
- 1,
82
- from_lovelace(2_000_000),
83
- mock_script_address(0, None),
84
- )
85
- |> tx_in_inline_datum(is_at_initiation, initiation_datum())
86
- |> tx_in_inline_datum(
87
- !is_at_initiation,
88
- active_datum(
89
- mock_pub_key_address(1, None),
90
- [Pair("test", [Pair("test", 1)])],
91
- ),
92
- )
93
- |> tx_out(True, initiator_address(), initiator_output_value)
94
- |> tx_out(True, recipient_address(), recipient_output_value)
95
- |> required_signer_hash(is_initiator_signed, mock_pub_key_hex(0))
96
- |> required_signer_hash(is_recipient_signed, mock_pub_key_hex(1))
97
- |> complete()
98
- }
99
-
100
- test success_cancel() {
101
- let output_reference = mock_utxo_ref(0, 1)
102
- let unused_mock_datum = initiation_datum()
103
- let redeemer = CancelTrade
104
- let test_case =
105
- CancelTestCase {
106
- is_at_initiation: True,
107
- is_initiator_received_value: True,
108
- is_recipient_received_value: True,
109
- is_initiator_signed: True,
110
- is_recipient_signed: True,
111
- }
112
-
113
- let tx = get_cancel_test_tx(test_case)
114
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
115
- escrow_logic(unused_mock_datum, redeemer, ctx)
116
- }
117
-
118
- test success_cancel_at_initiation() {
119
- let output_reference = mock_utxo_ref(0, 1)
120
- let unused_mock_datum = initiation_datum()
121
- let redeemer = CancelTrade
122
- let test_case =
123
- CancelTestCase {
124
- is_at_initiation: True,
125
- is_initiator_received_value: True,
126
- is_recipient_received_value: True,
127
- is_initiator_signed: True,
128
- is_recipient_signed: False,
129
- }
130
-
131
- let tx = get_cancel_test_tx(test_case)
132
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
133
- escrow_logic(unused_mock_datum, redeemer, ctx)
134
- }
135
-
136
- test success_cancel_at_active_with_initiator_signed() {
137
- let output_reference = mock_utxo_ref(0, 1)
138
- let unused_mock_datum = initiation_datum()
139
- let redeemer = CancelTrade
140
- let test_case =
141
- CancelTestCase {
142
- is_at_initiation: False,
143
- is_initiator_received_value: True,
144
- is_recipient_received_value: True,
145
- is_initiator_signed: True,
146
- is_recipient_signed: False,
147
- }
148
-
149
- let tx = get_cancel_test_tx(test_case)
150
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
151
- escrow_logic(unused_mock_datum, redeemer, ctx)
152
- }
153
-
154
- test success_cancel_at_active_with_recipient_signed() {
155
- let output_reference = mock_utxo_ref(0, 1)
156
- let unused_mock_datum = initiation_datum()
157
- let redeemer = CancelTrade
158
- let test_case =
159
- CancelTestCase {
160
- is_at_initiation: False,
161
- is_initiator_received_value: True,
162
- is_recipient_received_value: True,
163
- is_initiator_signed: False,
164
- is_recipient_signed: True,
165
- }
166
-
167
- let tx = get_cancel_test_tx(test_case)
168
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
169
- escrow_logic(unused_mock_datum, redeemer, ctx)
170
- }
171
-
172
- test fail_cancel_at_initiation_without_signature() {
173
- let output_reference = mock_utxo_ref(0, 1)
174
- let unused_mock_datum = initiation_datum()
175
- let redeemer = CancelTrade
176
- let test_case =
177
- CancelTestCase {
178
- is_at_initiation: True,
179
- is_initiator_received_value: True,
180
- is_recipient_received_value: True,
181
- is_initiator_signed: False,
182
- is_recipient_signed: True,
183
- }
184
-
185
- let tx = get_cancel_test_tx(test_case)
186
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
187
- !escrow_logic(unused_mock_datum, redeemer, ctx)
188
- }
189
-
190
- test fail_cancel_without_signature() {
191
- let output_reference = mock_utxo_ref(0, 1)
192
- let unused_mock_datum = initiation_datum()
193
- let redeemer = CancelTrade
194
- let test_case =
195
- CancelTestCase {
196
- is_at_initiation: False,
197
- is_initiator_received_value: True,
198
- is_recipient_received_value: True,
199
- is_initiator_signed: False,
200
- is_recipient_signed: False,
201
- }
202
-
203
- let tx = get_cancel_test_tx(test_case)
204
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
205
- !escrow_logic(unused_mock_datum, redeemer, ctx)
206
- }
207
-
208
- test fail_cancel_without_initiator_value_returned() {
209
- let output_reference = mock_utxo_ref(0, 1)
210
- let unused_mock_datum = initiation_datum()
211
- let redeemer = CancelTrade
212
- let test_case =
213
- CancelTestCase {
214
- is_at_initiation: False,
215
- is_initiator_received_value: False,
216
- is_recipient_received_value: True,
217
- is_initiator_signed: True,
218
- is_recipient_signed: True,
219
- }
220
-
221
- let tx = get_cancel_test_tx(test_case)
222
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
223
- !escrow_logic(unused_mock_datum, redeemer, ctx)
224
- }
225
-
226
- test fail_cancel_without_recipient_value_returned() {
227
- let output_reference = mock_utxo_ref(0, 1)
228
- let unused_mock_datum = initiation_datum()
229
- let redeemer = CancelTrade
230
- let test_case =
231
- CancelTestCase {
232
- is_at_initiation: False,
233
- is_initiator_received_value: True,
234
- is_recipient_received_value: False,
235
- is_initiator_signed: True,
236
- is_recipient_signed: True,
237
- }
238
-
239
- let tx = get_cancel_test_tx(test_case)
240
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
241
- !escrow_logic(unused_mock_datum, redeemer, ctx)
242
- }
243
-
244
- type RecipientDepositTestCase {
245
- is_datum_updated: Bool,
246
- is_value_deposited: Bool,
247
- }
248
-
249
- fn get_deposit_test_tx(test_case: RecipientDepositTestCase) -> Transaction {
250
- let RecipientDepositTestCase { is_datum_updated, is_value_deposited } =
251
- test_case
252
- let input_value = from_lovelace(2_000_000)
253
- let output_value =
254
- input_value
255
- |> if is_value_deposited {
256
- add(_, "test", "test", 1)
257
- } else {
258
- add(_, "", "", 1_000_000)
259
- }
260
-
261
- new_tx_tester()
262
- |> tx_in(True, mock_tx_hash(0), 1, input_value, mock_script_address(0, None))
263
- |> tx_in_inline_datum(True, initiation_datum())
264
- |> tx_out(True, mock_script_address(0, None), output_value)
265
- |> tx_out_inline_datum(
266
- is_datum_updated,
267
- active_datum(
268
- mock_pub_key_address(1, None),
269
- [Pair("test", [Pair("test", 1)])],
270
- ),
271
- )
272
- |> tx_out_inline_datum(!is_datum_updated, initiation_datum())
273
- |> complete()
274
- }
275
-
276
- test success_deposit() {
277
- let output_reference = mock_utxo_ref(0, 1)
278
- let unused_mock_datum = initiation_datum()
279
- let redeemer =
280
- RecipientDeposit {
281
- recipient: mock_pub_key_address(1, None),
282
- recipient_assets: test_value(),
283
- }
284
- let test_case =
285
- RecipientDepositTestCase {
286
- is_datum_updated: True,
287
- is_value_deposited: True,
288
- }
289
-
290
- let tx = get_deposit_test_tx(test_case)
291
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
292
- escrow_logic(unused_mock_datum, redeemer, ctx)
293
- }
294
-
295
- test fail_deposit_without_updating_datum() {
296
- let output_reference = mock_utxo_ref(0, 1)
297
- let unused_mock_datum = initiation_datum()
298
- let redeemer =
299
- RecipientDeposit {
300
- recipient: mock_pub_key_address(1, None),
301
- recipient_assets: test_value(),
302
- }
303
- let test_case =
304
- RecipientDepositTestCase {
305
- is_datum_updated: False,
306
- is_value_deposited: True,
307
- }
308
-
309
- let tx = get_deposit_test_tx(test_case)
310
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
311
- !escrow_logic(unused_mock_datum, redeemer, ctx)
312
- }
313
-
314
- test fail_deposit_without_depositing_value() {
315
- let output_reference = mock_utxo_ref(0, 1)
316
- let unused_mock_datum = initiation_datum()
317
- let redeemer =
318
- RecipientDeposit {
319
- recipient: mock_pub_key_address(1, None),
320
- recipient_assets: test_value(),
321
- }
322
- let test_case =
323
- RecipientDepositTestCase {
324
- is_datum_updated: True,
325
- is_value_deposited: False,
326
- }
327
-
328
- let tx = get_deposit_test_tx(test_case)
329
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
330
- !escrow_logic(unused_mock_datum, redeemer, ctx)
331
- }
332
-
333
- type CompleteTestCase {
334
- is_initiator_signed: Bool,
335
- is_initiator_received_value: Bool,
336
- is_recipient_signed: Bool,
337
- is_recipient_received_value: Bool,
338
- }
339
-
340
- fn get_complete_test_tx(test_case: CompleteTestCase) -> Transaction {
341
- let CompleteTestCase {
342
- is_initiator_signed,
343
- is_initiator_received_value,
344
- is_recipient_signed,
345
- is_recipient_received_value,
346
- } = test_case
347
- let input_datum =
348
- ActiveEscrow {
349
- initiator: mock_pub_key_address(0, None),
350
- initiator_assets: test_lovelace(),
351
- recipient: mock_pub_key_address(1, None),
352
- recipient_assets: test_value(),
353
- }
354
-
355
- new_tx_tester()
356
- |> required_signer_hash(is_initiator_signed, mock_pub_key_hex(0))
357
- |> required_signer_hash(is_recipient_signed, mock_pub_key_hex(1))
358
- |> tx_in(
359
- True,
360
- mock_tx_hash(0),
361
- 1,
362
- from_lovelace(2_000_000) |> add("test", "test", 1),
363
- mock_script_address(0, None),
364
- )
365
- |> tx_in_inline_datum(True, input_datum)
366
- |> tx_out(
367
- is_initiator_received_value,
368
- mock_pub_key_address(0, None),
369
- from_asset("test", "test", 1),
370
- )
371
- |> tx_out(
372
- is_recipient_received_value,
373
- mock_pub_key_address(1, None),
374
- from_lovelace(2_000_000),
375
- )
376
- |> complete()
377
- }
378
-
379
- test success_complete() {
380
- let output_reference = mock_utxo_ref(0, 1)
381
- let unused_mock_datum = initiation_datum()
382
- let redeemer = CompleteTrade
383
- let test_case =
384
- CompleteTestCase {
385
- is_initiator_signed: True,
386
- is_initiator_received_value: True,
387
- is_recipient_signed: True,
388
- is_recipient_received_value: True,
389
- }
390
-
391
- let tx = get_complete_test_tx(test_case)
392
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
393
- escrow_logic(unused_mock_datum, redeemer, ctx)
394
- }
395
-
396
- test fail_complete_without_initiator_signed() {
397
- let output_reference = mock_utxo_ref(0, 1)
398
- let unused_mock_datum = initiation_datum()
399
- let redeemer = CompleteTrade
400
- let test_case =
401
- CompleteTestCase {
402
- is_initiator_signed: False,
403
- is_initiator_received_value: True,
404
- is_recipient_signed: True,
405
- is_recipient_received_value: True,
406
- }
407
-
408
- let tx = get_complete_test_tx(test_case)
409
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
410
- !escrow_logic(unused_mock_datum, redeemer, ctx)
411
- }
412
-
413
- test fail_complete_without_value_sent_to_initiator() {
414
- let output_reference = mock_utxo_ref(0, 1)
415
- let unused_mock_datum = initiation_datum()
416
- let redeemer = CompleteTrade
417
- let test_case =
418
- CompleteTestCase {
419
- is_initiator_signed: True,
420
- is_initiator_received_value: False,
421
- is_recipient_signed: True,
422
- is_recipient_received_value: True,
423
- }
424
-
425
- let tx = get_complete_test_tx(test_case)
426
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
427
- !escrow_logic(unused_mock_datum, redeemer, ctx)
428
- }
429
-
430
- test fail_complete_without_recipeint_signed() {
431
- let output_reference = mock_utxo_ref(0, 1)
432
- let unused_mock_datum = initiation_datum()
433
- let redeemer = CompleteTrade
434
- let test_case =
435
- CompleteTestCase {
436
- is_initiator_signed: True,
437
- is_initiator_received_value: True,
438
- is_recipient_signed: False,
439
- is_recipient_received_value: True,
440
- }
441
-
442
- let tx = get_complete_test_tx(test_case)
443
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
444
- !escrow_logic(unused_mock_datum, redeemer, ctx)
445
- }
446
-
447
- test fail_complete_without_value_sent_to_recipient() {
448
- let output_reference = mock_utxo_ref(0, 1)
449
- let unused_mock_datum = initiation_datum()
450
- let redeemer = CompleteTrade
451
- let test_case =
452
- CompleteTestCase {
453
- is_initiator_signed: True,
454
- is_initiator_received_value: True,
455
- is_recipient_signed: True,
456
- is_recipient_received_value: False,
457
- }
458
-
459
- let tx = get_complete_test_tx(test_case)
460
- let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
461
- !escrow_logic(unused_mock_datum, redeemer, ctx)
462
- }
@@ -1 +0,0 @@
1
- export * from './offchain';