Skip to content

Commit

Permalink
use correct get dd by slug
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesReate committed Nov 25, 2024
1 parent f0105a0 commit 8da39eb
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.23.2

require (
github.com/DIMO-Network/device-data-api v0.9.10
github.com/DIMO-Network/device-definitions-api v1.2.65
github.com/DIMO-Network/device-definitions-api v1.2.66-0.20241125194326-a4a2d67792f2
github.com/DIMO-Network/go-mnemonic v0.0.0-20230406181942-6ddfe6f8c21c
github.com/DIMO-Network/meta-transaction-processor v0.3.2
github.com/DIMO-Network/shared v0.12.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ github.com/DIMO-Network/clickhouse-infra v0.0.3 h1:B6/4IY9IxLcyydET14IjHUT+A5SDE
github.com/DIMO-Network/clickhouse-infra v0.0.3/go.mod h1:NtpQ1btkPzebDvpYYygeqiiBmJ/q5oJb/T/JWzUVRlk=
github.com/DIMO-Network/device-data-api v0.9.10 h1:ORyxDSKPCEPFGG5S593+2OkLzWFsy4ZO0o90TPebQN4=
github.com/DIMO-Network/device-data-api v0.9.10/go.mod h1:tjR1bA9sw2sj5GNi88dqpGsGLjYHjQzSfv2lcCYLjqQ=
github.com/DIMO-Network/device-definitions-api v1.2.65 h1:/5cMk1dHwjxHnvhtOGo+H6xgW+uc6kJt1ZYZ3PFnMAE=
github.com/DIMO-Network/device-definitions-api v1.2.65/go.mod h1:6k8KSNzSh6svRWEG6EkGtZqttiHESW92OsLPNQ0nnsY=
github.com/DIMO-Network/device-definitions-api v1.2.66-0.20241125194326-a4a2d67792f2 h1:wmsKXIBIPsUdhDg+R1CK2biv9m5JbTfq4brPsxaC9qo=
github.com/DIMO-Network/device-definitions-api v1.2.66-0.20241125194326-a4a2d67792f2/go.mod h1:6k8KSNzSh6svRWEG6EkGtZqttiHESW92OsLPNQ0nnsY=
github.com/DIMO-Network/go-mnemonic v0.0.0-20230406181942-6ddfe6f8c21c h1:sKuB4i3m/5NpLjO6tKyc2gSqQHmRe02sMP+pQqJNTuQ=
github.com/DIMO-Network/go-mnemonic v0.0.0-20230406181942-6ddfe6f8c21c/go.mod h1:K5a/Iqh9iZYdMSh3UE3J+tc4aV1PxHe4Fz0ZEhZMPbg=
github.com/DIMO-Network/meta-transaction-processor v0.3.2 h1:eSf34mSmiRilMbQx+4Iyu6aNm/WWJjbopIGYNjz/Z6w=
Expand Down
10 changes: 7 additions & 3 deletions internal/controllers/user_devices_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ func (udc *UserDevicesController) PostMintDevice(c *fiber.Ctx) error {
// This actually makes no database calls!
mvs, dd, err := udc.checkVehicleMint(c, userDevice)
if err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error())
return fiber.NewError(fiber.StatusBadRequest, errors.Wrapf(err, "failed to checkVehicleMint. user device id: %s", userDeviceID).Error())
}

var mr VehicleMintRequest
Expand Down Expand Up @@ -1922,9 +1922,13 @@ func (udc *UserDevicesController) checkVehicleMint(c *fiber.Ctx, userDevice *mod
return nil, nil, fmt.Errorf("VIN not confirmed")
}

dd, err := udc.DeviceDefSvc.GetDeviceDefinitionBySlugName(c.Context(), userDevice.DefinitionID)
if len(userDevice.DefinitionID) == 0 {
return nil, nil, fmt.Errorf("vehcile definition_id not set")
}

dd, err := udc.DeviceDefSvc.GetDeviceDefinitionBySlug(c.Context(), userDevice.DefinitionID)
if err != nil {
return nil, nil, fmt.Errorf("error querying for device definition id: %s ", userDevice.DefinitionID)
return nil, nil, fmt.Errorf("error querying for definition by slug id: %s ", userDevice.DefinitionID)
}

if dd.Make.TokenId == 0 {
Expand Down
2 changes: 1 addition & 1 deletion internal/services/contracts_events_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ func (c *ContractsEventsConsumer) vehicleNodeMintedWithDeviceDefinition(e *Contr
return fmt.Errorf("failed to convert address to user id: %w", err)
}

dDef, err := c.ddSvc.GetDeviceDefinitionBySlugName(ctx, args.DeviceDefinitionId)
dDef, err := c.ddSvc.GetDeviceDefinitionBySlug(ctx, args.DeviceDefinitionId)
if err != nil {
return fmt.Errorf("failed to get device definition: %s error: %w", args.DeviceDefinitionId, err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/contracts_events_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ func Test_VehicleNodeMintedWithDeviceDefinition_NoMtx(t *testing.T) {
))
require.NoError(err)

deviceDefSvc.EXPECT().GetDeviceDefinitionBySlugName(gomock.Any(), &ddgrpc.GetDeviceDefinitionBySlugNameRequest{
deviceDefSvc.EXPECT().GetDeviceDefinitionBySlug(gomock.Any(), &ddgrpc.GetDeviceDefinitionBySlugNameRequest{
Slug: ddSlug,
}).Return(&ddgrpc.GetDeviceDefinitionItemResponse{
DeviceDefinitionId: deviceDefID,
Expand Down
6 changes: 3 additions & 3 deletions internal/services/device_definitions_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type DeviceDefinitionService interface {
DecodeVIN(ctx context.Context, vin string, model string, year int, countryCode string) (*ddgrpc.DecodeVinResponse, error)
GetIntegrationByTokenID(ctx context.Context, tokenID uint64) (*ddgrpc.Integration, error)
GetDeviceStyleByID(ctx context.Context, id string) (*ddgrpc.DeviceStyle, error)
GetDeviceDefinitionBySlugName(ctx context.Context, definitionID string) (*ddgrpc.GetDeviceDefinitionItemResponse, error)
GetDeviceDefinitionBySlug(ctx context.Context, definitionID string) (*ddgrpc.GetDeviceDefinitionItemResponse, error)
//go:generate mockgen -source device_definitions_service.go -destination ./device_definition_service_mock_test.go -package=services
}

Expand Down Expand Up @@ -235,14 +235,14 @@ func (d *deviceDefinitionService) GetIntegrationByVendor(ctx context.Context, ve
return integration, nil
}

func (d *deviceDefinitionService) GetDeviceDefinitionBySlugName(ctx context.Context, definitionID string) (*ddgrpc.GetDeviceDefinitionItemResponse, error) {
func (d *deviceDefinitionService) GetDeviceDefinitionBySlug(ctx context.Context, definitionID string) (*ddgrpc.GetDeviceDefinitionItemResponse, error) {
definitionsClient, conn, err := d.getDeviceDefsGrpcClient()
if err != nil {
return nil, err
}
defer conn.Close()

return definitionsClient.GetDeviceDefinitionBySlugName(ctx, &ddgrpc.GetDeviceDefinitionBySlugNameRequest{
return definitionsClient.GetDeviceDefinitionBySlug(ctx, &ddgrpc.GetDeviceDefinitionBySlugRequest{
Slug: definitionID,
})
}
Expand Down
14 changes: 8 additions & 6 deletions internal/services/device_definitions_service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions internal/services/mocks/device_definitions_service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8da39eb

Please sign in to comment.