Skip to content

Commit fe3d298

Browse files
authored
Merge pull request #21 from arkanoider/restore-trade-index
Two proposals for a trade index synch message
2 parents 1bb54a2 + 8d67cb3 commit fe3d298

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- [Admin Cancel order](./admin_cancel_order.md)
2727
- [Admin Add Solver](./admin_add_solver.md)
2828
- [Restore session](./restore_session.md)
29+
- [Last Trade Index](./last_trade_index.md)
2930
- [Actions](./actions.md)
3031
- [Message suggestions for actions](./message_suggestions_for_actions.md)
3132
- [P2P Order event. NIP-69](./order_event.md)

src/last_trade_index.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Last Trade Index
2+
3+
Defines the `last-trade-index` action used to retrieve the user's last `trade_index`.
4+
5+
## Request
6+
7+
Client sends a Gift wrap Nostr event to Mostro with the following rumor's content. The request sends a `null` payload to indicate that the client is querying for the last trade index.
8+
9+
```json
10+
{
11+
"restore": {
12+
"version": 1,
13+
"action": "last-trade-index",
14+
"payload": null
15+
}
16+
}
17+
```
18+
19+
## Response
20+
21+
Mostro responds with the user's last trade index as a u32 directly in the `trade_index` field. If the user has never created a trade, the value SHOULD be `1`.
22+
23+
```json
24+
{
25+
"restore": {
26+
"version": 1,
27+
"action": "last-trade-index",
28+
"trade_index": 42,
29+
"payload": null
30+
}
31+
}
32+
```
33+
34+
### Fields
35+
36+
* `restore.version`: Protocol version. Current is `1`.
37+
* `restore.action`: Must be `last-trade-index`.
38+
* `restore.trade_index` (response): u32 representing the last `trade_index` for the user. `1` if none.
39+
* `restore.payload` (response): Must be `null`.
40+
41+
## Example
42+
43+
Client requests the last trade index and receives `7`, meaning the next trade the client creates SHOULD use `trade_index = 8`.
44+
45+
```json
46+
{
47+
"restore": {
48+
"version": 1,
49+
"action": "last-trade-index",
50+
"trade_index": 7,
51+
"payload": null
52+
}
53+
}
54+
```

0 commit comments

Comments
 (0)