Skip to content

Commit 80fcb3f

Browse files
committed
fix: init account balance if account is not exist
1 parent 04ac63e commit 80fcb3f

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ linter:
4848

4949

5050
contract-zip:
51-
@mkdir tmp && cd tmp && unzip ../example/contracts.zip
51+
@rm -rf tmp && mkdir tmp && cd tmp && unzip -q ../example/contracts.zip
5252
@cd example/contracts/src/broker && cp -r ../../../../tmp/contracts/src/broker/vendor ./
5353
@cd example/contracts/src/data_swapper && cp -r ../../../../tmp/contracts/src/data_swapper/vendor ./
5454
@cd example/contracts/src/transfer && cp -r ../../../../tmp/contracts/src/transfer/vendor ./
5555
@cd example/contracts/src/transaction && cp -r ../../../../tmp/contracts/src/transaction/vendor ./
5656
@rm -rf tmp example/contracts.zip
57-
@cd example && zip -r contracts.zip contracts
57+
@cd example && zip -r -q contracts.zip contracts
5858
@printf "${GREEN}Build contracts.zip successfully!${NC}\n"

example/contracts.zip

1.36 MB
Binary file not shown.

example/contracts/src/transfer/helper.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ func getUint64(stub shim.ChaincodeStubInterface, key string) (uint64, error) {
2121
if err != nil {
2222
return 0, fmt.Errorf("amount must be an interger %w", err)
2323
}
24-
24+
// init value if not exist
25+
if value == nil {
26+
return 0, nil
27+
}
2528
ret, err := strconv.ParseUint(string(value), 10, 64)
2629
if err != nil {
2730
return 0, err

0 commit comments

Comments
 (0)