Skip to content

Commit efa3cbf

Browse files
authored
Merge pull request #119 from kryptokrauts/dev
v2.2.1
2 parents e729903 + 4d49f83 commit efa3cbf

File tree

4 files changed

+141
-12
lines changed

4 files changed

+141
-12
lines changed

docs/changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [v2.2.1](https://github.com/kryptokrauts/aepp-sdk-java/releases/tag/v2.2.1)
4+
5+
This release ships an enhancement.
6+
7+
### Enhancements
8+
- [#116](../../../issues/116) support includes for compiling, deploying and calling contracts
9+
- we identified this was missing when developing the [contraect-maven-plugin](https://github.com/kryptokrauts/contraect-maven-plugin)
10+
311
## [v2.2.0](https://github.com/kryptokrauts/aepp-sdk-java/releases/tag/v2.2.0)
412

513
This release ships some fixes and enhancements.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
organization=kryptokrauts
22
group=com.kryptokrauts
33
name=aepp-sdk-java
4-
version=2.2.0-SNAPSHOT
4+
version=2.2.1-SNAPSHOT

src/main/java/com/kryptokrauts/aeternity/sdk/service/compiler/CompilerService.java

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.kryptokrauts.aeternity.sdk.service.compiler.domain.ACIResult;
66
import io.reactivex.Single;
77
import java.util.List;
8+
import java.util.Map;
89

910
public interface CompilerService {
1011

@@ -14,28 +15,59 @@ public interface CompilerService {
1415
* @param contractCode the sourcecode of the contract
1516
* @param function the name of the function to call
1617
* @param arguments the params that should be passed to the function
17-
* @return asynchronous result handler (RxJava Single) for encoded calldata
18+
* @return asynchronous result handler (RxJava Single) for encoded calldata * @deprecated use
19+
* {@link asyncEncodeCalldata(String contractCode, String function, List<String> arguments,
20+
* Map<String, String> fileSystem)} instead. this method will be removed in future releases
1821
*/
22+
@Deprecated
1923
Single<StringResultWrapper> asyncEncodeCalldata(
2024
String contractCode, String function, List<String> arguments);
2125

26+
/**
27+
* asynchronously gets the encoded calldata for this contractCode
28+
*
29+
* @param contractCode the sourcecode of the contract
30+
* @param function the name of the function to call
31+
* @param arguments the params that should be passed to the function
32+
* @param fileSystem map with libraryName and code which is passed to the compiler
33+
* @return asynchronous result handler (RxJava Single) for encoded calldata
34+
*/
35+
Single<StringResultWrapper> asyncEncodeCalldata(
36+
String contractCode, String function, List<String> arguments, Map<String, String> fileSystem);
37+
2238
/**
2339
* synchronously gets the encoded calldata for this contractCode
2440
*
2541
* @param contractCode the sourcecode of the contract
2642
* @param function the name of the function to call
2743
* @param arguments the params that should be passed to the function
2844
* @return encoded calldata
45+
* @deprecated use {@link blockingEncodeCalldata(String contractCode, String function,
46+
* List<String> arguments, Map<String, String> fileSystem)} instead. this method will be
47+
* removed in future releases
2948
*/
49+
@Deprecated
3050
StringResultWrapper blockingEncodeCalldata(
3151
String contractCode, String function, List<String> arguments);
3252

53+
/**
54+
* synchronously gets the encoded calldata for this contractCode
55+
*
56+
* @param contractCode the sourcecode of the contract
57+
* @param function the name of the function to call
58+
* @param arguments the params that should be passed to the function
59+
* @param fileSystem map with libraryName and code which is passed to the compiler
60+
* @return encoded calldata
61+
*/
62+
StringResultWrapper blockingEncodeCalldata(
63+
String contractCode, String function, List<String> arguments, Map<String, String> fileSystem);
64+
3365
/**
3466
* asynchronously gets the contract bytecode for this contractCode
3567
*
3668
* @param contractCode the sourcecode of the contract
3769
* @param srcFile untested compileOpts value: set null
38-
* @param fileSystem untested compileOpts value: set null
70+
* @param fileSystem map with libraryName and code which is passed to the compiler
3971
* @return asynchronous result handler (RxJava Single) for byteCode of the compiled contract
4072
*/
4173
Single<StringResultWrapper> asyncCompile(String contractCode, String srcFile, Object fileSystem);
@@ -45,7 +77,7 @@ StringResultWrapper blockingEncodeCalldata(
4577
*
4678
* @param contractCode the sourcecode of the contract
4779
* @param srcFile untested compileOpts value: set null
48-
* @param fileSystem untested compileOpts value: set null
80+
* @param fileSystem map with libraryName and code which is passed to the compiler
4981
* @return byteCode of the compiled contract
5082
*/
5183
StringResultWrapper blockingCompile(String contractCode, String srcFile, Object fileSystem);
@@ -76,10 +108,31 @@ StringResultWrapper blockingEncodeCalldata(
76108
* @param callResult the received resultType (ok | error | revert)
77109
* @param callValue the received value
78110
* @return the decoded sophia call result
111+
* @deprecated use {@link asyncDecodeCallResult(String source, String function, String callResult,
112+
* String callValue, Map<String, String> fileSystem)} instead. this method will be removed in
113+
* future releases
79114
*/
115+
@Deprecated
80116
Single<ObjectResultWrapper> asyncDecodeCallResult(
81117
String source, String function, String callResult, String callValue);
82118

119+
/**
120+
* asynchronously decodes callresult of contract-calls
121+
*
122+
* @param source the contract source
123+
* @param function the called function
124+
* @param callResult the received resultType (ok | error | revert)
125+
* @param callValue the received value
126+
* @param fileSystem map with libraryName and code which is passed to the compiler
127+
* @return the decoded sophia call result
128+
*/
129+
Single<ObjectResultWrapper> asyncDecodeCallResult(
130+
String source,
131+
String function,
132+
String callResult,
133+
String callValue,
134+
Map<String, String> fileSystem);
135+
83136
/**
84137
* synchronously decodes callresult of contract-calls
85138
*
@@ -88,17 +141,38 @@ Single<ObjectResultWrapper> asyncDecodeCallResult(
88141
* @param callResult the received resultType (ok | error | revert)
89142
* @param callValue the received value
90143
* @return the decoded sophia call result
144+
* @deprecated use {@link blockingDecodeCallResult(String source, String function, String
145+
* callResult, String callValue, Map<String, String> fileSystem)} instead. this method will be
146+
* removed in future releases
91147
*/
148+
@Deprecated
92149
ObjectResultWrapper blockingDecodeCallResult(
93150
String source, String function, String callResult, String callValue);
94151

152+
/**
153+
* synchronously decodes callresult of contract-calls
154+
*
155+
* @param source the contract source
156+
* @param function the called function
157+
* @param callResult the received resultType (ok | error | revert)
158+
* @param callValue the received value
159+
* @param fileSystem map with libraryName and code which is passed to the compiler
160+
* @return the decoded sophia call result
161+
*/
162+
ObjectResultWrapper blockingDecodeCallResult(
163+
String source,
164+
String function,
165+
String callResult,
166+
String callValue,
167+
Map<String, String> fileSystem);
168+
95169
/**
96170
* asynchronously generates the ACI for this contractCode
97171
* https://github.com/aeternity/aesophia/blob/master/docs/aeso_aci.md
98172
*
99173
* @param contractCode the sourcecode of the contract
100174
* @param srcFile untested compileOpts value: set null
101-
* @param fileSystem untested compileOpts value: set null
175+
* @param fileSystem map with libraryName and code which is passed to the compiler
102176
* @return asynchronous result handler (RxJava Single) for {@link ACIResult}
103177
*/
104178
Single<ACIResult> asyncGenerateACI(String contractCode, String srcFile, Object fileSystem);
@@ -109,7 +183,7 @@ ObjectResultWrapper blockingDecodeCallResult(
109183
*
110184
* @param contractCode the sourcecode of the contract
111185
* @param srcFile untested compileOpts value: set null
112-
* @param fileSystem untested compileOpts value: set null
186+
* @param fileSystem map with libraryName and code which is passed to the compiler
113187
* @return result of {@link ACIResult}
114188
*/
115189
ACIResult blockingGenerateACI(String contractCode, String srcFile, Object fileSystem);

src/main/java/com/kryptokrauts/aeternity/sdk/service/compiler/impl/SophiaCompilerServiceImpl.java

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io.netty.util.internal.StringUtil;
1616
import io.reactivex.Single;
1717
import java.util.List;
18+
import java.util.Map;
1819
import java.util.Optional;
1920
import lombok.NonNull;
2021
import lombok.RequiredArgsConstructor;
@@ -29,27 +30,41 @@ public final class SophiaCompilerServiceImpl implements CompilerService {
2930
@Override
3031
public Single<StringResultWrapper> asyncEncodeCalldata(
3132
String sourceCode, String function, List<String> arguments) {
33+
return this.asyncEncodeCalldata(sourceCode, function, arguments, null);
34+
}
35+
36+
@Override
37+
public Single<StringResultWrapper> asyncEncodeCalldata(
38+
String sourceCode, String function, List<String> arguments, Map<String, String> fileSystem) {
3239
return StringResultWrapper.builder()
3340
.build()
3441
.asyncGet(
3542
this.compilerApi
36-
.rxEncodeCalldata(buildFunctionCallInput(sourceCode, function, arguments))
43+
.rxEncodeCalldata(
44+
buildFunctionCallInput(sourceCode, function, arguments, fileSystem))
3745
.map(calldata -> calldata.getCalldata()));
3846
}
3947

4048
@Override
4149
public StringResultWrapper blockingEncodeCalldata(
4250
String sourceCode, String function, List<String> arguments) {
51+
return this.blockingEncodeCalldata(sourceCode, function, arguments, null);
52+
}
53+
54+
@Override
55+
public StringResultWrapper blockingEncodeCalldata(
56+
String sourceCode, String function, List<String> arguments, Map<String, String> fileSystem) {
4357
return StringResultWrapper.builder()
4458
.build()
4559
.blockingGet(
4660
this.compilerApi
47-
.rxEncodeCalldata(buildFunctionCallInput(sourceCode, function, arguments))
61+
.rxEncodeCalldata(
62+
buildFunctionCallInput(sourceCode, function, arguments, fileSystem))
4863
.map(calldata -> calldata.getCalldata()));
4964
}
5065

5166
private FunctionCallInput buildFunctionCallInput(
52-
String sourceCode, String function, List<String> arguments) {
67+
String sourceCode, String function, List<String> arguments, Map<String, String> fileSystem) {
5368
FunctionCallInput body = new FunctionCallInput();
5469
body.source(sourceCode);
5570
body.function(function);
@@ -59,6 +74,9 @@ private FunctionCallInput buildFunctionCallInput(
5974
}
6075
}
6176
body.options(new CompileOpts().backend(config.getTargetVM().getBackendEnum()));
77+
if (fileSystem != null) {
78+
body.getOptions().fileSystem(fileSystem);
79+
}
6280
return body;
6381
}
6482

@@ -89,22 +107,44 @@ public ObjectResultWrapper blockingDecodeCalldata(String calldata, String sophia
89107
@Override
90108
public Single<ObjectResultWrapper> asyncDecodeCallResult(
91109
String source, String function, String callResult, String callValue) {
110+
return this.asyncDecodeCallResult(source, function, callResult, callValue, null);
111+
}
112+
113+
@Override
114+
public Single<ObjectResultWrapper> asyncDecodeCallResult(
115+
String source,
116+
String function,
117+
String callResult,
118+
String callValue,
119+
Map<String, String> fileSystem) {
92120
return ObjectResultWrapper.builder()
93121
.build()
94122
.asyncGet(
95123
this.compilerApi
96-
.rxDecodeCallResult(buildDecodeBody(source, function, callResult, callValue))
124+
.rxDecodeCallResult(
125+
buildDecodeBody(source, function, callResult, callValue, fileSystem))
97126
.map(decodeResult -> Optional.ofNullable(decodeResult).orElse("")));
98127
}
99128

100129
@Override
101130
public ObjectResultWrapper blockingDecodeCallResult(
102131
String source, String function, String callResult, String callValue) {
132+
return this.blockingDecodeCallResult(source, function, callResult, callValue, null);
133+
}
134+
135+
@Override
136+
public ObjectResultWrapper blockingDecodeCallResult(
137+
String source,
138+
String function,
139+
String callResult,
140+
String callValue,
141+
Map<String, String> fileSystem) {
103142
return ObjectResultWrapper.builder()
104143
.build()
105144
.blockingGet(
106145
this.compilerApi
107-
.rxDecodeCallResult(buildDecodeBody(source, function, callResult, callValue))
146+
.rxDecodeCallResult(
147+
buildDecodeBody(source, function, callResult, callValue, fileSystem))
108148
.map(decodeResult -> Optional.ofNullable(decodeResult).orElse("")));
109149
}
110150

@@ -116,14 +156,21 @@ private SophiaBinaryData buildDecodeBody(String calldata, String sophiaType) {
116156
}
117157

118158
private SophiaCallResultInput buildDecodeBody(
119-
String source, String function, String callResult, String callValue) {
159+
String source,
160+
String function,
161+
String callResult,
162+
String callValue,
163+
Map<String, String> fileSystem) {
120164
SophiaCallResultInput body = new SophiaCallResultInput();
121165
body.setSource(source);
122166
body.setFunction(function);
123167
body.setCallResult(callResult);
124168
body.setCallValue(callValue);
125169
CompileOpts compileOpts = new CompileOpts();
126170
compileOpts.setBackend(config.getTargetVM().getBackendEnum());
171+
if (fileSystem != null) {
172+
compileOpts.setFileSystem(fileSystem);
173+
}
127174
body.setOptions(compileOpts);
128175
return body;
129176
}

0 commit comments

Comments
 (0)