Skip to content

Commit

Permalink
added archetype devenv, reworked SmartContractCompiler so not use a t…
Browse files Browse the repository at this point in the history
…emp file
  • Loading branch information
neodix42 committed Oct 13, 2024
1 parent ca05314 commit e72375b
Show file tree
Hide file tree
Showing 13 changed files with 989 additions and 87 deletions.
38 changes: 38 additions & 0 deletions devenv/.gitignore
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
56 changes: 56 additions & 0 deletions devenv/pom.xml
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 devenv/src/main/resources/META-INF/maven/archetype-metadata.xml
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>
46 changes: 46 additions & 0 deletions devenv/src/main/resources/archetype-resources/pom.xml
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>
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);
}
}
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;
}
Loading

0 comments on commit e72375b

Please sign in to comment.