From 24b126cae8ce01e15c2a46a9d2ba8defee1a5a53 Mon Sep 17 00:00:00 2001 From: Franco Testagrossa Date: Mon, 29 Apr 2024 11:45:04 +0200 Subject: [PATCH] Introduce bounty canister --- Cargo.lock | 13 +++++++++++++ Cargo.toml | 1 + Makefile | 14 ++++++++++++++ bounty/Cargo.toml | 18 ++++++++++++++++++ bounty/bounty.did | 4 ++++ bounty/src/lib.rs | 5 +++++ dfx.json | 5 +++++ 7 files changed, 60 insertions(+) create mode 100644 bounty/Cargo.toml create mode 100644 bounty/bounty.did create mode 100644 bounty/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index b19ebb5..ce2a1b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,6 +116,19 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bounty" +version = "0.1.0" +dependencies = [ + "candid", + "ic-cdk", + "ic-cdk-macros", + "regex", + "serde", + "serde_bytes", + "serde_json", +] + [[package]] name = "byteorder" version = "1.4.3" diff --git a/Cargo.toml b/Cargo.toml index f8dcd33..524173e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = [ "backend", + "bounty", ] resolver = "2" \ No newline at end of file diff --git a/Makefile b/Makefile index ddb40c7..20a8cc5 100644 --- a/Makefile +++ b/Makefile @@ -13,17 +13,31 @@ node_modules: .SILENT: build build: node_modules dfx canister create backend + dfx canister create bounty dfx build .PHONY: install .SILENT: install install: build dfx canister install backend --mode reinstall --yes + dfx canister install bounty --mode reinstall --yes .PHONY: upgrade .SILENT: upgrade upgrade: build dfx canister install backend --mode=upgrade + dfx canister install bounty --mode=upgrade + +.PHONY: test +.SILENT: test +test-a: install + # Call the bounty canister to get the GitHub issue and capture the output + @echo "Calling healthcheck on bounty canister..." + @TMP_FILE=$$(mktemp); \ + dfx canister call bounty healthcheck > $$TMP_FILE; \ + echo "healthcheck response:"; \ + cat $$TMP_FILE; \ + rm -f $$TMP_FILE .PHONY: test .SILENT: test diff --git a/bounty/Cargo.toml b/bounty/Cargo.toml new file mode 100644 index 0000000..4d6f7ab --- /dev/null +++ b/bounty/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "bounty" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib"] + +[dependencies] +candid = "0.8.2" +ic-cdk = "0.6.0" +ic-cdk-macros = "0.6.0" +serde = "1.0.152" +serde_json = "1.0.93" +serde_bytes = "0.11.9" +regex = "1.5.4" \ No newline at end of file diff --git a/bounty/bounty.did b/bounty/bounty.did new file mode 100644 index 0000000..8e22d5c --- /dev/null +++ b/bounty/bounty.did @@ -0,0 +1,4 @@ +service : { + "healthcheck": () -> (text); +} + diff --git a/bounty/src/lib.rs b/bounty/src/lib.rs new file mode 100644 index 0000000..8b2300d --- /dev/null +++ b/bounty/src/lib.rs @@ -0,0 +1,5 @@ + +#[ic_cdk::update] +async fn healthcheck() -> String { + return "OK".to_string(); +} diff --git a/dfx.json b/dfx.json index 511fe2a..af6c60d 100644 --- a/dfx.json +++ b/dfx.json @@ -4,6 +4,11 @@ "candid": "backend/backend.did", "package": "backend", "type": "rust" + }, + "bounty": { + "candid": "bounty/bounty.did", + "package": "bounty", + "type": "rust" } }, "defaults": {