Skip to content

Commit

Permalink
lower the price of token; ensure invalid mint response returns Status…
Browse files Browse the repository at this point in the history
…Type_STATUS_TYPE_FAILURE
  • Loading branch information
VjeraTurk committed Nov 14, 2024
1 parent ab223fe commit 9b48c1a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (*AccommodationSearchV1Server) AccommodationSearch(ctx context.Context, req
}
}

var price = 500
var price = 2

// generate search result
for _, prop := range available_properties {
Expand Down Expand Up @@ -138,7 +138,7 @@ func (*AccommodationSearchV1Server) AccommodationSearch(ctx context.Context, req
Remarks: "",
})

price += 250
price += 2

if units_requested == int32(len(units)) {
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (*AccommodationSearchV2Server) AccommodationSearch(ctx context.Context, req
}
}

var price = 500
var price = 2

// generate search result
for _, prop := range available_properties {
Expand Down Expand Up @@ -139,7 +139,7 @@ func (*AccommodationSearchV2Server) AccommodationSearch(ctx context.Context, req
Remarks: "",
})

price += 250
price += 2

if units_requested == int32(len(units)) {
break
Expand Down
8 changes: 6 additions & 2 deletions examples/rpc/partner-plugin/handlers/book/mint/v2/mint_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ func (*MintServiceV2Server) Mint(ctx context.Context, req *bookv2.MintRequest) (
cache := cache.NewValidationCache()
priceDetail, found := cache.GetV2(req.ValidationId.Value)
if !found {
return &bookv2.MintResponse{
grpc.SendHeader(ctx, md.ToGrpcMD())
response := bookv2.MintResponse{
Header: &typesv1.ResponseHeader{
Status: typesv1.StatusType_STATUS_TYPE_FAILURE,
Alerts: []*typesv1.Alert{
Expand All @@ -42,7 +43,10 @@ func (*MintServiceV2Server) Mint(ctx context.Context, req *bookv2.MintRequest) (
},
},
},
}, nil
}
return &response, nil
// Fatal:
// return nil, fmt.Errorf("no validation data found for validationId: %s", req.ValidationId.Value)
}

log.Printf("Responding to request: %s (MintV2)", req.ValidationId.Value)
Expand Down

0 comments on commit 9b48c1a

Please sign in to comment.