MCPcopy Create free account
hub / github.com/DNAProject/DNA / removeAttribute

Function removeAttribute

smartcontract/service/native/did/method.go:333–373  ·  view source on GitHub ↗
(srvc *native.NativeService)

Source from the content-addressed store, hash-verified

331}
332
333func removeAttribute(srvc *native.NativeService) ([]byte, error) {
334 args := common.NewZeroCopySource(srvc.Input)
335 // arg0: ID
336 arg0, err := utils.DecodeVarBytes(args)
337 if err != nil {
338 return utils.BYTE_FALSE, errors.New("remove attribute failed: argument 0 error")
339 }
340 // arg1: path
341 arg1, err := utils.DecodeVarBytes(args)
342 if err != nil {
343 return utils.BYTE_FALSE, errors.New("remove attribute failed: argument 1 error")
344 }
345 // arg2: operator's public key
346 arg2, err := utils.DecodeVarBytes(args)
347 if err != nil {
348 return utils.BYTE_FALSE, errors.New("remove attribute failed: argument 2 error")
349 }
350
351 err = checkWitness(srvc, arg2)
352 if err != nil {
353 return utils.BYTE_FALSE, errors.New("remove attribute failed: " + err.Error())
354 }
355 key, err := encodeID(arg0)
356 if err != nil {
357 return utils.BYTE_FALSE, errors.New("remove attribute failed: " + err.Error())
358 }
359 if !isValid(srvc, key) {
360 return utils.BYTE_FALSE, errors.New("remove attribute failed: ID not registered")
361 }
362 if !isOwner(srvc, key, arg2) {
363 return utils.BYTE_FALSE, errors.New("remove attribute failed: no authorization")
364 }
365
366 err = deleteAttr(srvc, key, arg1)
367 if err != nil {
368 return utils.BYTE_FALSE, errors.New("remove attribute failed: " + err.Error())
369 }
370
371 triggerAttributeEvent(srvc, "remove", arg0, [][]byte{arg1})
372 return utils.BYTE_TRUE, nil
373}
374
375func verifySignature(srvc *native.NativeService) ([]byte, error) {
376 source := common.NewZeroCopySource(srvc.Input)

Callers 1

CaseAttributeFunction · 0.85

Calls 9

NewZeroCopySourceFunction · 0.92
DecodeVarBytesFunction · 0.92
checkWitnessFunction · 0.85
encodeIDFunction · 0.85
isValidFunction · 0.85
isOwnerFunction · 0.85
deleteAttrFunction · 0.85
triggerAttributeEventFunction · 0.85
ErrorMethod · 0.65

Tested by 1

CaseAttributeFunction · 0.68