(cVersion byte, contractAddr, fromAddr, toAddr common.Address)
| 341 | } |
| 342 | |
| 343 | func GetContractAllowance(cVersion byte, contractAddr, fromAddr, toAddr common.Address) (uint64, error) { |
| 344 | type allowanceStruct struct { |
| 345 | From common.Address |
| 346 | To common.Address |
| 347 | } |
| 348 | mutable, err := NewNativeInvokeTransaction(0, 0, contractAddr, cVersion, "allowance", |
| 349 | []interface{}{&allowanceStruct{ |
| 350 | From: fromAddr, |
| 351 | To: toAddr, |
| 352 | }}) |
| 353 | if err != nil { |
| 354 | return 0, fmt.Errorf("NewNativeInvokeTransaction error:%s", err) |
| 355 | } |
| 356 | |
| 357 | tx, err := mutable.IntoImmutable() |
| 358 | if err != nil { |
| 359 | return 0, err |
| 360 | } |
| 361 | |
| 362 | result, err := bactor.PreExecuteContract(tx) |
| 363 | if err != nil { |
| 364 | return 0, fmt.Errorf("PrepareInvokeContract error:%s", err) |
| 365 | } |
| 366 | if result.State == 0 { |
| 367 | return 0, fmt.Errorf("prepare invoke failed") |
| 368 | } |
| 369 | data, err := hex.DecodeString(result.Result.(string)) |
| 370 | if err != nil { |
| 371 | return 0, fmt.Errorf("hex.DecodeString error:%s", err) |
| 372 | } |
| 373 | allowance := common.BigIntFromNeoBytes(data) |
| 374 | return allowance.Uint64(), nil |
| 375 | } |
| 376 | |
| 377 | func GetGasPrice() (map[string]interface{}, error) { |
| 378 | start := bactor.GetCurrentBlockHeight() |
no test coverage detected