@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.
- package/dist/index.cjs +37 -0
- package/dist/{index.d.mts → index.d.cts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -1803
- package/package.json +30 -14
- package/.turbo/turbo-build$colon$docs.log +0 -8
- package/.turbo/turbo-build$colon$mesh.log +0 -19
- package/dist/index.mjs +0 -1834
- package/src/common.ts +0 -186
- package/src/coupon-bond-guaranteed/aiken-workspace/readme.md +0 -0
- package/src/coupon-bond-guaranteed/offchain.ts +0 -3
- package/src/coupon-bond-guaranteed/readme.md +0 -3
- package/src/escrow/aiken-workspace/aiken.lock +0 -26
- package/src/escrow/aiken-workspace/aiken.toml +0 -19
- package/src/escrow/aiken-workspace/lib/escrow/types.ak +0 -21
- package/src/escrow/aiken-workspace/lib/escrow/validators/escrow.ak +0 -122
- package/src/escrow/aiken-workspace/plutus.json +0 -238
- package/src/escrow/aiken-workspace/readme.md +0 -55
- package/src/escrow/aiken-workspace/validators/escrow.ak +0 -9
- package/src/escrow/aiken-workspace/validators/tests/escrow.ak +0 -462
- package/src/escrow/index.ts +0 -1
- package/src/escrow/offchain.ts +0 -254
- package/src/escrow/readme.md +0 -38
- package/src/giftcard/aiken-workspace/aiken.lock +0 -26
- package/src/giftcard/aiken-workspace/aiken.toml +0 -19
- package/src/giftcard/aiken-workspace/plutus.json +0 -138
- package/src/giftcard/aiken-workspace/readme.md +0 -55
- package/src/giftcard/aiken-workspace/validators/oneshot.ak +0 -173
- package/src/giftcard/index.ts +0 -1
- package/src/giftcard/offchain.ts +0 -184
- package/src/giftcard/readme.md +0 -36
- package/src/hello-world/aiken-workspace/README.md +0 -19
- package/src/hello-world/aiken-workspace/aiken.lock +0 -15
- package/src/hello-world/aiken-workspace/aiken.toml +0 -14
- package/src/hello-world/aiken-workspace/contract.md +0 -27
- package/src/hello-world/aiken-workspace/plutus.json +0 -69
- package/src/hello-world/aiken-workspace/validators/hello_world.ak +0 -24
- package/src/hello-world/index.ts +0 -1
- package/src/hello-world/offchain.ts +0 -24
- package/src/hello-world/readme.md +0 -1
- package/src/index.ts +0 -6
- package/src/marketplace/aiken-workspace/aiken.lock +0 -26
- package/src/marketplace/aiken-workspace/aiken.toml +0 -19
- package/src/marketplace/aiken-workspace/lib/marketplace/types.ak +0 -15
- package/src/marketplace/aiken-workspace/lib/marketplace/validators/marketplace.ak +0 -52
- package/src/marketplace/aiken-workspace/plutus.json +0 -204
- package/src/marketplace/aiken-workspace/readme.md +0 -55
- package/src/marketplace/aiken-workspace/validators/marketplace.ak +0 -14
- package/src/marketplace/aiken-workspace/validators/tests/marketplace.ak +0 -218
- package/src/marketplace/index.ts +0 -1
- package/src/marketplace/offchain.ts +0 -248
- package/src/marketplace/readme.md +0 -45
- package/src/payment-splitter/aiken-workspace/aiken.lock +0 -15
- package/src/payment-splitter/aiken-workspace/aiken.toml +0 -14
- package/src/payment-splitter/aiken-workspace/plutus.json +0 -83
- package/src/payment-splitter/aiken-workspace/validators/payment-splitter.ak +0 -329
- package/src/payment-splitter/index.ts +0 -1
- package/src/payment-splitter/offchain.ts +0 -143
- package/src/payment-splitter/readme.md +0 -100
- package/src/swap/aiken-workspace/aiken.lock +0 -26
- package/src/swap/aiken-workspace/aiken.toml +0 -19
- package/src/swap/aiken-workspace/plutus.json +0 -208
- package/src/swap/aiken-workspace/readme.md +0 -55
- package/src/swap/aiken-workspace/validators/swap.ak +0 -188
- package/src/swap/index.ts +0 -1
- package/src/swap/offchain.ts +0 -139
- package/src/swap/readme.md +0 -35
- package/src/vesting/aiken-workspace/README.md +0 -24
- package/src/vesting/aiken-workspace/aiken.lock +0 -26
- package/src/vesting/aiken-workspace/aiken.toml +0 -19
- package/src/vesting/aiken-workspace/lib/vesting/types.ak +0 -8
- package/src/vesting/aiken-workspace/lib/vesting/validators/vesting.ak +0 -19
- package/src/vesting/aiken-workspace/plutus.json +0 -67
- package/src/vesting/aiken-workspace/validators/tests/vesting.ak +0 -108
- package/src/vesting/aiken-workspace/validators/vesting.ak +0 -9
- package/src/vesting/index.ts +0 -1
- package/src/vesting/offchain.ts +0 -117
- package/src/vesting/readme.md +0 -36
- package/tsconfig.json +0 -5
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"preamble": {
|
|
3
|
-
"title": "meshjs/marketplace",
|
|
4
|
-
"description": "Aiken contracts for project 'meshjs/marketplace'",
|
|
5
|
-
"version": "0.0.0",
|
|
6
|
-
"plutusVersion": "v2",
|
|
7
|
-
"compiler": {
|
|
8
|
-
"name": "Aiken",
|
|
9
|
-
"version": "v1.0.29-alpha+unknown"
|
|
10
|
-
},
|
|
11
|
-
"license": "Apache-2.0"
|
|
12
|
-
},
|
|
13
|
-
"validators": [
|
|
14
|
-
{
|
|
15
|
-
"title": "marketplace.marketplace",
|
|
16
|
-
"datum": {
|
|
17
|
-
"title": "datum",
|
|
18
|
-
"schema": {
|
|
19
|
-
"$ref": "#/definitions/marketplace~1types~1MarketplaceDatum"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"redeemer": {
|
|
23
|
-
"title": "redeemer",
|
|
24
|
-
"schema": {
|
|
25
|
-
"$ref": "#/definitions/marketplace~1types~1MarketplaceRedeemer"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"parameters": [
|
|
29
|
-
{
|
|
30
|
-
"title": "owner",
|
|
31
|
-
"schema": {
|
|
32
|
-
"$ref": "#/definitions/aiken~1transaction~1credential~1Address"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"title": "fee_percentage_basis_point",
|
|
37
|
-
"schema": {
|
|
38
|
-
"$ref": "#/definitions/Int"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
"compiledCode": "59082f01000032323232323232223223232322322533300b3232323232323232325333014300e30153754002264a66602a6020602c6ea80344c94ccc058c044c05cdd50008991919299980c99299980e8008a501533301d302000114a22940cc88c8cc00400400c894ccc08000452f5c026464a66603e66ebcc048c084dd5180898109baa00200513302300233004004001133004004001302400230220013758601860366ea8c030c06cdd50079806180d9baa300b301b37540062a6660320022004294052819803998049bac3008301a3754601660346ea803805cc018cdc199b82375a601460346ea805005520a09c0133006330083758600e60326ea8c028c064dd50069805180c9baa0133005337006eb4c024c064dd50099998059bab300930193754601260326ea8005220100488100301b301837540022c64660020026eb0c024c060dd51804980c1baa00c22533301a00114c0103d87a80001323253330193375e601860366ea80080144c038cc0740092f5c0266008008002603c0046038002264a66602c6022602e6ea80044cc88c8cc00400400c894ccc074004528099299980d99b8f375c604000400829444cc00c00c004c080004dd6180d980e180e180e180e180e180e180e180e180c1baa3009301837540186eb8c06cc060dd50008b19299980b1808980b9baa0011300b3301a301b3018375400297ae014c0103d87a80003008301737546010602e6ea8044c064c058dd50008a503005301537540124a666026601c002297adef6c6013232330010014bd6f7b63011299980c80089980d19bb04c01014000374c00697adef6c60132323232533301a3372091010000213301e337609801014000374c00e00a2a66603466e3d2210000213301e337609801014000374c00e00626603c66ec0dd48011ba600133006006003375660360066eb8c064008c074008c06c004c8cc0040052f5bded8c044a66603000226603266ec13001014000375000697adef6c6013232323253330193372091010000213301d337609801014000375000e00a2a66603266e3d2210000213301d337609801014000375000e00626603a66ec0dd48011ba800133006006003375a60340066eb8c060008c070008c06800488c8cc004004c8cc00400400c894ccc06400452f5c0264666444646600200200644a66603e0022006264660426e9ccc084dd480319810980f00099810980f800a5eb80cc00c00cc08c008c084004dd7180c0009bab301900133003003301d002301b00122533301800114a2264a66602c6466e24dd698038009998058031bae300a001375c60120026eb0c06c0084cc00c00c004528180d8009180b180b980b80091191980080080191299980b0008a5eb7bdb1804cc894ccc054cdd79804180b9baa0020051323330010010023756601060306ea800c8894ccc06c00840044c8ccc010010c07c00ccc88c8cc004004014894ccc0800044cc084cdd81ba9004374c00697adef6c6013232323253330213372001000426604a66ec0dd48041ba6007005153330213371e010004264a666044603a60466ea80044cc098cdd81ba9009302730243754002008200864a666044a66604a00229445280a6103d87a80001301733026374c00297ae03233300100100800222253330270021001132333004004302b0033322323300100100522533302c00113302d337606ea4010dd4001a5eb7bdb1804c8c8c8c94ccc0b4cdc800400109981899bb037520106ea001c01454ccc0b4cdc78040010992999817181498179baa001133032337606ea4024c0ccc0c0dd5000802080219299981718148008a60103d87a80001302333032375000297ae03370000e00226606266ec0dd48011ba800133006006003375a605c0066eb8c0b0008c0c0008c0b8004dd718130009bad30270013029002133025337606ea4008dd3000998030030019bab3022003375c6040004604800460440026eb8c068004dd5980d800980e8010800980c00099801001180c8009180a180a80091809800911192999808180518089baa0011480004dd6980a98091baa001325333010300a301137540022980103d87a8000132330010013756602c60266ea8008894ccc054004530103d87a80001323232325333016337220100042a66602c66e3c0200084c02ccc068dd4000a5eb80530103d87a8000133006006003375a602e0066eb8c054008c064008c05c004c8cc004004010894ccc0500045300103d87a80001323232325333015337220100042a66602a66e3c0200084c028cc064dd3000a5eb80530103d87a80001330060060033756602c0066eb8c050008c060008c058004dd2a400029309b2b19299980518028008a99980698061baa00214985854ccc028c01000454ccc034c030dd50010a4c2c2c60146ea8004c94ccc020c00cc024dd5002099191919191919192999809980b00109924ca666020601660226ea801c4c8c8c8c94ccc05cc0680084c8c926325333016301100113232533301b301e002132498c94ccc064c0500044c8c94ccc078c0840084c926301400116301f001301b37540042a66603260260022646464646464a666044604a0042930b1bad30230013023002375a604200260420046eb4c07c004c06cdd50010b180c9baa00116301c001301837540062a66602c60200022a66603260306ea800c526161630163754004601a0062c60300026030004602c00260246ea801c5858dd7180a000980a0011bae30120013012002375a60200026020004601c00260146ea8010588c94ccc024c0100044c8c94ccc038c04400852616375c601e00260166ea800854ccc024c00c0044c8c94ccc038c04400852616375c601e00260166ea800858c024dd50009b8748008dc3a40006eb40055cd2ab9d5573caae7d5d02ba157441",
|
|
43
|
-
"hash": "cd144c1e18d8e44dfeacb018a2795d17d7c30574a427eb2aa2dbc87c"
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
"definitions": {
|
|
47
|
-
"ByteArray": {
|
|
48
|
-
"dataType": "bytes"
|
|
49
|
-
},
|
|
50
|
-
"Int": {
|
|
51
|
-
"dataType": "integer"
|
|
52
|
-
},
|
|
53
|
-
"Option$aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential": {
|
|
54
|
-
"title": "Optional",
|
|
55
|
-
"anyOf": [
|
|
56
|
-
{
|
|
57
|
-
"title": "Some",
|
|
58
|
-
"description": "An optional value.",
|
|
59
|
-
"dataType": "constructor",
|
|
60
|
-
"index": 0,
|
|
61
|
-
"fields": [
|
|
62
|
-
{
|
|
63
|
-
"$ref": "#/definitions/aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"title": "None",
|
|
69
|
-
"description": "Nothing.",
|
|
70
|
-
"dataType": "constructor",
|
|
71
|
-
"index": 1,
|
|
72
|
-
"fields": []
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
},
|
|
76
|
-
"aiken/transaction/credential/Address": {
|
|
77
|
-
"title": "Address",
|
|
78
|
-
"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).",
|
|
79
|
-
"anyOf": [
|
|
80
|
-
{
|
|
81
|
-
"title": "Address",
|
|
82
|
-
"dataType": "constructor",
|
|
83
|
-
"index": 0,
|
|
84
|
-
"fields": [
|
|
85
|
-
{
|
|
86
|
-
"title": "payment_credential",
|
|
87
|
-
"$ref": "#/definitions/aiken~1transaction~1credential~1Credential"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"title": "stake_credential",
|
|
91
|
-
"$ref": "#/definitions/Option$aiken~1transaction~1credential~1Referenced$aiken~1transaction~1credential~1Credential"
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
"aiken/transaction/credential/Credential": {
|
|
98
|
-
"title": "Credential",
|
|
99
|
-
"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).",
|
|
100
|
-
"anyOf": [
|
|
101
|
-
{
|
|
102
|
-
"title": "VerificationKeyCredential",
|
|
103
|
-
"dataType": "constructor",
|
|
104
|
-
"index": 0,
|
|
105
|
-
"fields": [
|
|
106
|
-
{
|
|
107
|
-
"$ref": "#/definitions/ByteArray"
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
"title": "ScriptCredential",
|
|
113
|
-
"dataType": "constructor",
|
|
114
|
-
"index": 1,
|
|
115
|
-
"fields": [
|
|
116
|
-
{
|
|
117
|
-
"$ref": "#/definitions/ByteArray"
|
|
118
|
-
}
|
|
119
|
-
]
|
|
120
|
-
}
|
|
121
|
-
]
|
|
122
|
-
},
|
|
123
|
-
"aiken/transaction/credential/Referenced$aiken/transaction/credential/Credential": {
|
|
124
|
-
"title": "Referenced",
|
|
125
|
-
"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.",
|
|
126
|
-
"anyOf": [
|
|
127
|
-
{
|
|
128
|
-
"title": "Inline",
|
|
129
|
-
"dataType": "constructor",
|
|
130
|
-
"index": 0,
|
|
131
|
-
"fields": [
|
|
132
|
-
{
|
|
133
|
-
"$ref": "#/definitions/aiken~1transaction~1credential~1Credential"
|
|
134
|
-
}
|
|
135
|
-
]
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
"title": "Pointer",
|
|
139
|
-
"dataType": "constructor",
|
|
140
|
-
"index": 1,
|
|
141
|
-
"fields": [
|
|
142
|
-
{
|
|
143
|
-
"title": "slot_number",
|
|
144
|
-
"$ref": "#/definitions/Int"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
"title": "transaction_index",
|
|
148
|
-
"$ref": "#/definitions/Int"
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
"title": "certificate_index",
|
|
152
|
-
"$ref": "#/definitions/Int"
|
|
153
|
-
}
|
|
154
|
-
]
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
-
},
|
|
158
|
-
"marketplace/types/MarketplaceDatum": {
|
|
159
|
-
"title": "MarketplaceDatum",
|
|
160
|
-
"anyOf": [
|
|
161
|
-
{
|
|
162
|
-
"title": "MarketplaceDatum",
|
|
163
|
-
"dataType": "constructor",
|
|
164
|
-
"index": 0,
|
|
165
|
-
"fields": [
|
|
166
|
-
{
|
|
167
|
-
"title": "seller",
|
|
168
|
-
"$ref": "#/definitions/aiken~1transaction~1credential~1Address"
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
"title": "price",
|
|
172
|
-
"$ref": "#/definitions/Int"
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
"title": "policy",
|
|
176
|
-
"$ref": "#/definitions/ByteArray"
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
"title": "tokenName",
|
|
180
|
-
"$ref": "#/definitions/ByteArray"
|
|
181
|
-
}
|
|
182
|
-
]
|
|
183
|
-
}
|
|
184
|
-
]
|
|
185
|
-
},
|
|
186
|
-
"marketplace/types/MarketplaceRedeemer": {
|
|
187
|
-
"title": "MarketplaceRedeemer",
|
|
188
|
-
"anyOf": [
|
|
189
|
-
{
|
|
190
|
-
"title": "Buy",
|
|
191
|
-
"dataType": "constructor",
|
|
192
|
-
"index": 0,
|
|
193
|
-
"fields": []
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
"title": "Close",
|
|
197
|
-
"dataType": "constructor",
|
|
198
|
-
"index": 1,
|
|
199
|
-
"fields": []
|
|
200
|
-
}
|
|
201
|
-
]
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# marketplace
|
|
2
|
-
|
|
3
|
-
Write validators in the `validators` folder, and supporting functions in the `lib` folder using `.ak` as a file extension.
|
|
4
|
-
|
|
5
|
-
For example, as `validators/always_true.ak`
|
|
6
|
-
|
|
7
|
-
```gleam
|
|
8
|
-
validator {
|
|
9
|
-
fn spend(_datum: Data, _redeemer: Data, _context: Data) -> Bool {
|
|
10
|
-
True
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Building
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
aiken build
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Testing
|
|
22
|
-
|
|
23
|
-
You can write tests in any module using the `test` keyword. For example:
|
|
24
|
-
|
|
25
|
-
```gleam
|
|
26
|
-
test foo() {
|
|
27
|
-
1 + 1 == 2
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
To run all tests, simply do:
|
|
32
|
-
|
|
33
|
-
```sh
|
|
34
|
-
aiken check
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
To run only tests matching the string `foo`, do:
|
|
38
|
-
|
|
39
|
-
```sh
|
|
40
|
-
aiken check -m foo
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Documentation
|
|
44
|
-
|
|
45
|
-
If you're writing a library, you might want to generate an HTML documentation for it.
|
|
46
|
-
|
|
47
|
-
Use:
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
aiken docs
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Resources
|
|
54
|
-
|
|
55
|
-
Find more on the [Aiken's user manual](https://aiken-lang.org).
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
use aiken/transaction.{ScriptContext}
|
|
2
|
-
use aiken/transaction/credential.{Address}
|
|
3
|
-
use marketplace/types.{MarketplaceDatum, MarketplaceRedeemer}
|
|
4
|
-
use marketplace/validators/marketplace.{marketplace_logic}
|
|
5
|
-
|
|
6
|
-
validator(owner: Address, fee_percentage_basis_point: Int) {
|
|
7
|
-
fn marketplace(
|
|
8
|
-
datum: MarketplaceDatum,
|
|
9
|
-
redeemer: MarketplaceRedeemer,
|
|
10
|
-
ctx: ScriptContext,
|
|
11
|
-
) {
|
|
12
|
-
marketplace_logic(owner, fee_percentage_basis_point, datum, redeemer, ctx)
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
use aiken/transaction.{InlineDatum, Input, ScriptContext, Spend, Transaction}
|
|
2
|
-
use aiken/transaction/value.{add, from_lovelace}
|
|
3
|
-
use marketplace/types.{Buy, Close, MarketplaceDatum}
|
|
4
|
-
use marketplace/validators/marketplace.{marketplace_logic}
|
|
5
|
-
use sidan_placeholder/address.{mock_pub_key_address, mock_script_address}
|
|
6
|
-
use sidan_placeholder/builder.{
|
|
7
|
-
complete, new_tx_tester, required_signer_hash, tx_in, tx_in_inline_datum,
|
|
8
|
-
tx_out,
|
|
9
|
-
}
|
|
10
|
-
use sidan_placeholder/key_hex.{mock_policy_id, mock_pub_key_hex}
|
|
11
|
-
use sidan_placeholder/output_reference.{mock_tx_hash, mock_utxo_ref}
|
|
12
|
-
use sidan_placeholder/outputs.{mock_script_output}
|
|
13
|
-
use sidan_placeholder/transaction.{add_input} as sidan_tx
|
|
14
|
-
|
|
15
|
-
type CloseTestCase {
|
|
16
|
-
is_seller_signed: Bool,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
fn mock_datum() -> MarketplaceDatum {
|
|
20
|
-
MarketplaceDatum {
|
|
21
|
-
seller: mock_pub_key_address(1, None),
|
|
22
|
-
price: 200_000_000,
|
|
23
|
-
policy: mock_policy_id(0),
|
|
24
|
-
tokenName: "Test Token",
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
fn get_close_test_tx(test_case: CloseTestCase) -> Transaction {
|
|
29
|
-
let CloseTestCase { is_seller_signed } = test_case
|
|
30
|
-
|
|
31
|
-
new_tx_tester()
|
|
32
|
-
|> tx_in(
|
|
33
|
-
True,
|
|
34
|
-
mock_tx_hash(0),
|
|
35
|
-
1,
|
|
36
|
-
from_lovelace(2_000_000),
|
|
37
|
-
mock_script_address(0, None),
|
|
38
|
-
)
|
|
39
|
-
|> tx_in_inline_datum(True, mock_datum())
|
|
40
|
-
|> required_signer_hash(is_seller_signed, mock_pub_key_hex(1))
|
|
41
|
-
|> complete()
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
test success_close() {
|
|
45
|
-
let output_reference = mock_utxo_ref(0, 1)
|
|
46
|
-
let redeemer = Close
|
|
47
|
-
let test_case = CloseTestCase { is_seller_signed: True }
|
|
48
|
-
|
|
49
|
-
let tx = get_close_test_tx(test_case)
|
|
50
|
-
let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
|
|
51
|
-
marketplace_logic(
|
|
52
|
-
mock_pub_key_address(0, None),
|
|
53
|
-
100,
|
|
54
|
-
mock_datum(),
|
|
55
|
-
redeemer,
|
|
56
|
-
ctx,
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
test fail_close_without_signature() {
|
|
61
|
-
let output_reference = mock_utxo_ref(0, 1)
|
|
62
|
-
let redeemer = Close
|
|
63
|
-
let test_case = CloseTestCase { is_seller_signed: False }
|
|
64
|
-
|
|
65
|
-
let tx = get_close_test_tx(test_case)
|
|
66
|
-
let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
|
|
67
|
-
!marketplace_logic(
|
|
68
|
-
mock_pub_key_address(0, None),
|
|
69
|
-
100,
|
|
70
|
-
mock_datum(),
|
|
71
|
-
redeemer,
|
|
72
|
-
ctx,
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
type BuyTestCase {
|
|
77
|
-
is_only_one_input_from_script: Bool,
|
|
78
|
-
is_fee_paid: Bool,
|
|
79
|
-
is_proceed_paid: Bool,
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
fn get_buy_test_tx(test_case: BuyTestCase) -> Transaction {
|
|
83
|
-
let BuyTestCase {
|
|
84
|
-
is_only_one_input_from_script,
|
|
85
|
-
is_fee_paid,
|
|
86
|
-
is_proceed_paid,
|
|
87
|
-
} = test_case
|
|
88
|
-
|
|
89
|
-
let input_value =
|
|
90
|
-
from_lovelace(2_000_000) |> add(mock_policy_id(0), "Test Token", 1)
|
|
91
|
-
|
|
92
|
-
new_tx_tester()
|
|
93
|
-
|> tx_out(
|
|
94
|
-
True,
|
|
95
|
-
mock_pub_key_address(0, None),
|
|
96
|
-
if is_fee_paid {
|
|
97
|
-
from_lovelace(2_000_000)
|
|
98
|
-
} else {
|
|
99
|
-
from_lovelace(1_000_000)
|
|
100
|
-
},
|
|
101
|
-
)
|
|
102
|
-
|> tx_out(
|
|
103
|
-
True,
|
|
104
|
-
mock_pub_key_address(1, None),
|
|
105
|
-
if is_proceed_paid {
|
|
106
|
-
from_lovelace(202_000_000)
|
|
107
|
-
} else {
|
|
108
|
-
from_lovelace(200_000_000)
|
|
109
|
-
},
|
|
110
|
-
)
|
|
111
|
-
|> complete()
|
|
112
|
-
|> add_input(
|
|
113
|
-
True,
|
|
114
|
-
Input {
|
|
115
|
-
output_reference: mock_utxo_ref(0, 1),
|
|
116
|
-
output: mock_script_output(
|
|
117
|
-
mock_script_address(0, None),
|
|
118
|
-
input_value,
|
|
119
|
-
InlineDatum(mock_datum()),
|
|
120
|
-
),
|
|
121
|
-
},
|
|
122
|
-
)
|
|
123
|
-
|> add_input(
|
|
124
|
-
!is_only_one_input_from_script,
|
|
125
|
-
Input {
|
|
126
|
-
output_reference: mock_utxo_ref(0, 2),
|
|
127
|
-
output: mock_script_output(
|
|
128
|
-
mock_script_address(0, None),
|
|
129
|
-
input_value,
|
|
130
|
-
InlineDatum(mock_datum()),
|
|
131
|
-
),
|
|
132
|
-
},
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
test success_buy() {
|
|
137
|
-
let output_reference = mock_utxo_ref(0, 1)
|
|
138
|
-
let redeemer = Buy
|
|
139
|
-
let test_case =
|
|
140
|
-
BuyTestCase {
|
|
141
|
-
is_only_one_input_from_script: True,
|
|
142
|
-
is_fee_paid: True,
|
|
143
|
-
is_proceed_paid: True,
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
let tx = get_buy_test_tx(test_case)
|
|
147
|
-
let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
|
|
148
|
-
marketplace_logic(
|
|
149
|
-
mock_pub_key_address(0, None),
|
|
150
|
-
100,
|
|
151
|
-
mock_datum(),
|
|
152
|
-
redeemer,
|
|
153
|
-
ctx,
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
test fail_buy_with_multiple_script_inputs() {
|
|
158
|
-
let output_reference = mock_utxo_ref(0, 1)
|
|
159
|
-
let redeemer = Buy
|
|
160
|
-
let test_case =
|
|
161
|
-
BuyTestCase {
|
|
162
|
-
is_only_one_input_from_script: False,
|
|
163
|
-
is_fee_paid: True,
|
|
164
|
-
is_proceed_paid: True,
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
let tx = get_buy_test_tx(test_case)
|
|
168
|
-
let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
|
|
169
|
-
!marketplace_logic(
|
|
170
|
-
mock_pub_key_address(0, None),
|
|
171
|
-
100,
|
|
172
|
-
mock_datum(),
|
|
173
|
-
redeemer,
|
|
174
|
-
ctx,
|
|
175
|
-
)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
test fail_buy_without_fee_paid() {
|
|
179
|
-
let output_reference = mock_utxo_ref(0, 1)
|
|
180
|
-
let redeemer = Buy
|
|
181
|
-
let test_case =
|
|
182
|
-
BuyTestCase {
|
|
183
|
-
is_only_one_input_from_script: True,
|
|
184
|
-
is_fee_paid: False,
|
|
185
|
-
is_proceed_paid: True,
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
let tx = get_buy_test_tx(test_case)
|
|
189
|
-
let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
|
|
190
|
-
!marketplace_logic(
|
|
191
|
-
mock_pub_key_address(0, None),
|
|
192
|
-
100,
|
|
193
|
-
mock_datum(),
|
|
194
|
-
redeemer,
|
|
195
|
-
ctx,
|
|
196
|
-
)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
test fail_buy_without_proceed_paid() {
|
|
200
|
-
let output_reference = mock_utxo_ref(0, 1)
|
|
201
|
-
let redeemer = Buy
|
|
202
|
-
let test_case =
|
|
203
|
-
BuyTestCase {
|
|
204
|
-
is_only_one_input_from_script: True,
|
|
205
|
-
is_fee_paid: True,
|
|
206
|
-
is_proceed_paid: False,
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
let tx = get_buy_test_tx(test_case)
|
|
210
|
-
let ctx = ScriptContext { purpose: Spend(output_reference), transaction: tx }
|
|
211
|
-
!marketplace_logic(
|
|
212
|
-
mock_pub_key_address(0, None),
|
|
213
|
-
100,
|
|
214
|
-
mock_datum(),
|
|
215
|
-
redeemer,
|
|
216
|
-
ctx,
|
|
217
|
-
)
|
|
218
|
-
}
|
package/src/marketplace/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './offchain';
|