Skip to content

Commit 6bba463

Browse files
authored
Merge pull request #90 from CmxTop/docs/contract-abi
docs: add contract ABI documentation to contract/ABI.md
2 parents 9e6d3bc + d7674df commit 6bba463

1 file changed

Lines changed: 111 additions & 0 deletions

File tree

contract/ABI.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# NovaSupport Contract ABI
2+
3+
Reference implementation: `contract/contracts/support_page/src/lib.rs`
4+
5+
## Contract ID
6+
7+
Deploy the contract to Stellar Testnet, then set `NEXT_PUBLIC_CONTRACT_ID` in `frontend/.env.local` to the deployed contract ID.
8+
9+
This repository does not currently include a checked-in deployed contract ID.
10+
11+
## Functions
12+
13+
### `support(env, supporter, recipient, amount, asset_code, message) -> u32`
14+
15+
Records a support action, requires authorization from the supporter, emits a `support` event, increments the global support counter, and returns the updated global count.
16+
17+
Parameters:
18+
19+
- `env: Env` - Soroban execution environment.
20+
- `supporter: Address` - Address that must authorize the call via `require_auth()`.
21+
- `recipient: Address` - Address receiving support.
22+
- `amount: i128` - Raw onchain support amount. The contract only checks that it is greater than zero.
23+
- `asset_code: String` - Asset code label such as `"XLM"` or `"USDC"`.
24+
- `message: String` - Arbitrary support message emitted with the event.
25+
26+
Returns:
27+
28+
- `u32` - Global support count after the current call completes.
29+
30+
Behavior:
31+
32+
- Rejects calls where `amount <= 0`.
33+
- Reads the current `SupportCount` from persistent storage.
34+
- Increments and stores the new `SupportCount`.
35+
- Emits a `support` event with the full payload.
36+
37+
Errors:
38+
39+
- No numeric Soroban error enum is defined in the current contract.
40+
- If `amount <= 0`, the contract panics with `amount must be positive`.
41+
- If `supporter` does not authorize the call, Soroban authorization fails.
42+
43+
### `support_count(env) -> u32`
44+
45+
Returns the total number of successful `support()` calls recorded by the contract.
46+
47+
Parameters:
48+
49+
- `env: Env` - Soroban execution environment.
50+
51+
Returns:
52+
53+
- `u32` - Current global support count.
54+
55+
Behavior:
56+
57+
- Reads `SupportCount` from persistent storage.
58+
- Returns `0` when no support has been recorded yet.
59+
60+
## Events
61+
62+
### Topic: `"support"`
63+
64+
Emitted on every successful `support()` call.
65+
66+
Event payload type:
67+
68+
```json
69+
{
70+
"supporter": "G...",
71+
"recipient": "G...",
72+
"amount": 10000000,
73+
"asset_code": "XLM",
74+
"message": "Keep building!"
75+
}
76+
```
77+
78+
Event fields:
79+
80+
- `supporter: Address` - Authorized caller.
81+
- `recipient: Address` - Support recipient.
82+
- `amount: i128` - Raw amount passed to `support()`.
83+
- `asset_code: String` - Asset code label.
84+
- `message: String` - Support message.
85+
86+
Notes:
87+
88+
- The event topic is the single symbol `support`.
89+
- The event payload does not include a timestamp.
90+
- The event payload does not include the global support count.
91+
92+
## Storage Keys
93+
94+
| Key | Type | Description |
95+
| --- | --- | --- |
96+
| `SupportCount` | `u32` | Global count of successful `support()` calls stored in persistent storage. |
97+
98+
## Error Codes
99+
100+
The current contract does not define numeric error codes or a custom Soroban error enum.
101+
102+
| Error | Value | Meaning |
103+
| --- | --- | --- |
104+
| `amount must be positive` | N/A | Triggered when `support()` is called with `amount <= 0`. |
105+
| Soroban auth failure | N/A | Triggered when `supporter` does not authorize the call. |
106+
107+
## ABI Notes
108+
109+
- `recipient_count(recipient)` is not implemented in the current contract.
110+
- `get_total_amount(recipient)` is not implemented in the current contract.
111+
- Per-recipient counters and per-recipient totals are not stored in the current contract.

0 commit comments

Comments
 (0)