(ctx contractapi.TransactionContextInterface, energy string, money string)
| 42 | } |
| 43 | |
| 44 | func (s *SmartContract) CreateUser(ctx contractapi.TransactionContextInterface, energy string, money string) (*Home, error) { |
| 45 | energyValue, err := parseNonNegativeAmount(energy) |
| 46 | if err != nil { |
| 47 | return nil, err |
| 48 | } |
| 49 | moneyValue, err := parseNonNegativeAmount(money) |
| 50 | if err != nil { |
| 51 | return nil, err |
| 52 | } |
| 53 | id, err := nextID(ctx, homeCounterKey) |
| 54 | if err != nil { |
| 55 | return nil, err |
| 56 | } |
| 57 | address := newAddress(ctx, "home") |
| 58 | home := &Home{ |
| 59 | Address: address, |
| 60 | Energy: energyValue, |
| 61 | Money: moneyValue, |
| 62 | ID: id, |
| 63 | Status: homeAvailableForTrade, |
| 64 | PriKey: address + "1", |
| 65 | PubKey: address + "2", |
| 66 | } |
| 67 | if err := putHome(ctx, home); err != nil { |
| 68 | return nil, err |
| 69 | } |
| 70 | return home, nil |
| 71 | } |
| 72 | |
| 73 | func (s *SmartContract) BuyByAddress(ctx contractapi.TransactionContextInterface, sellerAddress string, buyerSignature string, buyerAddress string, energy string) (*EnergyTransaction, error) { |
| 74 | energyValue, err := parsePositiveAmount(energy) |
nothing calls this directly
no test coverage detected