Skip to content

Commit

Permalink
Update to neow3j 3.15.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
csmuller committed Feb 8, 2022
1 parent 0ade1ed commit 87f5e25
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Example of a Governance Smart Contract for the Neo Blockchain

This code is the product of the [Neo DevLog Episode 3](https://www.youtube.com/watch?v=P9V_hADZJPI)
held on Dec 16, 2021 on the Neo Discord Server.
It shows a simple implementation of a governance contract that handles proposals with
arbitrary intents. At the same time it serves as an example of how to use the neow3j test
framework (at version 3.14.1).
This code is the product of the [Neo DevLog Episode 3](https://www.youtube.com/watch?v=P9V_hADZJPI)
held on Dec 16, 2021 on the Neo Discord Server. It shows a simple implementation of a governance
contract that handles proposals with arbitrary intents. At the same time it serves as an example of
how to use the neow3j test framework.

> Note: Neow3j might have evolved since the creation of this repository.
> Make sure to check out the neow3j [repository](https://github.com/neow3j/neow3j)
> and the docs at [neow3j.io](https://neow3j.io).
> Note: Neow3j might have evolved since the creation of this repository. Make sure to check out the
> neow3j [repository](https://github.com/neow3j/neow3j) and the docs at
> [neow3j.io](https://neow3j.io).
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'java'
id 'io.neow3j.gradle-plugin' version '3.14.1'
id 'io.neow3j.gradle-plugin' version '3.15.0'
}

group 'org.example'
group 'com.axlabs'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8
Expand All @@ -14,12 +14,12 @@ repositories {
}

dependencies {
implementation 'io.neow3j:devpack:3.14.1'
implementation 'io.neow3j:devpack:3.15.0'

testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2',
'io.neow3j:devpack-test:3.14.1',
'io.neow3j:devpack-test:3.15.0',
'org.hamcrest:hamcrest-all:1.3',
'io.neow3j:compiler:3.14.1'
'io.neow3j:compiler:3.15.0'
}

tasks.withType(Test) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/axlabs/governance/GenericGov.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
public class GenericGov {

static StorageContext ctx = Storage.getStorageContext();
static final StorageMap proposals = ctx.createMap(0);
static final StorageMap members = ctx.createMap(1);
static final StorageMap proposals = new StorageMap(ctx, "proposals");
static final StorageMap members = new StorageMap(ctx, "members");

@OnDeployment
public static void deploy(Object data, boolean update) {
Expand Down
7 changes: 6 additions & 1 deletion src/test/java/com/axlabs/governance/GenericGovTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import io.neow3j.utils.Await;
import io.neow3j.wallet.Account;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.math.BigInteger;
Expand All @@ -32,6 +35,7 @@
import static io.neow3j.types.ContractParameter.hash160;
import static io.neow3j.types.ContractParameter.string;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@ContractTest(blockTime = 1,
contracts = {GenericGov.class, GenericGovTreasury.class},
configFile = "default.neo-express",
Expand Down Expand Up @@ -177,11 +181,12 @@ public void release_funds() throws Throwable {
System.out.println(charlie.getNep17Balances(neow3j));
}

@Order(Order.DEFAULT + 1) // Execute this test last.
@Test
public void update_gov() throws Throwable {
// Define proposal
ContractParameter proposer = hash160(charlie);
CompilationUnit res = new Compiler().compile(GenericGovV2.class.getCanonicalName());
CompilationUnit res = new Compiler().compile(GenericGovUpdated.class.getCanonicalName());
ObjectMapper mapper = new ObjectMapper();
String manifestString = mapper.writeValueAsString(res.getManifest());
ContractParameter intent = array(
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/axlabs/governance/GenericGovUpdated.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import io.neow3j.devpack.events.Event1Arg;

@Permission(contract = "*", methods = "*")
@DisplayName("Generic Governance v2")
@DisplayName("Generic Governance")
@ManifestExtra(key = "author", value = "AxLabs")
public class GenericGovV2 {
public class GenericGovUpdated {

static Event1Arg<String> updated;

Expand Down

0 comments on commit 87f5e25

Please sign in to comment.