Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding diff script #34

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions proto/cmp/services/book/v2/mint.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
syntax = "proto3";

package cmp.services.book.v2;

import "cmp/types/v1/common.proto";
import "cmp/types/v1/language.proto";
import "cmp/types/v1/payment.proto";
import "cmp/types/v1/price.proto";
import "cmp/types/v1/pubkey.proto";
import "cmp/types/v1/traveller.proto";
import "cmp/types/v1/uuid.proto";
import "google/protobuf/timestamp.proto";

message MintRequest {
// Message header
cmp.types.v1.RequestHeader header = 1;

// This must be a UUID according to RFC 4122
cmp.types.v1.UUID validation_id = 2;

string external_session_id = 3;

cmp.types.v1.Language language = 4;

string market = 5;

string booking_reference = 6;

repeated cmp.types.v1.ExtensiveTraveller travellers = 7;

// The comments field is meant to pass noncommittal remarks entered by the
// end-consumer about the service reservation, like "non-smoking room please",
// "top floor room please".
string comment = 8;

// Public keys that will be used to encrypt the private booking data
repeated cmp.types.v1.PublicKey public_keys = 9;

// Buyer's address. Only this address should be allowed to buy the `BookingToken`
// on chain.
string buyer_address = 10;

// This field is only relevant for off chain virtual credit card payments.
cmp.types.v1.AdditionalPaymentInfo additional_payment_info = 11;
}

message MintResponse {
// Message header
cmp.types.v1.ResponseHeader header = 1;

// This must be a UUID according to RFC 4122
cmp.types.v1.UUID mint_id = 2;

// This must be a UUID according to RFC 4122
cmp.types.v1.UUID validation_id = 3;

string provider_booking_reference = 4;

// Timestamp of the booking in the inventory system of the supplier.
google.protobuf.Timestamp provider_booking_timestamp = 5;

// Price of the `BookingToken`. This field is meant to be populated by the
// supplier plugin and used by the supplier bot while minting the `BookingToken`.
cmp.types.v1.Price price = 6;

// ID of the token that represents the booking of the service
int32 booking_token_id = 7;

// URI of the token that represents the booking of the service
string booking_token_uri = 8;

// Mint transaction ID that will be populated by the supplier bot after the
// `BookingToken` is minted on chain.
string mint_transaction_id = 9;

// On chain booking token should be only buyable until this timestamp and should
// expire after that.
google.protobuf.Timestamp buyable_until = 10;

// Transaction ID of the buy operation. This field is populated by the distributor
// (buyer) bot after the buy operation and passed to the distributor middleware
// (partner plugin) in the mint response.
//
// This fielld is not meant for the supplier.
string buy_transaction_id = 11;
}

// ![Diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/proto/cmp/services/book/v1/mint.proto.dot.xs.svg)
// [Open Message Diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/proto/cmp/services/book/v1/mint.proto.dot.svg)
service MintService {
rpc Mint(MintRequest) returns (MintResponse);
}
21 changes: 21 additions & 0 deletions proto/cmp/types/v2/token.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";

package cmp.types.v2;

// Token Reference
//
// ![Diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/proto/cmp/types/v1/token.proto.dot.xs.svg)
// [Open Message Diagram](https://storage.googleapis.com/docs-cmp-files/diagrams/proto/cmp/types/v1/token.proto.dot.svg)
message TokenCurrency {
string contract_address = 1;
}

// Booking token that represents to access to the service
message Token {
// Contract address of the smart contract or the address of natively implemented
// asset on-chain.
string contract = 1;

// Token ID
int32 token_id = 2;
}
48 changes: 48 additions & 0 deletions scripts/diff_against_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

## This file will do a diff against the dev branch for added files
## As the definition of the versioning is to always create a new version if a file has been changed
## we make sure that every structure change is a breaking change.
##
## But at the same time it's hard to see the actual changes in the new version as there is no
## history of changes. Therefore this script exists which will:
##
## * Get the *added* files out of the git history
## * Extract the version
## * Check if a file with version-1 exists in the origin branch
## * Do a diff against the other file

CUR_BRANCH=$(git branch --show-current)
ORIGIN=${1:-dev}

git fetch origin $ORIGIN

function check_file {
FILE=$1

FILE_VERSION=$(echo $FILE | grep -oP "/v[0-9]+/" | cut -d"v" -f2 | cut -d"/" -f1)

if [[ "$FILE_VERSION" == "1" ]] ; then
# Skip it as it's newly introduced
return
fi


OTHER_FILE=$(echo $FILE | sed -e "s#/v$FILE_VERSION/#/v$(( FILE_VERSION - 1))/#")

echo "#############################################################################"
echo "## Detected newly added file: $FILE"
echo "## Version: $FILE_VERSION"
echo "## Comparing against $ORIGIN/$OTHER_FILE"
echo "#############################################################################"
echo

GIT_PAGER=cat git diff --exit-code origin/$ORIGIN:$OTHER_FILE $CUR_BRANCH:$FILE
if [[ "$?" == "0" ]] ; then
echo "No change detected! (weird?)"
fi
}

while read FILE ; do
check_file $FILE
done < <(git diff --name-status origin/$ORIGIN | grep -P "^A.*" | grep -oP "proto/.*")