(cVersion byte, contractAddres []common.Address, accAddr common.Address, atomic bool)
| 305 | } |
| 306 | |
| 307 | func GetContractBalance(cVersion byte, contractAddres []common.Address, accAddr common.Address, atomic bool) ([]uint64, uint32, error) { |
| 308 | txes := make([]*types.Transaction, 0, len(contractAddres)) |
| 309 | for _, contractAddr := range contractAddres { |
| 310 | mutable, err := NewNativeInvokeTransaction(0, 0, contractAddr, cVersion, "balanceOf", []interface{}{accAddr[:]}) |
| 311 | if err != nil { |
| 312 | return nil, 0, fmt.Errorf("NewNativeInvokeTransaction error:%s", err) |
| 313 | } |
| 314 | tx, err := mutable.IntoImmutable() |
| 315 | if err != nil { |
| 316 | return nil, 0, err |
| 317 | } |
| 318 | |
| 319 | txes = append(txes, tx) |
| 320 | } |
| 321 | |
| 322 | results, height, err := bactor.PreExecuteContractBatch(txes, atomic) |
| 323 | if err != nil { |
| 324 | return nil, 0, fmt.Errorf("PrepareInvokeContract error:%s", err) |
| 325 | } |
| 326 | balances := make([]uint64, 0, len(contractAddres)) |
| 327 | for _, result := range results { |
| 328 | if result.State == 0 { |
| 329 | return nil, 0, fmt.Errorf("prepare invoke failed") |
| 330 | } |
| 331 | data, err := hex.DecodeString(result.Result.(string)) |
| 332 | if err != nil { |
| 333 | return nil, 0, fmt.Errorf("hex.DecodeString error:%s", err) |
| 334 | } |
| 335 | |
| 336 | balance := common.BigIntFromNeoBytes(data) |
| 337 | balances = append(balances, balance.Uint64()) |
| 338 | } |
| 339 | |
| 340 | return balances, height, nil |
| 341 | } |
| 342 | |
| 343 | func GetContractAllowance(cVersion byte, contractAddr, fromAddr, toAddr common.Address) (uint64, error) { |
| 344 | type allowanceStruct struct { |
no test coverage detected