diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12132e5430..391989812d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,6 @@ # All Examples TODO restore when https://github.com/demergent-labs/azle/issues/1192 is resolved # "examples/complex_types", -# "examples/counter", # "examples/cross_canister_calls", # "examples/cycles", # "examples/date", @@ -114,6 +113,7 @@ jobs: "examples/candid_encoding", "examples/complex_init", "examples/composite_queries", + "examples/counter", "examples/primitive_types", "examples/principal", "examples/query", diff --git a/examples/counter/dfx.json b/examples/counter/dfx.json index c78402bafb..4514887657 100644 --- a/examples/counter/dfx.json +++ b/examples/counter/dfx.json @@ -6,7 +6,8 @@ "root": "src", "ts": "src/index.ts", "candid": "src/index.did", - "wasm": ".azle/counter/counter.wasm.gz", + "wasm": ".azle/counter/counter.wasm", + "gzip": true, "declarations": { "output": "test/dfx_generated/counter", "node_compatibility": true diff --git a/examples/counter/src/index.ts b/examples/counter/src/index.ts index 5f0f717d44..4ede974d3d 100644 --- a/examples/counter/src/index.ts +++ b/examples/counter/src/index.ts @@ -1,17 +1,14 @@ import { nat64, query, Service, update } from 'azle'; -export default class extends Service { - count: nat64 = 0n; - - @query([], nat64) - readCount(): nat64 { - return this.count; - } - - @update([], nat64) - incrementCount(): nat64 { - this.count += 1n; - - return this.count; - } -} +let count: nat64 = 0n; + +export default Service({ + readCount: query([], nat64, () => { + return count; + }), + incrementCount: update([], nat64, () => { + count += 1n; + + return count; + }) +});