-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added archetype devenv, reworked SmartContractCompiler so not use a t…
…emp file
- Loading branch information
Showing
13 changed files
with
989 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.github.neodix42</groupId> | ||
<artifactId>top</artifactId> | ||
<version>0.7.1</version> | ||
</parent> | ||
|
||
<groupId>org.ton.java</groupId> | ||
<artifactId>devenv</artifactId> | ||
<packaging>maven-archetype</packaging> | ||
|
||
<name>TON Java Archetype</name> | ||
|
||
<description>Java Maven archetype used for TON development using ton4j.</description> | ||
|
||
<url>https://github.com/neodiX42/ton4j</url> | ||
|
||
<licenses> | ||
<license> | ||
<name>GNU General Public License v3.0</name> | ||
<url>https://www.gnu.org/licenses/gpl-3.0.html</url> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<name>neodiX</name> | ||
<email>[email protected]</email> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com/neodiX42/ton4j.git</connection> | ||
<developerConnection>scm:git:ssh://github.com/neodiX42/ton4j.git</developerConnection> | ||
<url>https://github.com/neodiX42/ton4j/tree/main</url> | ||
</scm> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
</properties> | ||
|
||
<build> | ||
<extensions> | ||
<extension> | ||
<groupId>org.apache.maven.archetype</groupId> | ||
<artifactId>archetype-packaging</artifactId> | ||
<version>3.2.1</version> | ||
</extension> | ||
</extensions> | ||
</build> | ||
</project> |
10 changes: 10 additions & 0 deletions
10
devenv/src/main/resources/META-INF/maven/archetype-metadata.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<archetype-descriptor name="devenv"> | ||
<fileSets> | ||
<fileSet> | ||
<directory>src/test/java</directory> | ||
</fileSet> | ||
<fileSet> | ||
<directory>src/test/resources</directory> | ||
</fileSet> | ||
</fileSets> | ||
</archetype-descriptor> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>${groupId}</groupId> | ||
<artifactId>${artifactId}</artifactId> | ||
<version>${version}</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>${artifactId}</name> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.github.neodix42</groupId> | ||
<artifactId>smartcontract</artifactId> | ||
<version>0.7.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.neodix42</groupId> | ||
<artifactId>func</artifactId> | ||
<version>0.7.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.neodix42</groupId> | ||
<artifactId>emulator</artifactId> | ||
<version>0.7.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.4.12</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
36 changes: 36 additions & 0 deletions
36
devenv/src/main/resources/archetype-resources/src/test/java/DevEnvTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import java.io.IOException; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
import org.ton.java.cell.Cell; | ||
import org.ton.java.smartcontract.SmartContractCompiler; | ||
import org.ton.java.tonlib.Tonlib; | ||
import org.ton.java.tonlib.types.*; | ||
|
||
@Slf4j | ||
@RunWith(JUnit4.class) | ||
public class DevEnvTest { | ||
|
||
static Cell codeCell; | ||
|
||
@BeforeClass | ||
public static void setUpBeforeClass() throws IOException { | ||
log.info("Compiling main.fc..."); | ||
SmartContractCompiler smcFunc = | ||
SmartContractCompiler.builder().contractAsResource("/main.fc").build(); | ||
codeCell = smcFunc.compileToCell(); | ||
log.info("codeCell {}", codeCell.print()); | ||
} | ||
|
||
@Test | ||
public void testCompileContract() throws IOException {} | ||
|
||
@Test | ||
public void testTonlibGetLastBlock() { | ||
Tonlib tonlib = Tonlib.builder().testnet(true).build(); | ||
BlockIdExt block = tonlib.getLast().getLast(); | ||
log.info("block {}", block); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
devenv/src/main/resources/archetype-resources/src/test/resources/main.fc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma version >=0.4.3; | ||
|
||
#include "stdlib.fc"; | ||
|
||
() recv_internal(int my_ton_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure { | ||
~dump(40); | ||
} | ||
|
||
() recv_external(slice in_msg_body) impure { | ||
~dump(41); | ||
var msg_seqno = in_msg_body~load_uint(32); | ||
var ds = get_data().begin_parse(); | ||
var stored_seqno = ds~load_uint(32); | ||
|
||
throw_if(33, msg_seqno != stored_seqno); | ||
|
||
accept_message(); | ||
|
||
set_data(begin_cell() | ||
.store_uint(stored_seqno + 1, 32) | ||
.end_cell()); | ||
} | ||
|
||
int get_id() method_id { | ||
;; ~dump(42); | ||
return 42; | ||
} |
Oops, something went wrong.