From 347640a24604fa3148d9f9e94ad50d96fdefaaa8 Mon Sep 17 00:00:00 2001 From: arkanoider Date: Tue, 7 Oct 2025 14:42:52 +0200 Subject: [PATCH 1/7] feat: two options to add a new message for synch last trade index of a user between clients and mostro --- src/restore_trade_index.md | 58 ++++++++++++++++++++++++ src/restore_trade_index_second_option.md | 54 ++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 src/restore_trade_index.md create mode 100644 src/restore_trade_index_second_option.md diff --git a/src/restore_trade_index.md b/src/restore_trade_index.md new file mode 100644 index 0000000..60f8594 --- /dev/null +++ b/src/restore_trade_index.md @@ -0,0 +1,58 @@ +# Restore Trade Index + +Use this message to request the last trade index associated with the user's mnemonic, while keeping the `restore-session` action. This allows clients to resume indexing from the correct `trade_index` value without changing the action name. + +## Request + +Client sends a Gift wrap Nostr event to Mostro with the following rumor's content. The client indicates the request by sending a `payload` object with a `last_trade_index` key set to `null`: + +```json +{ + "restore": { + "version": 1, + "action": "restore-session", + "payload": { + "last_trade_index": null + } + } +} +``` + +## Response + +Mostro responds with the user's last trade index as a u32 under the same `payload.last_trade_index` key. If the user has never created a trade, the value SHOULD be `1`. + +```json +{ + "restore": { + "version": 1, + "action": "restore-session", + "payload": { + "last_trade_index": 42 + } + } +} +``` + +### Fields + +* `restore.version`: Protocol version. Current is `1`. +* `restore.action`: Must be `restore-session`. +* `restore.payload.last_trade_index` (request): Must be `null` to indicate a query. +* `restore.payload.last_trade_index` (response): u32 representing the last `trade_index` for the user. `1` if none. + +## Example + +Client requests the last trade index and receives `7`, meaning the next trade the client creates SHOULD use `trade_index = 8`. + +```json +{ + "restore": { + "version": 1, + "action": "restore-session", + "payload": { + "last_trade_index": 7 + } + } +} +``` diff --git a/src/restore_trade_index_second_option.md b/src/restore_trade_index_second_option.md new file mode 100644 index 0000000..ad24db5 --- /dev/null +++ b/src/restore_trade_index_second_option.md @@ -0,0 +1,54 @@ +# Sync Trade Index + +Defines the `synch-trade-index` action used to retrieve the user's last `trade_index`. + +## Request + +Client sends a Gift wrap Nostr event to Mostro with the following rumor's content. The request uses a `null` payload to indicate that the client is querying for the last trade index. + +```json +{ + "restore": { + "version": 1, + "action": "synch-trade-index", + "payload": null + } +} +``` + +## Response + +Mostro responds with the user's last trade index as a u32 directly in the `payload` field. If the user has never created a trade, the value SHOULD be `1`. + +```json +{ + "restore": { + "version": 1, + "action": "synch-trade-index", + "payload": 42 + } +} +``` + +### Fields + +* `restore.version`: Protocol version. Current is `1`. +* `restore.action`: Must be `synch-trade-index`. +* `restore.payload` (request): Must be `null` when querying. +* `restore.payload` (response): u32 representing the last `trade_index` for the user. `1` if none. + +## Example + +Client requests the last trade index and receives `7`, meaning the next trade the client creates SHOULD use `trade_index = 8`. + +```json +{ + "restore": { + "version": 1, + "action": "synch-trade-index", + "payload": 7 + } +} +``` + + From ee5a7b3f28d9c4e31d4e4adc791107ffb840e2f5 Mon Sep 17 00:00:00 2001 From: arkanoider Date: Tue, 7 Oct 2025 14:51:21 +0200 Subject: [PATCH 2/7] chore: typo on second option --- src/restore_trade_index_second_option.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/restore_trade_index_second_option.md b/src/restore_trade_index_second_option.md index ad24db5..04a45ad 100644 --- a/src/restore_trade_index_second_option.md +++ b/src/restore_trade_index_second_option.md @@ -10,7 +10,7 @@ Client sends a Gift wrap Nostr event to Mostro with the following rumor's conten { "restore": { "version": 1, - "action": "synch-trade-index", + "action": "last-trade-index", "payload": null } } @@ -24,7 +24,7 @@ Mostro responds with the user's last trade index as a u32 directly in the `paylo { "restore": { "version": 1, - "action": "synch-trade-index", + "action": "last-trade-index", "payload": 42 } } @@ -33,7 +33,7 @@ Mostro responds with the user's last trade index as a u32 directly in the `paylo ### Fields * `restore.version`: Protocol version. Current is `1`. -* `restore.action`: Must be `synch-trade-index`. +* `restore.action`: Must be `last-trade-index`. * `restore.payload` (request): Must be `null` when querying. * `restore.payload` (response): u32 representing the last `trade_index` for the user. `1` if none. @@ -45,7 +45,7 @@ Client requests the last trade index and receives `7`, meaning the next trade th { "restore": { "version": 1, - "action": "synch-trade-index", + "action": "last-trade-index", "payload": 7 } } From bf53dced98ace37e84d2b0b7ec645fbc632d6c1e Mon Sep 17 00:00:00 2001 From: arkanoider Date: Tue, 7 Oct 2025 16:05:18 +0200 Subject: [PATCH 3/7] chore: typo on second option --- src/restore_trade_index_second_option.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/restore_trade_index_second_option.md b/src/restore_trade_index_second_option.md index 04a45ad..d9501d6 100644 --- a/src/restore_trade_index_second_option.md +++ b/src/restore_trade_index_second_option.md @@ -25,7 +25,8 @@ Mostro responds with the user's last trade index as a u32 directly in the `paylo "restore": { "version": 1, "action": "last-trade-index", - "payload": 42 + "trade_index": 42, + "payload": null } } ``` From 9871cc782c660d0bc344023914b66f82730f73f6 Mon Sep 17 00:00:00 2001 From: arkanoider Date: Tue, 7 Oct 2025 17:18:49 +0200 Subject: [PATCH 4/7] chore: typo --- src/restore_trade_index_second_option.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/restore_trade_index_second_option.md b/src/restore_trade_index_second_option.md index d9501d6..27aed6b 100644 --- a/src/restore_trade_index_second_option.md +++ b/src/restore_trade_index_second_option.md @@ -35,8 +35,8 @@ Mostro responds with the user's last trade index as a u32 directly in the `paylo * `restore.version`: Protocol version. Current is `1`. * `restore.action`: Must be `last-trade-index`. -* `restore.payload` (request): Must be `null` when querying. -* `restore.payload` (response): u32 representing the last `trade_index` for the user. `1` if none. +* `restore.trade_index` (response): u32 representing the last `trade_index` for the user. `1` if none. +* `restore.payload` (response): Must be `null`. ## Example @@ -47,7 +47,8 @@ Client requests the last trade index and receives `7`, meaning the next trade th "restore": { "version": 1, "action": "last-trade-index", - "payload": 7 + "trade_index": 7, + "payload": null } } ``` From ae6bc1c5fe1c27e6a21aacfd8f8686e7ee70dc5c Mon Sep 17 00:00:00 2001 From: arkanoider Date: Tue, 7 Oct 2025 17:20:08 +0200 Subject: [PATCH 5/7] chore: typo --- src/restore_trade_index_second_option.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/restore_trade_index_second_option.md b/src/restore_trade_index_second_option.md index 27aed6b..a0e70fd 100644 --- a/src/restore_trade_index_second_option.md +++ b/src/restore_trade_index_second_option.md @@ -18,7 +18,7 @@ Client sends a Gift wrap Nostr event to Mostro with the following rumor's conten ## Response -Mostro responds with the user's last trade index as a u32 directly in the `payload` field. If the user has never created a trade, the value SHOULD be `1`. +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`. ```json { From 2988035f9e6f0e4a9622623a2a4891e5a0fea14f Mon Sep 17 00:00:00 2001 From: arkanoider Date: Tue, 7 Oct 2025 20:28:34 +0200 Subject: [PATCH 6/7] chore: fix typos --- ...x_second_option.md => last_trade_index.md} | 10 ++-- src/restore_trade_index.md | 58 ------------------- 2 files changed, 4 insertions(+), 64 deletions(-) rename src/{restore_trade_index_second_option.md => last_trade_index.md} (76%) delete mode 100644 src/restore_trade_index.md diff --git a/src/restore_trade_index_second_option.md b/src/last_trade_index.md similarity index 76% rename from src/restore_trade_index_second_option.md rename to src/last_trade_index.md index a0e70fd..7bcf377 100644 --- a/src/restore_trade_index_second_option.md +++ b/src/last_trade_index.md @@ -1,10 +1,10 @@ -# Sync Trade Index +# Last Trade Index -Defines the `synch-trade-index` action used to retrieve the user's last `trade_index`. +Defines the `last-trade-index` action used to retrieve the user's last `trade_index`. ## Request -Client sends a Gift wrap Nostr event to Mostro with the following rumor's content. The request uses a `null` payload to indicate that the client is querying for the last trade index. +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. ```json { @@ -18,7 +18,7 @@ Client sends a Gift wrap Nostr event to Mostro with the following rumor's conten ## Response -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`. +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`. ```json { @@ -52,5 +52,3 @@ Client requests the last trade index and receives `7`, meaning the next trade th } } ``` - - diff --git a/src/restore_trade_index.md b/src/restore_trade_index.md deleted file mode 100644 index 60f8594..0000000 --- a/src/restore_trade_index.md +++ /dev/null @@ -1,58 +0,0 @@ -# Restore Trade Index - -Use this message to request the last trade index associated with the user's mnemonic, while keeping the `restore-session` action. This allows clients to resume indexing from the correct `trade_index` value without changing the action name. - -## Request - -Client sends a Gift wrap Nostr event to Mostro with the following rumor's content. The client indicates the request by sending a `payload` object with a `last_trade_index` key set to `null`: - -```json -{ - "restore": { - "version": 1, - "action": "restore-session", - "payload": { - "last_trade_index": null - } - } -} -``` - -## Response - -Mostro responds with the user's last trade index as a u32 under the same `payload.last_trade_index` key. If the user has never created a trade, the value SHOULD be `1`. - -```json -{ - "restore": { - "version": 1, - "action": "restore-session", - "payload": { - "last_trade_index": 42 - } - } -} -``` - -### Fields - -* `restore.version`: Protocol version. Current is `1`. -* `restore.action`: Must be `restore-session`. -* `restore.payload.last_trade_index` (request): Must be `null` to indicate a query. -* `restore.payload.last_trade_index` (response): u32 representing the last `trade_index` for the user. `1` if none. - -## Example - -Client requests the last trade index and receives `7`, meaning the next trade the client creates SHOULD use `trade_index = 8`. - -```json -{ - "restore": { - "version": 1, - "action": "restore-session", - "payload": { - "last_trade_index": 7 - } - } -} -``` From 8d67cb300d4ee34706a9b8d72007fc432e722ab1 Mon Sep 17 00:00:00 2001 From: arkanoider Date: Tue, 7 Oct 2025 22:11:52 +0200 Subject: [PATCH 7/7] chore: add last trade index markdown in summary.md --- src/SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 1b02b16..465382c 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -26,6 +26,7 @@ - [Admin Cancel order](./admin_cancel_order.md) - [Admin Add Solver](./admin_add_solver.md) - [Restore session](./restore_session.md) +- [Last Trade Index](./last_trade_index.md) - [Actions](./actions.md) - [Message suggestions for actions](./message_suggestions_for_actions.md) - [P2P Order event. NIP-69](./order_event.md)