Skip to content

Commit

Permalink
Update docs to message v1 (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch authored Dec 6, 2023
1 parent f30518f commit 530bf7f
Show file tree
Hide file tree
Showing 24 changed files with 374 additions and 316 deletions.
2 changes: 1 addition & 1 deletion book/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ authors = ["Francisco Calderón"]
language = "en"
multilingual = false
src = "src"
title = "Mostro"
title = "Mostro messages specs"
24 changes: 0 additions & 24 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,3 @@
- [Cancel](./cancel.md)
- [Dispute](./dispute.md)
- [Actions](./actions.md)
- [Order](./new_order.md)
- [TakeSell](./take_sell.md)
- [AddInvoice](./take_sell.md)
- [WaitingSellerToPay](./take_sell.md)
- [TakeBuy](./take_buy.md)
- [PayInvoice](./take_buy.md)
- [WaitingSellerToPay](./take_buy.md)
- [WaitingBuyerInvoice](./take_buy.md)
- [AddInvoice](./take_buy.md)
- [PayInvoice](./seller_pay_hold_invoice.md)
- [BuyerTookOrder](./seller_pay_hold_invoice.md)
- [HoldInvoicePaymentAccepted](./seller_pay_hold_invoice.md)
- [FiatSent](./fiat_sent.md)
- [Release](./release.md)
- [HoldInvoicePaymentSettled](./release.md)
- [PurchaseCompleted](./release.md)
- [RateUser](./user_rating.md)
- [Received](./user_rating.md)
- [Cancel](./cancel.md)
- [CooperativeCancelInitiatedByYou](./cancel.md)
- [CooperativeCancelInitiatedByPeer](./cancel.md)
- [Dispute](./dispute.md)
- [DisputeInitiatedByYou](./dispute.md)
- [DisputeInitiatedByPeer](./dispute.md)
2 changes: 2 additions & 0 deletions book/src/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ Action is used to identify each message between Mostro and users
AdminTakeDispute,
}
```

You can see details in [mostro core documentation](https://docs.rs/mostro-core/latest/mostro_core/message/enum.Action.html)
1 change: 0 additions & 1 deletion book/src/actions/cancel.md

This file was deleted.

1 change: 0 additions & 1 deletion book/src/actions/dispute.md

This file was deleted.

1 change: 0 additions & 1 deletion book/src/actions/fiat_sent.md

This file was deleted.

1 change: 0 additions & 1 deletion book/src/actions/new_order.md

This file was deleted.

1 change: 0 additions & 1 deletion book/src/actions/rate_user.md

This file was deleted.

1 change: 0 additions & 1 deletion book/src/actions/release.md

This file was deleted.

1 change: 0 additions & 1 deletion book/src/actions/seller_pay_hold_invoice.md

This file was deleted.

1 change: 0 additions & 1 deletion book/src/actions/take_buy.md

This file was deleted.

1 change: 0 additions & 1 deletion book/src/actions/take_sell.md

This file was deleted.

88 changes: 57 additions & 31 deletions book/src/cancel.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Cancel Order

A use can cancel an Order created by himself and with status `Pending` sending action `Cancel`, the message will look like this:
A user can cancel an Order created by himself and with status `Pending` sending action `Cancel`, the message will look like this:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj",
"action": "Cancel",
"content": null
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj",
"action": "Cancel",
"content": null
}
}
```

Expand All @@ -18,11 +20,13 @@ Mostro will send a message with action `Cancel` confirming the order was cancele

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "Cancel",
"content": null
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "Cancel",
"content": null
}
}
```

Expand All @@ -32,46 +36,68 @@ A user can cancel an `Active` order, but will need the counterparty to agree, le

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "Cancel",
"content": null
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "Cancel",
"content": null
}
}
```

Mostro will send this message to the seller:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "CooperativeCancelInitiatedByYou",
"content": null
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "CooperativeCancelInitiatedByYou",
"content": null
}
}
```

And this message to the buyer:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "CooperativeCancelInitiatedByPeer",
"content": null
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "CooperativeCancelInitiatedByPeer",
"content": null
}
}
```

The buyer can accept the cooperative cancellation sending this message:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "Cancel",
"content": null
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "Cancel",
"content": null
}
}
```

And Mostro will send this message to both parties:

```json
{
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "CooperativeCancelAccepted",
"content": null
}
}
```
36 changes: 21 additions & 15 deletions book/src/dispute.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ A use can start a dispute in an order with status `Pending` or `FiatSent` sendin

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj",
"action": "Dispute",
"content": null
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj",
"action": "Dispute",
"content": null
}
}
```

