(ctx contractapi.TransactionContextInterface, key string, target interface{})
| 287 | } |
| 288 | |
| 289 | func readJSON(ctx contractapi.TransactionContextInterface, key string, target interface{}) error { |
| 290 | data, err := ctx.GetStub().GetState(key) |
| 291 | if err != nil { |
| 292 | return fmt.Errorf("failed to read %s: %w", key, err) |
| 293 | } |
| 294 | if data == nil { |
| 295 | return fmt.Errorf("state %s does not exist", key) |
| 296 | } |
| 297 | if err := json.Unmarshal(data, target); err != nil { |
| 298 | return fmt.Errorf("failed to decode %s: %w", key, err) |
| 299 | } |
| 300 | return nil |
| 301 | } |
| 302 | |
| 303 | func putJSON(ctx contractapi.TransactionContextInterface, key string, value interface{}) error { |
| 304 | data, err := json.Marshal(value) |
no outgoing calls
no test coverage detected