diff --git a/node/pkg/near/watcher.go b/node/pkg/near/watcher.go index 65a841d752..1f925e88dc 100644 --- a/node/pkg/near/watcher.go +++ b/node/pkg/near/watcher.go @@ -389,20 +389,6 @@ func (e *Watcher) Run(ctx context.Context) error { logger.Info("Near watcher connecting to RPC node ", zap.String("url", e.nearRPC)) go func() { - if e.next_round == 0 { - finalBody, err := e.getFinalBlock() - if err != nil { - logger.Error("StatusAfterBlock", zap.Error(err)) - p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDNear, 1) - errC <- err - return - } - e.next_round = gjson.ParseBytes(finalBody).Get("result.chunks.0.height_created").Uint() - } - - timer := time.NewTicker(time.Second * 1) - defer timer.Stop() - for { select { case <-ctx.Done(): @@ -420,7 +406,29 @@ func (e *Watcher) Run(ctx context.Context) error { if err != nil { logger.Error(fmt.Sprintf("near obsvReqC: %s", err.Error())) } + } + } + }() + + go func() { + if e.next_round == 0 { + finalBody, err := e.getFinalBlock() + if err != nil { + logger.Error("StatusAfterBlock", zap.Error(err)) + p2p.DefaultRegistry.AddErrorCount(vaa.ChainIDNear, 1) + errC <- err + return + } + e.next_round = gjson.ParseBytes(finalBody).Get("result.chunks.0.height_created").Uint() + } + timer := time.NewTicker(time.Second * 1) + defer timer.Stop() + + for { + select { + case <-ctx.Done(): + return case <-timer.C: finalBody, err := e.getFinalBlock() if err != nil { @@ -456,6 +464,13 @@ func (e *Watcher) Run(ctx context.Context) error { logger.Info("lastBlock", zap.Uint64("lastBlock", lastBlock), zap.Uint64("next_round", e.next_round)) for ; e.next_round <= lastBlock; e.next_round = e.next_round + 1 { + currentNearHeight.Set(float64(e.next_round)) + p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDNear, &gossipv1.Heartbeat_Network{ + Height: int64(e.next_round), + ContractAddress: e.wormholeContract, + }) + readiness.SetReady(common.ReadinessNearSyncing) + if e.next_round == lastBlock { err := e.inspectBody(logger, e.next_round, parsedFinalBody) if err != nil { @@ -487,13 +502,6 @@ func (e *Watcher) Run(ctx context.Context) error { } } } - - currentNearHeight.Set(float64(e.next_round - 1)) - p2p.DefaultRegistry.SetNetworkStats(vaa.ChainIDNear, &gossipv1.Heartbeat_Network{ - Height: int64(e.next_round - 1), - ContractAddress: e.wormholeContract, - }) - readiness.SetReady(common.ReadinessNearSyncing) } } }() diff --git a/sdk/js/src/token_bridge/transfer.ts b/sdk/js/src/token_bridge/transfer.ts index be67285daa..04b41d71f1 100644 --- a/sdk/js/src/token_bridge/transfer.ts +++ b/sdk/js/src/token_bridge/transfer.ts @@ -771,11 +771,11 @@ export async function transferNearFromNear( args: { receiver: uint8ArrayToHex(receiver), chain: chain, - fee: fee.toString(), + fee: fee.toString(10), payload: payload, message_fee: message_fee, }, - attachedDeposit: (new BN(qty.toString()).add(new BN(message_fee))), + attachedDeposit: (new BN(qty.toString(10)).add(new BN(message_fee))), gas: new BN("100000000000000"), });