From 8a01ebeb50e3f60576180320c02043f248a5cc7e Mon Sep 17 00:00:00 2001
From: Stephen Antoni <155085865+steve24grd@users.noreply.github.com>
Date: Thu, 8 Aug 2024 10:24:44 +0700
Subject: [PATCH] fix: apply consistent naming for canister, directory and
 project (#26)

Co-authored-by: Stephen Antoni <luxeaves@gmail.com>
Co-authored-by: Agustinus Theodorus <agustinustheoo@gmail.com>
---
 .github/workflows/build-and-test.yml                   |  2 +-
 .maintain/README.md                                    |  4 ++--
 .maintain/deploy.sh                                    |  4 ++--
 Cargo.lock                                             |  2 +-
 Cargo.toml                                             |  2 +-
 README.md                                              |  2 +-
 canister_ids.json                                      |  5 +----
 dfx.json                                               | 10 +++++-----
 docs/canister-deployment-guideline.md                  |  4 ++--
 package-lock.json                                      |  4 ++--
 package.json                                           |  8 ++++----
 .../Cargo.toml                                         |  2 +-
 .../icp_prototype_backend.did.ts                       |  0
 .../icp_subaccount_indexer.did}                        |  0
 .../src/hashof.rs                                      |  0
 .../src/ledger.rs                                      |  0
 .../src/lib.rs                                         |  0
 .../src/memory.rs                                      |  0
 .../src/tests.rs                                       |  0
 .../src/types.rs                                       |  0
 20 files changed, 23 insertions(+), 26 deletions(-)
 rename src/{icp_prototype_backend => icp_subaccount_indexer}/Cargo.toml (96%)
 rename src/{icp_prototype_backend => icp_subaccount_indexer}/icp_prototype_backend.did.ts (100%)
 rename src/{icp_prototype_backend/icp_prototype_backend.did => icp_subaccount_indexer/icp_subaccount_indexer.did} (100%)
 rename src/{icp_prototype_backend => icp_subaccount_indexer}/src/hashof.rs (100%)
 rename src/{icp_prototype_backend => icp_subaccount_indexer}/src/ledger.rs (100%)
 rename src/{icp_prototype_backend => icp_subaccount_indexer}/src/lib.rs (100%)
 rename src/{icp_prototype_backend => icp_subaccount_indexer}/src/memory.rs (100%)
 rename src/{icp_prototype_backend => icp_subaccount_indexer}/src/tests.rs (100%)
 rename src/{icp_prototype_backend => icp_subaccount_indexer}/src/types.rs (100%)

diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index a274fef..45223d5 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -33,7 +33,7 @@ jobs:
         run: cargo clippy -- -D warnings
 
       - name: Build with cargo
-        run: cargo build --release --target wasm32-unknown-unknown --package icp_prototype_backend
+        run: cargo build --release --target wasm32-unknown-unknown --package icp_subaccount_indexer
 
       - name: Run tests with cargo
         run: cargo test --features "happy_path" && cargo test --features "sad_path"
diff --git a/.maintain/README.md b/.maintain/README.md
index 9329b8b..207b1db 100644
--- a/.maintain/README.md
+++ b/.maintain/README.md
@@ -57,7 +57,7 @@ Create or modify `canister_ids.json` in the project root:
 
 ```json
 {
-  "icp_prototype_backend": {
+  "icp_subaccount_indexer": {
     "ic": "upy4y-myaaa-aaaaal-qjbxa-cai"
   }
 }
@@ -97,7 +97,7 @@ Use the `deploy.sh` script for deployment:
 Alternatively, you can use the dfx command directly:
 
 ```bash
