Skip to content

Commit

Permalink
update cancellation and notification pkg with for new logic on-chain
Browse files Browse the repository at this point in the history
  • Loading branch information
havan committed Nov 27, 2024
1 parent 65fd153 commit 401a2b2
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 24 deletions.
3 changes: 2 additions & 1 deletion proto/cmp/services/cancellation/v1/accept.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 3 additions & 1 deletion proto/cmp/services/cancellation/v1/accept_counter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 3 additions & 1 deletion proto/cmp/services/cancellation/v1/cancel_proposal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
6 changes: 5 additions & 1 deletion proto/cmp/services/cancellation/v1/check.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion proto/cmp/services/cancellation/v1/counter.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
15 changes: 14 additions & 1 deletion proto/cmp/services/cancellation/v1/initiate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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;
}
24 changes: 10 additions & 14 deletions proto/cmp/services/cancellation/v1/reject.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,26 +15,21 @@ 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
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;
}
34 changes: 30 additions & 4 deletions proto/cmp/services/notification/v2/notify.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -33,46 +34,71 @@ 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;
uint64 refund_amount = 3;
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;
uint64 refund_amount = 3;
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;
uint64 new_refund_amount = 3;
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;
Expand Down

0 comments on commit 401a2b2

Please sign in to comment.