From 401a2b24bc1a3ffc1e7f3d4f60c1775ce8cac6a9 Mon Sep 17 00:00:00 2001 From: Ekrem Seren Date: Thu, 28 Nov 2024 02:23:03 +0300 Subject: [PATCH] update cancellation and notification pkg with for new logic on-chain --- .../cmp/services/cancellation/v1/accept.proto | 3 +- .../cancellation/v1/accept_counter.proto | 4 ++- .../cancellation/v1/cancel_proposal.proto | 4 ++- .../cmp/services/cancellation/v1/check.proto | 6 +++- .../services/cancellation/v1/counter.proto | 3 +- .../services/cancellation/v1/initiate.proto | 15 +++++++- ...cancellation_reason.proto => reason.proto} | 0 .../cmp/services/cancellation/v1/reject.proto | 24 ++++++------- .../cmp/services/notification/v2/notify.proto | 34 ++++++++++++++++--- 9 files changed, 69 insertions(+), 24 deletions(-) rename proto/cmp/services/cancellation/v1/{cancellation_reason.proto => reason.proto} (100%) diff --git a/proto/cmp/services/cancellation/v1/accept.proto b/proto/cmp/services/cancellation/v1/accept.proto index 8e6488a..66561ff 100644 --- a/proto/cmp/services/cancellation/v1/accept.proto +++ b/proto/cmp/services/cancellation/v1/accept.proto @@ -26,6 +26,7 @@ message AcceptCancellationResponse { // Response header cmp.types.v1.ResponseHeader header = 1; - // Accept cancellation transaction ID + // Transaction ID on-chain for the cancellation proposal acceptance. This + // transaction proves the acceptance of the proposal on-chain to avoid disputes. string transaction_id = 2; } diff --git a/proto/cmp/services/cancellation/v1/accept_counter.proto b/proto/cmp/services/cancellation/v1/accept_counter.proto index 9464a78..3b8e0a7 100644 --- a/proto/cmp/services/cancellation/v1/accept_counter.proto +++ b/proto/cmp/services/cancellation/v1/accept_counter.proto @@ -22,6 +22,8 @@ message AcceptCounterCancellationResponse { // Response header cmp.types.v1.ResponseHeader header = 1; - // Accept counter cancellation transaction ID + // Transaction ID on-chain for the counter cancellation proposal acceptance. This + // transaction proves the acceptance of the counter proposal on-chain to avoid + // disputes. string transaction_id = 2; } diff --git a/proto/cmp/services/cancellation/v1/cancel_proposal.proto b/proto/cmp/services/cancellation/v1/cancel_proposal.proto index 8ca81a2..7048ab7 100644 --- a/proto/cmp/services/cancellation/v1/cancel_proposal.proto +++ b/proto/cmp/services/cancellation/v1/cancel_proposal.proto @@ -18,6 +18,8 @@ message CancelCancellationResponse { // Response header cmp.types.v1.ResponseHeader header = 1; - // Accept cancellation transaction ID + // Transaction ID on-chain for cancelling the cancellation proposal. This + // transaction proves the cancellation of the cancellation proposal on-chain to + // avoid disputes. string transaction_id = 2; } diff --git a/proto/cmp/services/cancellation/v1/check.proto b/proto/cmp/services/cancellation/v1/check.proto index 9f8c084..9cfd457 100644 --- a/proto/cmp/services/cancellation/v1/check.proto +++ b/proto/cmp/services/cancellation/v1/check.proto @@ -2,7 +2,8 @@ syntax = "proto3"; package cmp.services.cancellation.v1; -import "cmp/services/cancellation/v1/reject.proto"; +import "cmp/services/cancellation/v1/reason.proto"; +import "cmp/services/cancellation/v1/rejection_reason.proto"; import "cmp/types/v1/common.proto"; import "cmp/types/v2/price.proto"; import "google/protobuf/timestamp.proto"; @@ -25,6 +26,9 @@ message CheckCancellationRequest { // The amount to be refunded cmp.types.v2.Price refund_amount = 3; + + // Cancellation reason + cmp.services.cancellation.v1.CancellationReason reason = 4; } message CheckCancellationResponse { diff --git a/proto/cmp/services/cancellation/v1/counter.proto b/proto/cmp/services/cancellation/v1/counter.proto index 01af2be..312e4e6 100644 --- a/proto/cmp/services/cancellation/v1/counter.proto +++ b/proto/cmp/services/cancellation/v1/counter.proto @@ -22,6 +22,7 @@ message CounterCancellationResponse { // Response header cmp.types.v1.ResponseHeader header = 1; - // Counter cancellation transaction ID + // Transaction ID on-chain for the cancellation proposal counter. This transaction + // proves the counter of the proposal on-chain to avoid disputes. string transaction_id = 2; } diff --git a/proto/cmp/services/cancellation/v1/initiate.proto b/proto/cmp/services/cancellation/v1/initiate.proto index 3e0a059..be07a28 100644 --- a/proto/cmp/services/cancellation/v1/initiate.proto +++ b/proto/cmp/services/cancellation/v1/initiate.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package cmp.services.cancellation.v1; +import "cmp/services/cancellation/v1/reason.proto"; import "cmp/types/v1/common.proto"; import "cmp/types/v2/price.proto"; @@ -14,12 +15,24 @@ message InitiateCancellationRequest { // The amount to be refunded cmp.types.v2.Price refund_amount = 3; + + // The cancellation reason + cmp.services.cancellation.v1.CancellationReason reason = 4; + + // Cancellation reason version. This is used by the contract to store on-chain, + // the protobuf pkg version of the enum above. So it's clear which enum is used. + // + // FIXME: Do we need this here? Maybe the bot can extract this info from the + // version of the package of the enum itself. + uint32 reason_version = 5; } message InitiateCancellationResponse { // The response header cmp.types.v1.ResponseHeader header = 1; - // Transaction id for the initiate cancellation request + // Transaction ID on-chain for the cancellation proposal initiation. This + // transaction proves the initiation of the cancellation proposal on-chain to + // avoid disputes. string transaction_id = 2; } diff --git a/proto/cmp/services/cancellation/v1/cancellation_reason.proto b/proto/cmp/services/cancellation/v1/reason.proto similarity index 100% rename from proto/cmp/services/cancellation/v1/cancellation_reason.proto rename to proto/cmp/services/cancellation/v1/reason.proto diff --git a/proto/cmp/services/cancellation/v1/reject.proto b/proto/cmp/services/cancellation/v1/reject.proto index cbf6a83..7465019 100644 --- a/proto/cmp/services/cancellation/v1/reject.proto +++ b/proto/cmp/services/cancellation/v1/reject.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package cmp.services.cancellation.v1; +import "cmp/services/cancellation/v1/rejection_reason.proto"; import "cmp/types/v1/common.proto"; // Request for cancellation rejection @@ -14,6 +15,13 @@ message RejectCancellationRequest { // Reason for rejection cmp.services.cancellation.v1.CancellationRejectionReason reason = 3; + + // Rejection reason version. This is used by the contract to store on-chain, + // the protobuf pkg version of the enum above. So it's clear which enum is used. + // + // FIXME: Do we need this here? Maybe the bot can extract this info from the + // version of the package of the enum itself. + uint32 reason_version = 4; } // Response for cancellation rejection @@ -21,19 +29,7 @@ message RejectCancellationResponse { // Response Header cmp.types.v1.ResponseHeader header = 1; - // Transaction id for the rejected cancellation + // Transaction ID on-chain for the cancellation proposal rejection. This + // transaction proves the rejection of the proposal on-chain to avoid disputes. string transaction_id = 2; } - -enum CancellationRejectionReason { - CANCELLATION_REJECTION_REASON_UNSPECIFIED = 0; - CANCELLATION_REJECTION_REASON_TECHNICAL_ERROR = 1; - CANCELLATION_REJECTION_REASON_INVALID_SERVICE_OR_BOOKING_REFERENCE = 2; - CANCELLATION_REJECTION_REASON_BOOKING_IS_ALREADY_CANCELLED = 3; - CANCELLATION_REJECTION_REASON_SERVICE_HAS_STARTED_OR_HAS_BEEN_DELIVERED = 4; - CANCELLATION_REJECTION_REASON_CANCELLATION_WINDOW_EXPIRED = 5; - CANCELLATION_REJECTION_REASON_SERVICE_CANNOT_BE_CANCELLED_ONLINE = 6; - CANCELLATION_REJECTION_REASON_RATE_OR_FARE_CANNOT_BE_CANCELLED = 7; - CANCELLATION_REJECTION_REASON_ENTIRE_PACKAGE_MUST_BE_CANCELLED = 8; // Service forms part of a package, the entire package must be cancelled - CANCELLATION_REJECTION_REASON_REFUND_CURRENCY_NOT_SUPPORTED = 9; -} diff --git a/proto/cmp/services/notification/v2/notify.proto b/proto/cmp/services/notification/v2/notify.proto index 3364dda..c5834e0 100644 --- a/proto/cmp/services/notification/v2/notify.proto +++ b/proto/cmp/services/notification/v2/notify.proto @@ -2,7 +2,8 @@ syntax = "proto3"; package cmp.services.notification.v2; -import "cmp/services/cancellation/v1/reject.proto"; +import "cmp/services/cancellation/v1/reason.proto"; +import "cmp/services/cancellation/v1/rejection_reason.proto"; import "cmp/types/v1/uuid.proto"; import "google/protobuf/empty.proto"; @@ -33,15 +34,24 @@ message TokenExpired { cmp.types.v1.UUID mint_id = 2; } -// event CancellationPending(uint256 indexed tokenId, address indexed proposedBy, uint256 refundAmount); +// Related on-chain event: +// +// ```solidity +// event CancellationPending(uint256 indexed tokenId, address indexed proposedBy, uint256 refundAmount, uint16 cancellationReason, uint16 cancellationReasonVersion); +// ``` message CancellationPending { uint64 token_id = 1; string proposed_by = 2; uint64 refund_amount = 3; - string tx_id = 4; + cmp.services.cancellation.v1.CancellationReason reason = 4; + string tx_id = 5; } +// Related on-chain event: +// +// ```solidity // event CancellationAccepted(uint256 indexed tokenId, address indexed acceptedBy, uint256 refundAmount); +// ``` message CancellationAccepted { uint64 token_id = 1; string accepted_by = 2; @@ -49,7 +59,11 @@ message CancellationAccepted { string tx_id = 4; } +// Related on-chain event: +// +// ```solidity // event CancellationProposalAcceptedByTheOwner(uint256 indexed tokenId, address indexed acceptedBy, uint256 refundAmount); +// ``` message CancellationProposalAcceptedByTheOwner { uint64 token_id = 1; string accepted_by = 2; @@ -57,7 +71,11 @@ message CancellationProposalAcceptedByTheOwner { string tx_id = 4; } +// Related on-chain event: +// +// ```solidity // event CancellationCountered(uint256 indexed tokenId, address indexed counteredBy, uint256 newRefundAmount); +// ``` message CancellationCountered { uint64 token_id = 1; string countered_by = 2; @@ -65,14 +83,22 @@ message CancellationCountered { string tx_id = 4; } +// Related on-chain event: +// +// ```solidity // event CancellationProposalCancelled(uint256 indexed tokenId, address indexed cancelledBy); +// ``` message CancellationProposalCancelled { uint64 token_id = 1; string cancelled_by = 2; string tx_id = 3; } -// event CancellationRejected(uint256 indexed tokenId, address indexed rejectedBy, CancellationRejectionReason reason); +// Related on-chain event: +// +// ```solidity +// event CancellationRejected(uint256 indexed tokenId, address indexed rejectedBy, uint16 rejectionReason, uint16 rejectionReasonVersion); +// ``` message CancellationRejected { uint64 token_id = 1; string rejected_by = 2;