(ctx contractapi.TransactionContextInterface, key string, target interface{})
| 386 | } |
| 387 | |
| 388 | func readJSON(ctx contractapi.TransactionContextInterface, key string, target interface{}) error { |
| 389 | data, err := ctx.GetStub().GetState(key) |
| 390 | if err != nil { |
| 391 | return fmt.Errorf("failed to read %s: %w", key, err) |
| 392 | } |
| 393 | if data == nil { |
| 394 | return fmt.Errorf("state %s does not exist", key) |
| 395 | } |
| 396 | if err := json.Unmarshal(data, target); err != nil { |
| 397 | return fmt.Errorf("failed to decode %s: %w", key, err) |
| 398 | } |
| 399 | return nil |
| 400 | } |
| 401 | |
| 402 | func putJSON(ctx contractapi.TransactionContextInterface, key string, value interface{}) error { |
| 403 | data, err := json.Marshal(value) |
no outgoing calls
no test coverage detected