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

SI-2471-burn-vehicle #271

Merged
merged 29 commits into from
Mar 21, 2024
Merged

SI-2471-burn-vehicle #271

merged 29 commits into from
Mar 21, 2024

Conversation

Allyson-English
Copy link
Member

@Allyson-English Allyson-English commented Feb 27, 2024

  • add GET and POST endpoints to burn a minted vehicle
    • GET /v1/vehicle/:tokenID/commands/burn
    • POST /v1/vehicle/:tokenID/commands/burn
  • handler for VehicleBurnedEvent in contract event consumer
  • update udOwner.Delete("/", userDeviceController.DeleteUserDevice); check if device has been minted; if yes, return an error (StatusFailedDependency, 424) and instruct the user to burn the device
  • tests

NOTES:

  • do we want to keep /commands in the burn endpoint path? This is consistent with what we have elsewhere but it could also make sense to make the path /v1/vehicle/:tokenID/burn
  • is StatusFailedDependency (424) the best error code to return from the DeleteUserDevice endpoint? I was aiming to make it distinct from other errors returned by that function to make it easier for the frontend to handle

Copy link

linear bot commented Feb 27, 2024

SI-2471 Vehicle burning

@elffjs
Copy link
Member

elffjs commented Feb 27, 2024

Do we have a handler for VehicleNodeBurned (or Transfer to the zero address) already? Maybe that should be the first PR, now that I think about it.

@Allyson-English Allyson-English marked this pull request as ready for review March 8, 2024 19:26
internal/controllers/user_devices_controller.go Outdated Show resolved Hide resolved
internal/controllers/user_devices_controller.go Outdated Show resolved Hide resolved
internal/controllers/user_devices_controller.go Outdated Show resolved Hide resolved
internal/controllers/user_devices_controller.go Outdated Show resolved Hide resolved
internal/controllers/user_devices_controller_test.go Outdated Show resolved Hide resolved
internal/controllers/user_integrations_controller.go Outdated Show resolved Hide resolved
internal/services/autopi_api_service_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@KevinJoiner KevinJoiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't finish looking at this, but I took a first glance. I think 424 makes sense as a return code.

internal/controllers/nft_controller.go Show resolved Hide resolved
internal/controllers/nft_controller.go Outdated Show resolved Hide resolved
internal/controllers/nft_controller.go Outdated Show resolved Hide resolved
Comment on lines 959 to 960
logger.Err(err).Msg("database error retrieving nft")
return fiber.NewError(fiber.StatusInternalServerError, "database error retrieving nft")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handler will log on our behalf unless we explicitly call helpers.SkipErrorLog(c) which we do not.

A good general guideline for most Go functions is that you do not want to log and return an error. Since a function can never guarantee who will be calling it, that function does not know if the caller wants the errors logged or not, so it's best to just return the error and let the caller decide what to do with it.
A situation where you would log and return is if the error contains sensitive information you do not want to give to the calling function. In that situation it may be acceptable to log a detail error message and then return a general message to the user. An example of this is when APIs returning a general 500 Internal Error, but log more specific details.

internal/services/registry/client.go Outdated Show resolved Hide resolved
@Allyson-English Allyson-English merged commit 9436598 into main Mar 21, 2024
2 checks passed
@Allyson-English Allyson-English deleted the SI-2471-burn-vehicle branch March 21, 2024 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants