@@ -391,28 +391,17 @@ cre.Promise[*evm.CallContractReply]
391391 {{- end }}
392392 }
393393
394- var bn cre.Promise [*pb.BigInt ]
395- if blockNumber == nil {
396- promise := c.client.HeaderByNumber (runtime, &evm.HeaderByNumberRequest {
397- BlockNumber: bindings.FinalizedBlockNumber ,
398- })
399-
400- bn = cre.Then (promise, func(finalizedBlock *evm.HeaderByNumberReply ) (*pb.BigInt , error) {
401- if finalizedBlock == nil || finalizedBlock.Header == nil {
402- return nil , errors.New (" failed to get finalized block header" )
403- }
404- return finalizedBlock.Header.BlockNumber , nil
405- })
406- } else {
407- bn = cre.PromiseFromResult (pb.NewBigIntFromInt (blockNumber), nil )
394+ bn := bindings.FinalizedBlockNumber
395+ if blockNumber != nil {
396+ bn = pb.NewBigIntFromInt (blockNumber)
408397 }
409398
410- promise := cre.ThenPromise (bn , func(bn *pb.BigInt ) cre.Promise [*evm.CallContractReply ] {
411- return c.client.CallContract (runtime, &evm.CallContractRequest {
412- Call: &evm.CallMsg {To: c.Address.Bytes (), Data: calldata},
413- BlockNumber: bn,
414- })
415- })
399+ promise := cre.ThenPromise (cre .PromiseFromResult (bn, nil ) , func(bn *pb.BigInt ) cre.Promise [*evm.CallContractReply ] {
400+ return c.client.CallContract (runtime, &evm.CallContractRequest {
401+ Call: &evm.CallMsg {To: c.Address.Bytes (), Data: calldata},
402+ BlockNumber: bn,
403+ })
404+ })
416405
417406 {{- if gt (len $call .Normalized.Outputs ) 0}}
418407 return cre.Then (promise, func(response *evm.CallContractReply ) ({{- if gt (len $call .Normalized.Outputs ) 1 -}}{{$call .Normalized.Name }}Output{{- else -}}{{with index $call .Normalized.Outputs 0}}{{bindtype .Type $ .Structs }}{{end }}{{- end }}, error) {
0 commit comments