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

Function parsePositiveAmount

11_app_dev/chaincode_example03.go:306–315  ·  view source on GitHub ↗
(value string)

Source from the content-addressed store, hash-verified

304}
305
306func parsePositiveAmount(value string) (int, error) {
307 amount, err := strconv.Atoi(value)
308 if err != nil {
309 return 0, fmt.Errorf("amount must be an integer: %w", err)
310 }
311 if amount <= 0 {
312 return 0, fmt.Errorf("amount must be greater than zero")
313 }
314 return amount, nil
315}
316
317func recordTransaction(ctx contractapi.TransactionContextInterface, fromType int, fromID int, toType int, toID int, amount int) (*Transaction, error) {
318 id, err := nextID(ctx, transferCounterKey)

Callers 3

InitLedgerMethod · 0.70
IssueCoinMethod · 0.70
parseIDAndAmountFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected