movementkit-cli 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/index.js +11 -7
  2. package/kits/engineer/.claude/agents/devops.md +176 -0
  3. package/kits/engineer/.claude/agents/frontend.md +207 -0
  4. package/kits/engineer/.claude/agents/smart-contract.md +150 -0
  5. package/kits/engineer/.claude/agents/tester.md +174 -0
  6. package/kits/engineer/.claude/commands/cook/contracts.md +174 -0
  7. package/kits/engineer/.claude/commands/cook/frontend.md +325 -0
  8. package/kits/engineer/.claude/commands/cook.md +118 -0
  9. package/kits/engineer/.claude/commands/deploy-full.md +158 -0
  10. package/kits/engineer/.claude/commands/deploy-smart-contract.md +177 -0
  11. package/kits/engineer/.claude/commands/docs/generate.md +121 -0
  12. package/kits/engineer/.claude/commands/docs/init.md +132 -0
  13. package/kits/engineer/.claude/commands/plan.md +103 -0
  14. package/kits/engineer/.claude/commands/review.md +98 -0
  15. package/kits/engineer/.claude/commands/test.md +92 -0
  16. package/kits/engineer/.claude/commands/watzup.md +100 -0
  17. package/kits/engineer/.claude/workflows/development-rules.md +110 -0
  18. package/kits/engineer/.claude/workflows/primary-workflow.md +95 -0
  19. package/kits/engineer/CLAUDE.md +105 -0
  20. package/kits/engineer/contracts/Move.toml +13 -0
  21. package/kits/engineer/contracts/sources/counter.move +122 -0
  22. package/kits/engineer/contracts/tests/counter_tests.move +96 -0
  23. package/kits/engineer/docs/MOVE_LANGUAGE_REFERENCE.md +560 -0
  24. package/kits/engineer/frontend/.env.example +9 -0
  25. package/kits/engineer/frontend/index.html +14 -0
  26. package/kits/engineer/frontend/package.json +29 -0
  27. package/kits/engineer/frontend/src/App.tsx +41 -0
  28. package/kits/engineer/frontend/src/components/WalletConnect.tsx +54 -0
  29. package/kits/engineer/frontend/src/contexts/WalletContext.tsx +42 -0
  30. package/kits/engineer/frontend/src/hooks/useContract.ts +95 -0
  31. package/kits/engineer/frontend/src/index.css +76 -0
  32. package/kits/engineer/frontend/src/main.tsx +11 -0
  33. package/kits/engineer/frontend/tsconfig.json +22 -0
  34. package/kits/engineer/frontend/tsconfig.node.json +11 -0
  35. package/kits/engineer/frontend/vite.config.ts +17 -0
  36. package/package.json +3 -2
