From 87f5e25c9677ab77cc49b527399301d1afc0b195 Mon Sep 17 00:00:00 2001 From: Claude Muller Date: Tue, 8 Feb 2022 08:56:02 +0100 Subject: [PATCH] Update to neow3j 3.15.0. --- README.md | 15 +++++++-------- build.gradle | 10 +++++----- .../java/com/axlabs/governance/GenericGov.java | 4 ++-- .../com/axlabs/governance/GenericGovTest.java | 7 ++++++- .../com/axlabs/governance/GenericGovUpdated.java | 4 ++-- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 0f910e8..cefa925 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/build.gradle b/build.gradle index d138a04..cc004b1 100644 --- a/build.gradle +++ b/build.gradle @@ -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 @@ -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) { diff --git a/src/main/java/com/axlabs/governance/GenericGov.java b/src/main/java/com/axlabs/governance/GenericGov.java index 102740b..f039140 100644 --- a/src/main/java/com/axlabs/governance/GenericGov.java +++ b/src/main/java/com/axlabs/governance/GenericGov.java @@ -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) { diff --git a/src/test/java/com/axlabs/governance/GenericGovTest.java b/src/test/java/com/axlabs/governance/GenericGovTest.java index 6addeca..73059bf 100644 --- a/src/test/java/com/axlabs/governance/GenericGovTest.java +++ b/src/test/java/com/axlabs/governance/GenericGovTest.java @@ -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; @@ -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", @@ -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( diff --git a/src/test/java/com/axlabs/governance/GenericGovUpdated.java b/src/test/java/com/axlabs/governance/GenericGovUpdated.java index b47da2f..d78109e 100644 --- a/src/test/java/com/axlabs/governance/GenericGovUpdated.java +++ b/src/test/java/com/axlabs/governance/GenericGovUpdated.java @@ -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 updated;