From 2e51f56d32d5597ba30164a636aa3a413649f924 Mon Sep 17 00:00:00 2001 From: romever <360876221@qq.com> Date: Tue, 16 Jul 2024 20:04:24 +0800 Subject: [PATCH] feat: Runtime evm transaction content add hash field.All runtime transactions use consensus hash. --- .../logic/runtime/runtimetransactioninfologic.go | 11 ++++++++++- api/internal/types/types.go | 1 + api/oasisscan.api | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/api/internal/logic/runtime/runtimetransactioninfologic.go b/api/internal/logic/runtime/runtimetransactioninfologic.go index 387501b..57723db 100644 --- a/api/internal/logic/runtime/runtimetransactioninfologic.go +++ b/api/internal/logic/runtime/runtimetransactioninfologic.go @@ -49,11 +49,19 @@ func (l *RuntimeTransactionInfoLogic) RuntimeTransactionInfo(req *types.RuntimeT return nil, errort.NewDefaultError() } + if txModel == nil { + return nil, nil + } + + runtimeName := "" runtimeModel, err := l.svcCtx.RuntimeModel.FindOneByRuntimeId(l.ctx, runtimeId) if err != nil && !errors.Is(err, sqlx.ErrNotFound) { logc.Errorf(l.ctx, "find runtime info error, %v", err) return nil, errort.NewDefaultError() } + if runtimeModel != nil { + runtimeName = runtimeModel.Name + } var consensusTx *types.RuntimeTransactionConsensusTx = nil var evmTx *types.RuntimeTransactionEvmTx = nil @@ -71,6 +79,7 @@ func (l *RuntimeTransactionInfoLogic) RuntimeTransactionInfo(req *types.RuntimeT return nil, errort.NewDefaultError() } evmTx = &types.RuntimeTransactionEvmTx{ + Hash: txModel.EvmHash, From: txModel.EvmFrom, To: txModel.EvmTo, Nonce: int64(txData.Nonce()), @@ -150,7 +159,7 @@ func (l *RuntimeTransactionInfoLogic) RuntimeTransactionInfo(req *types.RuntimeT resp = &types.RuntimeTransactionInfoResponse{ RuntimeId: runtimeId, - RuntimeName: runtimeModel.Name, + RuntimeName: runtimeName, TxHash: txModel.TxHash, Round: txModel.Round, Result: txModel.Result, diff --git a/api/internal/types/types.go b/api/internal/types/types.go index a66d60b..2dcfb9c 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -454,6 +454,7 @@ type RuntimeTransactionEventError struct { } type RuntimeTransactionEvmTx struct { + Hash string `json:"hash"` From string `json:"from"` To string `json:"to"` Nonce int64 `json:"nonce"` diff --git a/api/oasisscan.api b/api/oasisscan.api index b1a5d6c..155448b 100644 --- a/api/oasisscan.api +++ b/api/oasisscan.api @@ -387,6 +387,7 @@ type ( Nonce int64 `json:"nonce"` } RuntimeTransactionEvmTx { + Hash string `json:"hash"` From string `json:"from"` To string `json:"to"` Nonce int64 `json:"nonce"`