Expand All @@ -18,22 +20,26 @@ Mostro will send this message to the seller:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "DisputeInitiatedByYou,",
"content": null
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "DisputeInitiatedByYou,",
"content": null
}
}
```

And here is the message to the buyer:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "DisputeInitiatedByPeer",
"content": null
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "DisputeInitiatedByPeer",
"content": null
}
}
```
1 change: 0 additions & 1 deletion book/src/fiat_sent.md

This file was deleted.

46 changes: 26 additions & 20 deletions book/src/fiatsent.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ After the buyer sends the fiat money to the seller, the buyer should send a mess

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj",
"action": "FiatSent",
"content": null
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "FiatSent",
"content": null
}
}
```

Expand All @@ -18,29 +20,33 @@ Mostro send a messages to both parties confirming `FiatSent` action and sending

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj",
"action": "FiatSent",
"content": {
"Peer": {
"pubkey": "npub1qqqxssz4k6swex94zdg5s4pqx3uqlhwsc2vdzvhjvzk33pcypkhqe9aeq2"
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj",
"action": "FiatSent",
"content": {
"Peer": {
"pubkey": "npub1qqqxssz4k6swex94zdg5s4pqx3uqlhwsc2vdzvhjvzk33pcypkhqe9aeq2"
}
}
}
}
```

And here an example of the message to the seller:
And here an example of the message from Mostro to the seller:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqxssz4k6swex94zdg5s4pqx3uqlhwsc2vdzvhjvzk33pcypkhqe9aeq2",
"action": "FiatSent",
"content": {
"Peer": {
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj"
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqqxssz4k6swex94zdg5s4pqx3uqlhwsc2vdzvhjvzk33pcypkhqe9aeq2",
"action": "FiatSent",
"content": {
"Peer": {
"pubkey": "npub1qqqt938cer4dvlslg04zwwf66ts8r3txp6mv79cx2498pyuqx8uq0c7qkj"
}
}
}
}
Expand Down
62 changes: 33 additions & 29 deletions book/src/new_order.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ To create a new sell order the user should send a Nostr event kind 4 to Mostro w

```json
{
"version": "0",
"pubkey": "npub1qqqxssz4k6swex94zdg5s4pqx3uqlhwsc2vdzvhjvzk33pcypkhqe9aeq2",
"action": "Order",
"content": {
"Order": {
"kind": "Sell",
"status": "Pending",
"amount": 0,
"fiat_code": "VES",
"fiat_amount": 100,
"payment_method": "face to face",
"premium": 1,
"created_at": 0
"Order": {
"version": "1",
"pubkey": "npub1qqq...",
"action": "NewOrder",
"content": {
"Order": {
"kind": "Sell",
"status": "Pending",
"amount": 0,
"fiat_code": "VES",
"fiat_amount": 100,
"payment_method": "face to face",
"premium": 1,
"created_at": 0
}
}
}
}
Expand All @@ -27,7 +29,7 @@ Let's explain some of the fields:
- kind: `Sell` or `Buy`
- status: Is always `Pending` when creating a new order
- amount: 0 for when we want to sell with at market price, otherwise the amount in satoshis
- pubkey: Real user's pubkey, we use this when the message was sent from an ephemeral key
- pubkey: Real user's npub, we use this when the message was sent from an ephemeral key
- created_at: No need to send the correct unix timestamp, Mostro will replace it with the current time

## Confirmation message
Expand All @@ -36,21 +38,23 @@ Mostro will send back a confirmation message to the user like the following:

```json
{
"version": "0",
"order_id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": null,
"action": "Order",
"content": {
"Order": {
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"kind": "Sell",
"status": "Pending",
"amount": 0,
"fiat_code": "VES",
"fiat_amount": 100,
"payment_method": "face to face",
"premium": 1,
"created_at": 1698870173
"Order": {
"version": "1",
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"pubkey": "npub1qqq...",
"action": "NewOrder",
"content": {
"Order": {
"id": "ede61c96-4c13-4519-bf3a-dcf7f1e9d842",
"kind": "Sell",
"status": "Pending",
"amount": 0,
"fiat_code": "VES",
"fiat_amount": 100,
"payment_method": "face to face",
"premium": 1,
"created_at": 1698870173
}
}
}
}
Expand Down
Loading

0 comments on commit 530bf7f

Please sign in to comment.