-dfx deploy icp_prototype_backend --network ic --no-wallet --argument "(variant { Mainnet }, 15 : nat64, 10 : nat32, \"ryjl3-tyaaa-aaaaa-aaaba-cai\", \"$CUSTODIAN_PRINCIPAL\")"
+dfx deploy icp_subaccount_indexer --network ic --no-wallet --argument "(variant { Mainnet }, 15 : nat64, 10 : nat32, \"ryjl3-tyaaa-aaaaa-aaaba-cai\", \"$CUSTODIAN_PRINCIPAL\")"
 ```
 
 Note: If you encounter issues with the `wasm32-unknown-unknown` target, install it:
diff --git a/.maintain/deploy.sh b/.maintain/deploy.sh
index e9b511d..3fec9b1 100755
--- a/.maintain/deploy.sh
+++ b/.maintain/deploy.sh
@@ -105,9 +105,9 @@ print_colored "$GREEN" "Custodian Principal: $CUSTODIAN_PRINCIPAL"
 # Deploy the backend canister
 print_colored "$YELLOW" "Deploying backend canister..."
 if [ "$NETWORK" = "ic" ]; then
-    dfx deploy icp_prototype_backend --network ic --no-wallet --argument "(variant { Mainnet }, 15 : nat64, 10 : nat32, \"ryjl3-tyaaa-aaaaa-aaaba-cai\", \"$CUSTODIAN_PRINCIPAL\")"
+    dfx deploy icp_subaccount_indexer --network ic --no-wallet --argument "(variant { Mainnet }, 15 : nat64, 10 : nat32, \"ryjl3-tyaaa-aaaaa-aaaba-cai\", \"$CUSTODIAN_PRINCIPAL\")"
 else
-    dfx deploy icp_prototype_backend --network "$NETWORK" --argument "(variant { Local }, 15 : nat64, 10 : nat32, \"ryjl3-tyaaa-aaaaa-aaaba-cai\", \"$CUSTODIAN_PRINCIPAL\")"
+    dfx deploy icp_subaccount_indexer --network "$NETWORK" --argument "(variant { Local }, 15 : nat64, 10 : nat32, \"ryjl3-tyaaa-aaaaa-aaaba-cai\", \"$CUSTODIAN_PRINCIPAL\")"
 fi
 check_command "Deploy backend canister"
 
diff --git a/Cargo.lock b/Cargo.lock
index d4a6663..19e60e3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -471,7 +471,7 @@ dependencies = [
 ]
 
 [[package]]
-name = "icp_prototype_backend"
+name = "icp_subaccount_indexer"
 version = "0.1.0"
 dependencies = [
  "candid",
diff --git a/Cargo.toml b/Cargo.toml
index 5e5fea7..04815b5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
 [workspace]
 members = [
-    "src/icp_prototype_backend"
+    "src/icp_subaccount_indexer"
 ]
 resolver = "2"
diff --git a/README.md b/README.md
index 99141e5..17d01a3 100644
--- a/README.md
+++ b/README.md
@@ -67,7 +67,7 @@ ICSI is built with a focus on modularity and extensibility. The core components
 ## Canister Methods
 
 The canister provides several methods to assist with ICP-token deposit management. The complete methods can be observed inside
-[Candid File](./src/icp_prototype_backend/icp_prototype_backend.did)
+[Candid File](./src/icp_subaccount_indexer/icp_subaccount_indexer.did)
 
 ```
 add_subaccount : () -> (variant { Ok : text; Err : Error });
diff --git a/canister_ids.json b/canister_ids.json
index 4020abd..ad1d19b 100644
--- a/canister_ids.json
+++ b/canister_ids.json
@@ -1,8 +1,5 @@
 {
-  "icp_prototype_backend": {
+  "icp_subaccount_indexer": {
     "ic": "uiz2m-baaaa-aaaal-qjbxq-cai"
-  },
-  "www": {
-    "ic": "upy4y-myaaa-aaaal-qjbxa-cai"
   }
 }
diff --git a/dfx.json b/dfx.json
index 441b773..085be49 100644
--- a/dfx.json
+++ b/dfx.json
@@ -10,9 +10,9 @@
         }
       }
     },
-    "icp_prototype_backend": {
-      "candid": "src/icp_prototype_backend/icp_prototype_backend.did",
-      "package": "icp_prototype_backend",
+    "icp_subaccount_indexer": {
+      "candid": "src/icp_subaccount_indexer/icp_subaccount_indexer.did",
+      "package": "icp_subaccount_indexer",
       "type": "rust"
     }
   },
