Skip to content

Commit 5946684

Browse files
authored
Add support for Optional types in blueprint processing (#463)
* Add support for Optional types in blueprint processing Implemented changes to handle Optional types in blueprint definitions. Added tests for processing blueprints with basic option types and ensured proper compilation. Updated schema and processing utilities to accommodate new Optional type handling. * Add Pair type support and serialization logic Added the Pair type to Type and JavaType enums. Updated BlueprintSchema, ConverterCodeGenerator, and ClassDefinitionGenerator to handle Pair serialization and deserialization. Introduced unit tests to verify Pair functionality. * Fix package issue due to aiken stdlib definitions * To fix #452 Add tests for ScheduledTransactionRedeemer model and related tests
1 parent 7b1f060 commit 5946684

37 files changed

+2130
-60
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.bloxbean.cardano.client.plutus.annotation.processor.it;
2+
3+
import com.bloxbean.cardano.client.plutus.annotation.Blueprint;
4+
5+
@Blueprint(fileInResources = "blueprint/basic_option_plutus.json", packageName = "com.bloxbean.cardano.client.plutus.annotation.blueprint.basicoption")
6+
public class BasicOption {
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.bloxbean.cardano.client.plutus.annotation.processor.it;
2+
3+
import com.bloxbean.cardano.client.plutus.annotation.Blueprint;
4+
5+
@Blueprint(fileInResources = "blueprint/basic_pair.json", packageName = "com.bloxbean.cardano.client.plutus.annotation.blueprint.basicpair")
6+
public class BasicPair {
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.bloxbean.cardano.client.plutus.annotation.processor.it;
2+
3+
import com.bloxbean.cardano.client.plutus.annotation.Blueprint;
4+
5+
@Blueprint(fileInResources = "blueprint/recurring_payment.json", packageName = "com.bloxbean.cardano.client.plutus.annotation.blueprint.recurringpayment")
6+
public class RecurringPaymentBlueprint {
7+
}
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
{
2+
"preamble": {
3+
"title": "satya/hello6",
4+
"description": "Aiken contracts for project 'satya/hello6'",
5+
"version": "0.0.0",
6+
"plutusVersion": "v3",
7+
"compiler": {
8+
"name": "Aiken",
9+
"version": "v1.1.3+3d77b5c"
10+
},
11+
"license": "Apache-2.0"
12+
},
13+
"validators": [
14+
{
15+
"title": "hello6.option_test.spend",
16+
"datum": {
17+
"title": "datum",
18+
"schema": {
19+
"$ref": "#/definitions/hello6~1Datum"
20+
}
21+
},
22+
"redeemer": {
23+
"title": "redeemer",
24+
"schema": {
25+
"$ref": "#/definitions/hello6~1Redeemer"
26+
}
27+
},
28+
"compiledCode": "590214010100323232323232253330023232323232533233008300130093754004264646464a6646601a6002601c6ea80204c8c8c8c8c8c8c8c94ccc060c0680084c8c94ccc05cc02c0044c8c94ccc070c0780085401058dd7180e000980c9baa0091533301730100011533301a301937540122a0042c2c602e6ea80204cc028014894ccc0680084c8c94ccc064c0340044c8c94ccc078c0800084c8c94ccc074c04400454ccc080c07cdd50018a8010b0a99980e980b0008a999810180f9baa003150021616301d37540042a0082c603c00260366ea801c54ccc064c04800454ccc070c06cdd50038a8010b0b180c9baa00613300c00322533301c00215333019300d301a375401e26464a666036601e60386ea80044c94ccc07000c400452819b8f375c603e603a6ea800522010548656c6c6f0016301e301c375402a66e1cdd6980e980d9baa301d301b375401e90020b0999119299980e180800089919299981098118010a8020b1bad3021001301e37540062a666038602a0022a66603e603c6ea800c540085858c070dd5001180e80109800980f0010991801180e8019bad301b00216375860300026030004602c002602c0046eb0c050004c050008c048004c03cdd50041b87480005888c8cc00400400c88cc00c004c008008c038c03c008c034004c028dd50011b874800858c028c02c008c024004c024008c01c004c010dd50008a4c26cacae6955ceaab9e5573eae855d11",
29+
"hash": "259dcba0e8629ce7acabb4e4424f9da53be27aa2f5ee32c323fa0963"
30+
},
31+
{
32+
"title": "hello6.option_test.else",
33+
"compiledCode": "590214010100323232323232253330023232323232533233008300130093754004264646464a6646601a6002601c6ea80204c8c8c8c8c8c8c8c94ccc060c0680084c8c94ccc05cc02c0044c8c94ccc070c0780085401058dd7180e000980c9baa0091533301730100011533301a301937540122a0042c2c602e6ea80204cc028014894ccc0680084c8c94ccc064c0340044c8c94ccc078c0800084c8c94ccc074c04400454ccc080c07cdd50018a8010b0a99980e980b0008a999810180f9baa003150021616301d37540042a0082c603c00260366ea801c54ccc064c04800454ccc070c06cdd50038a8010b0b180c9baa00613300c00322533301c00215333019300d301a375401e26464a666036601e60386ea80044c94ccc07000c400452819b8f375c603e603a6ea800522010548656c6c6f0016301e301c375402a66e1cdd6980e980d9baa301d301b375401e90020b0999119299980e180800089919299981098118010a8020b1bad3021001301e37540062a666038602a0022a66603e603c6ea800c540085858c070dd5001180e80109800980f0010991801180e8019bad301b00216375860300026030004602c002602c0046eb0c050004c050008c048004c03cdd50041b87480005888c8cc00400400c88cc00c004c008008c038c03c008c034004c028dd50011b874800858c028c02c008c024004c024008c01c004c010dd50008a4c26cacae6955ceaab9e5573eae855d11",
34+
"hash": "259dcba0e8629ce7acabb4e4424f9da53be27aa2f5ee32c323fa0963"
35+
}
36+
],
37+
"definitions": {
38+
"ByteArray": {
39+
"dataType": "bytes"
40+
},
41+
"Int": {
42+
"dataType": "integer"
43+
},
44+
"List$Int": {
45+
"dataType": "list",
46+
"items": {
47+
"$ref": "#/definitions/Int"
48+
}
49+
},
50+
"List$Option$Int": {
51+
"dataType": "list",
52+
"items": {
53+
"$ref": "#/definitions/Option$Int"
54+
}
55+
},
56+
"Option$ByteArray": {
57+
"title": "Option",
58+
"anyOf": [
59+
{
60+
"title": "Some",
61+
"description": "An optional value.",
62+
"dataType": "constructor",
63+
"index": 0,
64+
"fields": [
65+
{
66+
"$ref": "#/definitions/ByteArray"
67+
}
68+
]
69+
},
70+
{
71+
"title": "None",
72+
"description": "Nothing.",
73+
"dataType": "constructor",
74+
"index": 1,
75+
"fields": []
76+
}
77+
]
78+
},
79+
"Option$Int": {
80+
"title": "Option",
81+
"anyOf": [
82+
{
83+
"title": "Some",
84+
"description": "An optional value.",
85+
"dataType": "constructor",
86+
"index": 0,
87+
"fields": [
88+
{
89+
"$ref": "#/definitions/Int"
90+
}
91+
]
92+
},
93+
{
94+
"title": "None",
95+
"description": "Nothing.",
96+
"dataType": "constructor",
97+
"index": 1,
98+
"fields": []
99+
}
100+
]
101+
},
102+
"Option$hello6/Action": {
103+
"title": "Option",
104+
"anyOf": [
105+
{
106+
"title": "Some",
107+
"description": "An optional value.",
108+
"dataType": "constructor",
109+
"index": 0,
110+
"fields": [
111+
{
112+
"$ref": "#/definitions/hello6~1Action"
113+
}
114+
]
115+
},
116+
{
117+
"title": "None",
118+
"description": "Nothing.",
119+
"dataType": "constructor",
120+
"index": 1,
121+
"fields": []
122+
}
123+
]
124+
},
125+
"hello6/Action": {
126+
"title": "Action",
127+
"anyOf": [
128+
{
129+
"title": "Mint",
130+
"dataType": "constructor",
131+
"index": 0,
132+
"fields": []
133+
},
134+
{
135+
"title": "Burn",
136+
"dataType": "constructor",
137+
"index": 1,
138+
"fields": []
139+
}
140+
]
141+
},
142+
"hello6/Datum": {
143+
"title": "Datum",
144+
"anyOf": [
145+
{
146+
"title": "Datum",
147+
"dataType": "constructor",
148+
"index": 0,
149+
"fields": [
150+
{
151+
"title": "count",
152+
"$ref": "#/definitions/Int"
153+
}
154+
]
155+
}
156+
]
157+
},
158+
"hello6/Redeemer": {
159+
"title": "Redeemer",
160+
"anyOf": [
161+
{
162+
"title": "Redeemer",
163+
"dataType": "constructor",
164+
"index": 0,
165+
"fields": [
166+
{
167+
"title": "msg",
168+
"$ref": "#/definitions/Option$ByteArray"
169+
},
170+
{
171+
"title": "list",
172+
"$ref": "#/definitions/List$Int"
173+
},
174+
{
175+
"title": "act",
176+
"$ref": "#/definitions/Option$hello6~1Action"
177+
},
178+
{
179+
"title": "act2",
180+
"$ref": "#/definitions/List$Option$Int"
181+
}
182+
]
183+
}
184+
]
185+
}
186+
}
187+
}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
{
2+
"preamble": {
3+
"title": "satya/hello6",
4+
"description": "Aiken contracts for project 'satya/hello6'",
5+
"version": "0.0.0",
6+
"plutusVersion": "v3",
7+
"compiler": {
8+
"name": "Aiken",
9+
"version": "v1.1.3+3d77b5c"
10+
},
11+
"license": "Apache-2.0"
12+
},
13+
"validators": [
14+
{
15+
"title": "hello6.option_test.spend",
16+
"datum": {
17+
"title": "datum",
18+
"schema": {
19+
"$ref": "#/definitions/hello6~1Datum"
20+
}
21+
},
22+
"redeemer": {
23+
"title": "redeemer",
24+
"schema": {
25+
"$ref": "#/definitions/hello6~1Redeemer"
26+
}
27+
},
28+
"compiledCode": "5901e201010032323232323225333002323232323253323300830013009375400426464646464a66601a6004601c6ea80204c8c8c8c8c8c94ccc058c0600084c8c94ccc054c0280044c8c94ccc068c0700085401058dd7180d000980b9baa00715333015300e001153330183017375400e2a0042c2c602a6ea80184c8cc020c0580104c8cc00400400c88c94ccc06800854ccc05cc030c060dd500689919299980c9807180d1baa001132533301a003100114a066e3cdd7180e980d9baa00148810548656c6c6f0016301c301a375402666e1cdd6980d980c9baa301b3019375401a90020b09919199119299980e180880089919299981098118010998090008a8020b1810800980f1baa0031533301c30150011533301f301e37540062a0042c2c60386ea8008c06c0084c00cc078010dd6980c800980d80118010011bad3014003163756602c002602c00464a666028602c602c002266ec0c054004c054c05800458dd6180a000980a001180900098079baa008162232533300f300400115333012301137540062a0042c2a66601e60100022a66602460226ea800c540085858c03cdd50011b8748000c038c03c008c034004c028dd50011b874800858c028c02c008c024004c024008c01c004c010dd50008a4c26cacae6955ceaab9e5573eae855d101",
29+
"hash": "7d6957063c7c52d9de05a799a33996d36c98427f06c9cc51d2dc77c8"
30+
},
31+
{
32+
"title": "hello6.option_test.else",
33+
"compiledCode": "5901e201010032323232323225333002323232323253323300830013009375400426464646464a66601a6004601c6ea80204c8c8c8c8c8c94ccc058c0600084c8c94ccc054c0280044c8c94ccc068c0700085401058dd7180d000980b9baa00715333015300e001153330183017375400e2a0042c2c602a6ea80184c8cc020c0580104c8cc00400400c88c94ccc06800854ccc05cc030c060dd500689919299980c9807180d1baa001132533301a003100114a066e3cdd7180e980d9baa00148810548656c6c6f0016301c301a375402666e1cdd6980d980c9baa301b3019375401a90020b09919199119299980e180880089919299981098118010998090008a8020b1810800980f1baa0031533301c30150011533301f301e37540062a0042c2c60386ea8008c06c0084c00cc078010dd6980c800980d80118010011bad3014003163756602c002602c00464a666028602c602c002266ec0c054004c054c05800458dd6180a000980a001180900098079baa008162232533300f300400115333012301137540062a0042c2a66601e60100022a66602460226ea800c540085858c03cdd50011b8748000c038c03c008c034004c028dd50011b874800858c028c02c008c024004c024008c01c004c010dd50008a4c26cacae6955ceaab9e5573eae855d101",
34+
"hash": "7d6957063c7c52d9de05a799a33996d36c98427f06c9cc51d2dc77c8"
35+
}
36+
],
37+
"definitions": {
38+
"ByteArray": {
39+
"dataType": "bytes"
40+
},
41+
"Int": {
42+
"dataType": "integer"
43+
},
44+
"List$Pair$Int_Option$hello6/Action": {
45+
"dataType": "map",
46+
"keys": {
47+
"$ref": "#/definitions/Int"
48+
},
49+
"values": {
50+
"$ref": "#/definitions/Option$hello6~1Action"
51+
}
52+
},
53+
"Option$ByteArray": {
54+
"title": "Option",
55+
"anyOf": [
56+
{
57+
"title": "Some",
58+
"description": "An optional value.",
59+
"dataType": "constructor",
60+
"index": 0,
61+
"fields": [
62+
{
63+
"$ref": "#/definitions/ByteArray"
64+
}
65+
]
66+
},
67+
{
68+
"title": "None",
69+
"description": "Nothing.",
70+
"dataType": "constructor",
71+
"index": 1,
72+
"fields": []
73+
}
74+
]
75+
},
76+
"Option$hello6/Action": {
77+
"title": "Option",
78+
"anyOf": [
79+
{
80+
"title": "Some",
81+
"description": "An optional value.",
82+
"dataType": "constructor",
83+
"index": 0,
84+
"fields": [
85+
{
86+
"$ref": "#/definitions/hello6~1Action"
87+
}
88+
]
89+
},
90+
{
91+
"title": "None",
92+
"description": "Nothing.",
93+
"dataType": "constructor",
94+
"index": 1,
95+
"fields": []
96+
}
97+
]
98+
},
99+
"Pair$Int_hello6/Action": {
100+
"title": "Pair",
101+
"dataType": "#pair",
102+
"left": {
103+
"$ref": "#/definitions/Int"
104+
},
105+
"right": {
106+
"$ref": "#/definitions/hello6~1Action"
107+
}
108+
},
109+
"hello6/Action": {
110+
"title": "Action",
111+
"anyOf": [
112+
{
113+
"title": "Mint",
114+
"dataType": "constructor",
115+
"index": 0,
116+
"fields": []
117+
},
118+
{
119+
"title": "Burn",
120+
"dataType": "constructor",
121+
"index": 1,
122+
"fields": []
123+
}
124+
]
125+
},
126+
"hello6/Datum": {
127+
"title": "Datum",
128+
"anyOf": [
129+
{
130+
"title": "Datum",
131+
"dataType": "constructor",
132+
"index": 0,
133+
"fields": [
134+
{
135+
"title": "count",
136+
"$ref": "#/definitions/Int"
137+
}
138+
]
139+
}
140+
]
141+
},
142+
"hello6/Redeemer": {
143+
"title": "Redeemer",
144+
"anyOf": [
145+
{
146+
"title": "Redeemer",
147+
"dataType": "constructor",
148+
"index": 0,
149+
"fields": [
150+
{
151+
"title": "msg",
152+
"$ref": "#/definitions/Option$ByteArray"
153+
},
154+
{
155+
"title": "p",
156+
"$ref": "#/definitions/Pair$Int_hello6~1Action"
157+
},
158+
{
159+
"title": "l",
160+
"$ref": "#/definitions/List$Pair$Int_Option$hello6~1Action"
161+
}
162+
]
163+
}
164+
]
165+
}
166+
}
167+
}

0 commit comments

Comments
 (0)