Skip to content

Commit

Permalink
✨ Fallback for asset type list in case of fail on update
Browse files Browse the repository at this point in the history
  • Loading branch information
andremacedopv committed Jan 17, 2023
1 parent d8fa5ad commit 975f10e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions transactions/updateAssetType.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var UpdateAssetType = Transaction{
assetTypes := req["assetTypes"].([]interface{})

assetTypeList := assets.AssetTypeList()
assetTypeListFallback := assets.AssetTypeList()

resAssetArr := make([]assets.AssetType, 0)
requiredValues := make(map[string]interface{}, 0)
Expand Down Expand Up @@ -116,6 +117,8 @@ var UpdateAssetType = Transaction{
if len(requiredValuesMap) > 0 {
updatedAssets, err := initilizeDefaultValues(stub, k, requiredValuesMap)
if err != nil {
// Rollback Asset Type List
assets.InitAssetList(assetTypeListFallback)
return nil, errors.WrapError(err, "failed to initialize default values")
}
response["assets"] = updatedAssets
Expand Down

0 comments on commit 975f10e

Please sign in to comment.