You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tx_processing.go
    path of file: ./repos/wormhole/node/pkg/watchers/near
    
    the code of the file until where you have to start completion: package near

import (
	"context"
	"encoding/base64"
	"encoding/hex"
	"encoding/json"
	"errors"
	"fmt"
	"strconv"
	"strings"
	"time"

	"github.com/certusone/wormhole/node/pkg/common"
	"github.com/certusone/wormhole/node/pkg/watchers/near/nearapi"
	eth_common "github.com/ethereum/go-ethereum/common"
	"github.com/mr-tron/base58"
	"github.com/tidwall/gjson"
	"github.com/wormhole-foundation/wormhole/sdk/vaa"
	"go.uber.org/zap"
)

type NearWormholePublishEvent struct {
	Standard    string `json:"standard"`
	Event       string `json:"event"`
	Data        string `json:"data"`
	Nonce       uint32 `json:"nonce"`
	Emitter     string `json:"emitter"`
	Seq         uint64 `json:"seq"`
	BlockHeight uint64 `json:"block"`
}

// processTx fetches a transaction's receipt_outcomes and l
    
func (e *Watcher) processOutcome(logger *zap.Logger, ctx context.Context, job *transactionProcessingJob, receiptOutcome gjson.Result) error {
	outcome := receiptOutcome.Get("outcome")
	if !outcome.Exists() {
		logger.Warn("NEAR RPC malformed response: receipts_outcome.outcome does not exist", zap.String("error_type", "nearapi_inconsistent"), zap.String("json", receiptOutcome.Str))
		return errors.New("NEAR RPC malformed response")
	}

	executor_id := outcome.Get("executor_id")
	if !executor_id.Exists() {
		logger.Warn("NEAR RPC malformed response: receipts_outcome.outcome does not exist", zap.String("error_type", "nearapi_inconsistent"), zap.String("json", receiptOutcome.Str))
		return errors.New("NEAR RPC malformed response: receipts_outcome.outcome does not exist")
	}

	// SECURITY CRITICAL: Check that the outcome relates to the Wormhole core contract on NEAR.
	// according to near source documentation, executor_id is the id of the account on which the execution happens:
	// for transaction this is signer_id
	// for receipt this is receiver_id, i.e. the account on which the receipt has been applied
	if executor_id.String() == "" || executor_id.String() != e.wormholeAccount {
		return nil
	}

	logger.Debug("Found a Wormhole Transaction... Now checking if it's a valid log emission.", zap.String("tx_hash", job.txHash))

	outcomeBlockHash := receiptOutcome.Get("block_hash")
	if !outcomeBlockHash.Exists() {
		logger.Warn("NEAR RPC malformed response: receipts_outcome.block_hash does not exist", zap.String("error_type", "nearapi_inconsistent"), zap.String("json", receiptOutcome.Str))
		return errors.New("NEAR RPC malformed response: receipts_outcome.block_hash does not exist")
	}

	l := outcome.Get("logs")
	if !l.Exists() {
		logger.Warn("NEAR RPC malformed response: receipts_outcome.outcome.logs does not exist", zap.String("error_type", "nearapi_inconsistent"), zap.String("json", receiptOutcome.Str))
		return errors.New("NEAR RPC malformed response: receipts_outcome.outcome.logs does not exist")
	}

	// SECURITY CRITICAL: Check that block has been finalized.
	outcomeBlockHeader, isFinalized := e.finalizer.isFinalized(logger, ctx, outcomeBlockHash.String())
	if !isFinalized {
		// If it has not, we return an error such that this transaction can be put back into the queue.
		return fmt.Errorf("block %s not finalized yet", outcomeBlockHash.String())
	}

	successValue := outcome.Get("status.SuccessValue")
	if !successValue.Exists() || successValue.String() == "" {
		return errors.New("outcome.status.SuccessValue does not exist")
	}

	for _, log := range l.Array() {
		err := e.processWormholeLog(logger, ctx, job, outcomeBlockHeader, successValue.String(), log)
		if err != nil {
			// SECURITY defense-in-depth: If one of the logs is malformed, we skip processing the other logs for defense in depth
			return err
		}
	}
	return nil // SUCCESS
}