@@ -0,0 +1,13 @@
1
+ [package]
2
+ name = "movement_dapp"
3
+ version = "1.0.0"
4
+ authors = []
5
+
6
+ [addresses]
7
+ module_addr = "_"
8
+
9
+ [dependencies]
10
+ AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework", rev = "mainnet" }
11
+ AptosStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-stdlib", rev = "mainnet" }
12
+ MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib", rev = "mainnet" }
13
+
@@ -0,0 +1,122 @@
1
+ /// A simple counter module demonstrating basic Move patterns on Movement blockchain.
2
+ /// This serves as a template for building more complex dApps.
3
+ module module_addr::counter {
4
+ use std::signer;
5
+ use aptos_framework::event;
6
+
7
+ // ==================== Error Codes ====================
8
+
9
+ /// Error when counter doesn't exist for the account
10
+ const E_COUNTER_NOT_FOUND: u64 = 1;
11
+ /// Error when counter already exists for the account
12
+ const E_COUNTER_ALREADY_EXISTS: u64 = 2;
13
+
14
+ // ==================== Resources ====================
15
+
16
+ /// Counter resource stored at each user's address
17
+ struct Counter has key {
18
+ value: u64,
19
+ }
20
+
21
+ // ==================== Events ====================
22
+
23
+ /// Event emitted when a counter is created
24
+ #[event]
25
+ struct CounterCreated has drop, store {
26
+ account: address,
27
+ initial_value: u64,
28
+ }
29
+
30
+ /// Event emitted when a counter is incremented
31
+ #[event]
32
+ struct CounterIncremented has drop, store {
33
+ account: address,
34
+ old_value: u64,
35
+ new_value: u64,
36
+ }
37
+
38
+ /// Event emitted when a counter is decremented
39
+ #[event]
40
+ struct CounterDecremented has drop, store {
41
+ account: address,
42
+ old_value: u64,
43
+ new_value: u64,
44
+ }
45
+
46
+ // ==================== Entry Functions ====================
47
+
48
+ /// Initialize a new counter for the calling account
49
+ public entry fun initialize(account: &signer) {
50
+ let addr = signer::address_of(account);
51
+ assert!(!exists<Counter>(addr), E_COUNTER_ALREADY_EXISTS);
52
+
53
+ move_to(account, Counter { value: 0 });
54
+
55
+ event::emit(CounterCreated {
56
+ account: addr,
57
+ initial_value: 0,
58
+ });
59
+ }
60
+
61
+ /// Increment the counter by 1
62
+ public entry fun increment(account: &signer) acquires Counter {
63
+ let addr = signer::address_of(account);
64
+ assert!(exists<Counter>(addr), E_COUNTER_NOT_FOUND);
65
+
66
+ let counter = borrow_global_mut<Counter>(addr);
67
+ let old_value = counter.value;
68
+ counter.value = counter.value + 1;
69
+
70
+ event::emit(CounterIncremented {
71
+ account: addr,
72
+ old_value,
73
+ new_value: counter.value,
74
+ });
75
+ }
76
+
77
+ /// Decrement the counter by 1 (saturating at 0)
78
+ public entry fun decrement(account: &signer) acquires Counter {
79
+ let addr = signer::address_of(account);
80
+ assert!(exists<Counter>(addr), E_COUNTER_NOT_FOUND);
81
+
82
+ let counter = borrow_global_mut<Counter>(addr);
83
+ let old_value = counter.value;
84
+
85
+ if (counter.value > 0) {
86
+ counter.value = counter.value - 1;
87
+ };
88
+
89
+ event::emit(CounterDecremented {
90
+ account: addr,
91
+ old_value,
92
+ new_value: counter.value,
93
+ });
94
+ }
95
+
96
+ /// Set the counter to a specific value
97
+ public entry fun set_value(account: &signer, new_value: u64) acquires Counter {
98
+ let addr = signer::address_of(account);
99
+ assert!(exists<Counter>(addr), E_COUNTER_NOT_FOUND);
100
+
101
+ let counter = borrow_global_mut<Counter>(addr);
102
+ counter.value = new_value;
103
+ }
104
+
105
+ // ==================== View Functions ====================
106
+
107
+ /// Get the current counter value for an address
108
+ #[view]
109
+ public fun get_count(addr: address): u64 acquires Counter {
110
+ if (!exists<Counter>(addr)) {
111
+ return 0
112
+ };
113
+ borrow_global<Counter>(addr).value
114
+ }
115
+
116
+ /// Check if a counter exists for an address
117
+ #[view]
118
+ public fun has_counter(addr: address): bool {
119
+ exists<Counter>(addr)
120
+ }
121
+ }
122
+
@@ -0,0 +1,96 @@
1
+ #[test_only]
2
+ module module_addr::counter_tests {
3
+ use std::signer;
4
+ use module_addr::counter;
5
+
6
+ #[test(account = @0x1)]
7
+ fun test_initialize(account: &signer) {
8
+ // Initialize counter
9
+ counter::initialize(account);
10
+
11
+ // Verify counter exists and has value 0
12
+ let addr = signer::address_of(account);
13
+ assert!(counter::has_counter(addr), 0);
14
+ assert!(counter::get_count(addr) == 0, 1);
15
+ }
16
+
17
+ #[test(account = @0x1)]
18
+ fun test_increment(account: &signer) {
19
+ // Setup
20
+ counter::initialize(account);
21
+ let addr = signer::address_of(account);
22
+
23
+ // Increment
24
+ counter::increment(account);
25
+ assert!(counter::get_count(addr) == 1, 0);
26
+
27
+ // Increment again
28
+ counter::increment(account);
29
+ assert!(counter::get_count(addr) == 2, 1);
30
+ }
31
+
32
+ #[test(account = @0x1)]
33
+ fun test_decrement(account: &signer) {
34
+ // Setup
35
+ counter::initialize(account);
36
+ let addr = signer::address_of(account);
37
+
38
+ // Increment first
39
+ counter::increment(account);
40
+ counter::increment(account);
41
+ assert!(counter::get_count(addr) == 2, 0);
42
+
43
+ // Decrement
44
+ counter::decrement(account);
45
+ assert!(counter::get_count(addr) == 1, 1);
46
+ }
47
+
48
+ #[test(account = @0x1)]
49
+ fun test_decrement_at_zero(account: &signer) {
50
+ // Setup
51
+ counter::initialize(account);
52
+ let addr = signer::address_of(account);
53
+
54
+ // Decrement at 0 should stay at 0 (saturating)
55
+ counter::decrement(account);
56
+ assert!(counter::get_count(addr) == 0, 0);
57
+ }
58
+
59
+ #[test(account = @0x1)]
60
+ fun test_set_value(account: &signer) {
61
+ // Setup
62
+ counter::initialize(account);
63
+ let addr = signer::address_of(account);
64
+
65
+ // Set value
66
+ counter::set_value(account, 100);
67
+ assert!(counter::get_count(addr) == 100, 0);
68
+ }
69
+
70
+ #[test(account = @0x1)]
71
+ #[expected_failure(abort_code = counter::E_COUNTER_ALREADY_EXISTS)]
72
+ fun test_double_initialize_fails(account: &signer) {
73
+ counter::initialize(account);
74
+ counter::initialize(account); // Should fail
75
+ }
76
+
77
+ #[test(account = @0x1)]
78
+ #[expected_failure(abort_code = counter::E_COUNTER_NOT_FOUND)]
79
+ fun test_increment_without_init_fails(account: &signer) {
80
+ counter::increment(account); // Should fail - no counter
81
+ }
82
+
83
+ #[test]
84
+ fun test_get_count_nonexistent() {
85
+ // Getting count for non-existent counter should return 0
86
+ let count = counter::get_count(@0x999);
87
+ assert!(count == 0, 0);
88
+ }
89
+
90
+ #[test]
91
+ fun test_has_counter_nonexistent() {
92
+ // Checking non-existent counter should return false
93
+ assert!(!counter::has_counter(@0x999), 0);
94
+ }
95
+ }
96
+