Skip to content

Commit 8c153a9

Browse files
committed
filter functions from abi
1 parent 87545af commit 8c153a9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

app/src/main/java/io/ballerina/web3/abi/AbiReader.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,30 @@
2020

2121
import com.fasterxml.jackson.databind.ObjectMapper;
2222
import java.io.File;
23+
import java.util.Arrays;
24+
import java.util.stream.Collectors;
2325

2426
public class AbiReader {
2527

2628
private String abiPath;
2729

28-
public AbiReader(String abiPath){
30+
public AbiReader(String abiPath) {
2931
this.abiPath = abiPath;
3032
}
3133

32-
public AbiEntry[] read() throws Exception {
34+
public AbiEntry[] read() throws Exception {
3335

34-
// Load ABI JSON file
35-
ObjectMapper objectMapper = new ObjectMapper();
36-
File file = new File(abiPath);
36+
// Load ABI JSON file
37+
ObjectMapper objectMapper = new ObjectMapper();
38+
File file = new File(abiPath);
3739

38-
// Deserialize JSON
39-
ContractJson contractJson = objectMapper.readValue(file,ContractJson.class);
40+
// Deserialize JSON
41+
ContractJson contractJson = objectMapper.readValue(file, ContractJson.class);
4042

41-
AbiEntry[] abiEntries = contractJson.getAbi();
43+
AbiEntry[] abiEntries = contractJson.getAbi();
4244

43-
return abiEntries;
45+
return Arrays.stream(abiEntries)
46+
.filter(entry -> "function".equals(entry.getType()))
47+
.collect(Collectors.toList());
4448
}
4549
}

0 commit comments

Comments
 (0)