Skip to content

Commit db980a0

Browse files
docs: streamline ai docs + readme
1 parent 57e70e5 commit db980a0

File tree

8 files changed

+254
-1338
lines changed

8 files changed

+254
-1338
lines changed

.github/copilot-instructions.md

Lines changed: 111 additions & 209 deletions
Large diffs are not rendered by default.

API_REFERENCE.md

Lines changed: 0 additions & 817 deletions
This file was deleted.

README.md

Lines changed: 94 additions & 257 deletions
Large diffs are not rendered by default.

ai_first_template_todos.md

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,25 @@ Quick reference for enhancing this starter repo for AI-assisted development.
2929

3030
## 📚 Documentation Improvements
3131

32-
### 4. Consolidate API_REFERENCE.md
32+
### 4. API_REFERENCE.md Removed
3333

34-
**Current issue:** 90% overlap with README creates maintenance burden
34+
**Decision:** Deleted to avoid documentation drift
3535

36-
**Options:**
37-
- **A)** Merge into README, keep API_REFERENCE as pure method signatures only
38-
- **B)** Keep API_REFERENCE comprehensive, make README a quickstart only
39-
- **Recommended:** Option A - developers expect README to be comprehensive
36+
**Rationale:**
37+
- SDK has comprehensive docstrings in `module_base.py` for all methods
38+
- Duplicating method docs creates maintenance burden
39+
- AI can read SDK source directly via `semantic_search()`
40+
- Examples (01→05) demonstrate all patterns
41+
42+
**Unique Content to Integrate Later:**
43+
- Naming conventions table (Python/Query/Events) → Add to README.md
44+
- Query syntax with system attributes (`$owner`, `$content_type`) → Add to README.md or copilot-instructions.md
45+
- Event handling patterns (camelCase in events) → Already covered in copilot-instructions.md
46+
47+
**Action Items:**
48+
- [ ] Add naming conventions quick reference table to README
49+
- [ ] Add query syntax section to README (system attributes)
50+
- [ ] Ensure copilot-instructions.md covers event naming
4051

4152
### 5. Add "Next Steps" Comments to Examples
4253

@@ -64,40 +75,6 @@ Add to README:
6475

6576
---
6677

67-
## 🧪 Testing Enhancements
68-
69-
### 7. Add Tests for Remaining Examples
70-
71-
**Currently tested:** 01_basic_crud, 02_queries, utilities
72-
73-
**Missing:**
74-
- `test_03_events.py` - Event watching patterns
75-
- `test_04_web3_integration.py` - Direct contract interaction
76-
77-
**Note:** Current tests are actually good examples! They show:
78-
- Time conversion utilities
79-
- Entity existence checks
80-
- Extension patterns
81-
- Field mask usage
82-
83-
### 8. Test for Common Mistakes
84-
85-
Add tests that catch typical errors:
86-
```python
87-
def test_content_type_in_query():
88-
"""Ensure snake_case used in queries (common AI mistake)."""
89-
# Should use $content_type not $contentType
90-
result = client.arkiv.query_entities('$content_type = "text/plain"')
91-
assert len(list(result)) >= 0 # Should not raise error
92-
93-
def test_event_arg_naming():
94-
"""Document that event args use camelCase."""
95-
# This test is documentation for AI
96-
pass
97-
```
98-
99-
---
100-
10178
## 🚀 Advanced Patterns
10279

10380
### 9. Common Patterns Library (Optional)
@@ -139,7 +116,7 @@ from arkiv import Arkiv
139116

140117
## 🎨 Visual/Media
141118

142-
### 11. Demo GIF or Video
119+
### 11. Demo Video
143120

144121
- **README.md**: Embed 60-second demo showing repo → run → output
145122
- AI can't create this but can prompt maintainer to add it
@@ -181,9 +158,8 @@ Add to README or separate `TROUBLESHOOTING.md`:
181158
| 🔴 HIGH | Medium | High | #3 - Mini Chat Example |
182159
| 🟡 MEDIUM | Low | Medium | #5 - "Next Steps" Comments |
183160
| 🟡 MEDIUM | Low | Medium | #6 - Quick Reference Table |
184-
| 🟡 MEDIUM | Medium | Medium | #4 - Consolidate API_REFERENCE |
185161
| 🟢 LOW | Medium | Low | #9 - Patterns Library |
186-
| 🟢 LOW | High | Medium | #11 - Demo GIF |
162+
| 🟢 LOW | High | Medium | #11 - Demo Video |
187163

188164
---
189165

@@ -198,7 +174,7 @@ Add to README or separate `TROUBLESHOOTING.md`:
198174
5. Add Quick Reference table to README (1 hour)
199175

200176
**Week 3 (Polish):**
201-
6. Consolidate API_REFERENCE.md (2 hours)
177+
6. Integrate unique API_REFERENCE content to README (1 hour)
202178
7. Add troubleshooting section (1 hour)
203179

204180
**Ongoing:**

src/arkiv_starter/01_clients.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@
9898
print(" - Useful for testing ownership transfers\n")
9999