@@ -31,14 +31,14 @@
   "environments": {
     "local": {
       "canisters": {
-        "icp_prototype_backend": {
+        "icp_subaccount_indexer": {
           "dependencies": ["icp_ledger_canister"]
         }
       }
     },
     "ic": {
       "canisters": {
-        "icp_prototype_backend": {}
+        "icp_subaccount_indexer": {}
       }
     }
   },
diff --git a/docs/canister-deployment-guideline.md b/docs/canister-deployment-guideline.md
index bfc9c6e..5eeca65 100644
--- a/docs/canister-deployment-guideline.md
+++ b/docs/canister-deployment-guideline.md
@@ -85,7 +85,7 @@ Within your project’s root directory, add or adjust the following file `canist
 
 ```json
 {
-  "icp_prototype_backend": {
+  "icp_subaccount_indexer": {
     "ic": "upy4y-myaaa-aaaal-qjbxa-cai"
   }
 }
@@ -112,7 +112,7 @@ dfx cycles convert 0.3 --network ic
 Ensure the currently active identity is the correct `custodian` identity linked as the controller on NNS from previous steps. Don’t forget to export the value for `CUSTODIAN_PRINCIPAL` using the sub-step from step 5.
 
 ```bash
-dfx deploy icp_prototype_backend --network ic --no-wallet --argument "(variant { Mainnet }, 15 : nat64, 10 : nat32, \"ryjl3-tyaaa-aaaaa-aaaba-cai\", \"$(echo $CUSTODIAN_PRINCIPAL)\")"
+dfx deploy icp_subaccount_indexer --network ic --no-wallet --argument "(variant { Mainnet }, 15 : nat64, 10 : nat32, \"ryjl3-tyaaa-aaaaa-aaaba-cai\", \"$(echo $CUSTODIAN_PRINCIPAL)\")"
 ```
 
 Some roadblocks you may encounter:
diff --git a/package-lock.json b/package-lock.json
index febae74..9e38ca0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,10 +1,10 @@
 {
-  "name": "icp_prototype",
+  "name": "icp_subaccount_indexer",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
-      "name": "icp_prototype",
+      "name": "icp_subaccount_indexer",
       "dependencies": {
         "@dfinity/agent": "^1.0.1",
         "@dfinity/candid": "^1.0.1",
diff --git a/package.json b/package.json
index 377048b..616c9f6 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
 {
-  "name": "icp_prototype",
+  "name": "icp_subaccount_indexer",
   "type": "module",
   "scripts": {
     "build": "webpack",
@@ -8,10 +8,10 @@
     "start:local:env": "dfx start --clean --host 127.0.0.1:8000 --use-old-metering",
     "deploy:local": ".maintain/deploy.sh",
     "deploy:ic": "dfx deploy --network=ic",
-    "generate": "npm run generate:did && dfx generate icp_prototype_backend",
+    "generate": "npm run generate:did && dfx generate icp_subaccount_indexer",
     "generate:did": "npm run generate:did:backend && npm run generate:did:ts",
-    "generate:did:ts": "didc bind src/icp_prototype_backend/icp_prototype_backend.did -t ts > src/icp_prototype_backend/icp_prototype_backend.did.ts",
-    "generate:did:backend": "cargo build --release --target wasm32-unknown-unknown --package icp_prototype_backend && candid-extractor target/wasm32-unknown-unknown/release/icp_prototype_backend.wasm > src/icp_prototype_backend/icp_prototype_backend.did",
+    "generate:did:ts": "didc bind src/icp_subaccount_indexer/icp_subaccount_indexer.did -t ts > src/icp_subaccount_indexer/icp_subaccount_indexer.did.ts",
+    "generate:did:backend": "cargo build --release --target wasm32-unknown-unknown --package icp_subaccount_indexer && candid-extractor target/wasm32-unknown-unknown/release/icp_subaccount_indexer.wasm > src/icp_subaccount_indexer/icp_subaccount_indexer.did",
     "format": "cargo fmt && prettier --write .",
     "test:happy_path": "cargo test --features 'happy_path'",
     "test:sad_path": "cargo test --features 'sad_path'",
diff --git a/src/icp_prototype_backend/Cargo.toml b/src/icp_subaccount_indexer/Cargo.toml
similarity index 96%
rename from src/icp_prototype_backend/Cargo.toml
rename to src/icp_subaccount_indexer/Cargo.toml
index c42513e..5d3a898 100644
--- a/src/icp_prototype_backend/Cargo.toml
+++ b/src/icp_subaccount_indexer/Cargo.toml
@@ -1,5 +1,5 @@
 [package]
-name = "icp_prototype_backend"
+name = "icp_subaccount_indexer"
 version = "0.1.0"
 edition = "2021"
 
diff --git a/src/icp_prototype_backend/icp_prototype_backend.did.ts b/src/icp_subaccount_indexer/icp_prototype_backend.did.ts
similarity index 100%
rename from src/icp_prototype_backend/icp_prototype_backend.did.ts
rename to src/icp_subaccount_indexer/icp_prototype_backend.did.ts
diff --git a/src/icp_prototype_backend/icp_prototype_backend.did b/src/icp_subaccount_indexer/icp_subaccount_indexer.did
similarity index 100%
rename from src/icp_prototype_backend/icp_prototype_backend.did
rename to src/icp_subaccount_indexer/icp_subaccount_indexer.did
diff --git a/src/icp_prototype_backend/src/hashof.rs b/src/icp_subaccount_indexer/src/hashof.rs
similarity index 100%
rename from src/icp_prototype_backend/src/hashof.rs
rename to src/icp_subaccount_indexer/src/hashof.rs
diff --git a/src/icp_prototype_backend/src/ledger.rs b/src/icp_subaccount_indexer/src/ledger.rs
similarity index 100%
rename from src/icp_prototype_backend/src/ledger.rs
rename to src/icp_subaccount_indexer/src/ledger.rs
diff --git a/src/icp_prototype_backend/src/lib.rs b/src/icp_subaccount_indexer/src/lib.rs
similarity index 100%
rename from src/icp_prototype_backend/src/lib.rs
rename to src/icp_subaccount_indexer/src/lib.rs
diff --git a/src/icp_prototype_backend/src/memory.rs b/src/icp_subaccount_indexer/src/memory.rs
similarity index 100%
rename from src/icp_prototype_backend/src/memory.rs
rename to src/icp_subaccount_indexer/src/memory.rs
diff --git a/src/icp_prototype_backend/src/tests.rs b/src/icp_subaccount_indexer/src/tests.rs
similarity index 100%
rename from src/icp_prototype_backend/src/tests.rs
rename to src/icp_subaccount_indexer/src/tests.rs
diff --git a/src/icp_prototype_backend/src/types.rs b/src/icp_subaccount_indexer/src/types.rs
similarity index 100%
rename from src/icp_prototype_backend/src/types.rs
rename to src/icp_subaccount_indexer/src/types.rs