Skip to content

Commit

Permalink
Merge branch 'dev' into partner_plugin_mock
Browse files Browse the repository at this point in the history
  • Loading branch information
VjeraTurk committed Nov 14, 2024
2 parents 9b48c1a + 4296858 commit 48a2324
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/messaging/mint_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func (h *evmResponseHandler) handleMintResponseV1(ctx context.Context, response
mintResp.Header = &typesv1.ResponseHeader{}
}

if mintResp.Header.Status == typesv1.StatusType_STATUS_TYPE_FAILURE {
return false
}

// TODO @evlekht ensure that mintReq.BuyerAddress is c-chain address format,
// TODO not x/p/t chain or anything else. Currently it will not error
// TODO if address is invalid and will just get zero addr
Expand Down
4 changes: 4 additions & 0 deletions internal/messaging/mint_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func (h *evmResponseHandler) handleMintResponseV2(ctx context.Context, response
mintResp.Header = &typesv1.ResponseHeader{}
}

// Check if the response from plugin is successful before minting
if mintResp.Header.Status == typesv1.StatusType_STATUS_TYPE_FAILURE {
return false
}
// TODO: @VjeraTurk check if CMAccount exists

// TODO @evlekht ensure that mintReq.BuyerAddress is c-chain address format,
Expand Down
10 changes: 10 additions & 0 deletions internal/messaging/response_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ func (h *evmResponseHandler) HandleRequest(_ context.Context, msgType types.Mess
func (h *evmResponseHandler) AddErrorToResponseHeader(response protoreflect.ProtoMessage, errMessage string) {
headerFieldDescriptor := response.ProtoReflect().Descriptor().Fields().ByName("header")
headerReflectValue := response.ProtoReflect().Get(headerFieldDescriptor)

if !headerReflectValue.IsValid() || !headerReflectValue.Message().IsValid() {
// TODO: @VjeraTurk support more than 1 version! Or ensure header is not nil elsewhere
// Initialize the header if it is not set
header := &typesv1.ResponseHeader{}
response.ProtoReflect().Set(headerFieldDescriptor, protoreflect.ValueOfMessage(header.ProtoReflect()))
addErrorToResponseHeaderV1(header, errMessage)
return
}

switch header := headerReflectValue.Message().Interface().(type) {
case *typesv1.ResponseHeader:
addErrorToResponseHeaderV1(header, errMessage)
Expand Down

0 comments on commit 48a2324

Please sign in to comment.