100100
original_account = client.eth.default_account
101+
original_signer = client.current_signer # Track the current signer name
101102
print(f"📋 Starting with account: {original_account}")
103+
print(f" Current signer name: {original_signer}")
102104

103105
# Create and add a second account
104106
account_name = "second-account"
@@ -126,10 +128,14 @@
126128
print(f"✅ Entity created: {entity_key3}")
127129
print(f" Owner: {entity.owner if entity else 'N/A'}\n")
128130

129-
# Switch back to original (use account name from registry)
131+
# Switch back to original (use current_signer to track the name)
130132
print("🔄 Switching back to original account...")
131-
client.switch_to("default") # Use account name, not address
132-
print(f"✅ Now signing with: {client.eth.default_account}\n")
133+
if original_signer:
134+
client.switch_to(original_signer) # Use the saved signer name
135+
print(f"✅ Now signing with: {client.eth.default_account}")
136+
print(f" Current signer name: {client.current_signer}\n")
137+
else:
138+
print("⚠️ No original signer to switch back to\n")
133139

134140

135141
print("=" * 70)
@@ -178,6 +184,7 @@
178184
✅ Testing ownership transfers
179185
✅ Multi-user scenarios
180186
✅ Demonstrating permissions
187+
💡 Use client.current_signer to track current account name
181188
182189
5. NODE REFERENCE (client.node):
183190
✅ Fund test accounts

src/arkiv_starter/02_entity_crud.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
print(f" Extended expiration: {extended_entity.expires_at_block}\n")
7575

7676
print("👤 Step 5: Changing entity owner...")
77+
# Track original signer before switching
78+
original_signer = client.current_signer
79+
print(f" Current signer: {original_signer}")
80+
7781
# Create a new account to transfer ownership to
7882
from arkiv import NamedAccount
7983
new_owner_account = NamedAccount.create("new-owner")
@@ -94,8 +98,10 @@
9498

9599
print("🗑️ Step 6: Deleting entity (as new owner)...")
96100
# Switch to new owner to delete (only owner can delete)
101+
print(f" Switching from '{client.current_signer}' to 'new-owner' account...")
97102
client.accounts["new-owner"] = new_owner_account
98103
client.switch_to("new-owner")
104+
print(f" Current signer: {client.current_signer}")
99105

100106
receipt = client.arkiv.delete_entity(entity_key)
101107
print(f"✅ Entity deleted!")

src/arkiv_starter/04_events.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,21 @@ def on_owner_changed(event: ChangeOwnerEvent, tx_hash: TxHash) -> None:
104104
print(f" Extended entity: {entity_key}")
105105

106106
print("4️⃣ Operation 4: Changing entity owner...")
107+
original_signer = client.current_signer # Track original account name
107108
account_name = "new-owner"
108109
new_account = NamedAccount.create(account_name)
109110
receipt = client.arkiv.change_owner(entity_key, new_account.address)
110-
print(f" Changed owner of entity: {entity_key} to {new_account.address} ")
111+
print(f" Changed owner of entity: {entity_key} to {new_account.address}")
112+
print(f" Original signer: {original_signer}")
111113

112114
print("5️⃣ Operation 5: Deleting entity (as new owner)...")
113115
node = client.node
114116
assert node is not None
115117
node.fund_account(new_account) # Fund the new account
116-
client.accounts[account_name] = new_account # Add to client accounts
117-
client.switch_to(account_name) # Switch signing account to new owner
118+
client.accounts[account_name] = new_account # Add to client accounts
119+
print(f" Switching from '{client.current_signer}' to '{account_name}' account...")
120+
client.switch_to(account_name) # Switch signing account to new owner
121+
print(f" Current signer: {client.current_signer}")
118122
receipt = client.arkiv.delete_entity(entity_key)
119123
print(f" Deleted entity: {entity_key}")
120124

tests/test_01_clients.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def test_multiple_accounts_switch_to(arkiv_node):
7777
client = Arkiv(provider, account=account)
7878

7979
original_account = client.eth.default_account
80+
original_signer = client.current_signer # Track original account name
81+
assert original_signer is not None
8082

8183
# Create and add second account
8284
second_account = NamedAccount.create("test-second-account")
@@ -91,6 +93,7 @@ def test_multiple_accounts_switch_to(arkiv_node):
9193
# Switch to second account
9294
client.switch_to("second-account")
9395
assert client.eth.default_account == second_account.address
96+
assert client.current_signer == "second-account"
9497

9598
# Create entity with second account
9699
entity_key, receipt = client.arkiv.create_entity(
@@ -104,12 +107,10 @@ def test_multiple_accounts_switch_to(arkiv_node):
104107
assert entity is not None
105108
assert entity.owner == second_account.address
106109

107-
# Switch back to original (need to find the key)
108-
for name, acc in client.accounts.items():
109-
if acc.address == original_account:
110-
client.switch_to(name)
111-
break
110+
# Switch back to original using tracked signer name
111+
client.switch_to(original_signer)
112112
assert client.eth.default_account == original_account
113+
assert client.current_signer == original_signer
113114

114115

115116
def test_node_reference():

0 commit comments

Comments
 (0)