MCPcopy
hub / github.com/yeasy/blockchain_guide / parseNonNegativeAmount

Function parseNonNegativeAmount

11_app_dev/chaincode_example05.go:243–252  ·  view source on GitHub ↗
(value string)

Source from the content-addressed store, hash-verified

241}
242
243func parseNonNegativeAmount(value string) (int, error) {
244 amount, err := strconv.Atoi(value)
245 if err != nil {
246 return 0, fmt.Errorf("amount must be an integer: %w", err)
247 }
248 if amount < 0 {
249 return 0, fmt.Errorf("amount must not be negative")
250 }
251 return amount, nil
252}
253
254func newAddress(ctx contractapi.TransactionContextInterface, prefix string) string {
255 sum := sha256.Sum256([]byte(prefix + ":" + ctx.GetStub().GetTxID()))

Callers 3

CreateUserMethod · 0.70
ChangeStatusMethod · 0.70
parsePositiveAmountFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected