From a780ab3d9187d299b8644056d53c63c846c1dd85 Mon Sep 17 00:00:00 2001 From: George Date: Wed, 9 Oct 2024 16:20:16 -0400 Subject: [PATCH 1/5] Add transaction hash to getTransaction as well --- cmd/soroban-rpc/internal/methods/get_transaction.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/soroban-rpc/internal/methods/get_transaction.go b/cmd/soroban-rpc/internal/methods/get_transaction.go index f08c89f6..b187d6f6 100644 --- a/cmd/soroban-rpc/internal/methods/get_transaction.go +++ b/cmd/soroban-rpc/internal/methods/get_transaction.go @@ -117,6 +117,7 @@ func GetTransaction( response.FeeBump = tx.FeeBump response.Ledger = tx.Ledger.Sequence response.LedgerCloseTime = tx.Ledger.CloseTime + response.TransactionHash = tx.TransactionHash switch request.Format { case FormatJSON: From d1de196c90a7ce674adc2663c06529c2c56395cc Mon Sep 17 00:00:00 2001 From: George Date: Wed, 9 Oct 2024 16:37:39 -0400 Subject: [PATCH 2/5] Add hash even in not-found case --- cmd/soroban-rpc/internal/methods/get_transaction.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/soroban-rpc/internal/methods/get_transaction.go b/cmd/soroban-rpc/internal/methods/get_transaction.go index b187d6f6..592a8880 100644 --- a/cmd/soroban-rpc/internal/methods/get_transaction.go +++ b/cmd/soroban-rpc/internal/methods/get_transaction.go @@ -100,6 +100,7 @@ func GetTransaction( OldestLedger: storeRange.FirstLedger.Sequence, OldestLedgerCloseTime: storeRange.FirstLedger.CloseTime, } + response.TransactionHash = request.Hash if errors.Is(err, db.ErrNoTransaction) { response.Status = TransactionStatusNotFound return response, nil @@ -117,7 +118,6 @@ func GetTransaction( response.FeeBump = tx.FeeBump response.Ledger = tx.Ledger.Sequence response.LedgerCloseTime = tx.Ledger.CloseTime - response.TransactionHash = tx.TransactionHash switch request.Format { case FormatJSON: From 3692f2d163451bde8a5473a89a0c1c18e6f8ded6 Mon Sep 17 00:00:00 2001 From: George Date: Thu, 24 Oct 2024 11:10:26 -0700 Subject: [PATCH 3/5] Add field check to tests --- cmd/soroban-rpc/internal/methods/get_transaction_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/soroban-rpc/internal/methods/get_transaction_test.go b/cmd/soroban-rpc/internal/methods/get_transaction_test.go index 847b2e6e..7c339481 100644 --- a/cmd/soroban-rpc/internal/methods/get_transaction_test.go +++ b/cmd/soroban-rpc/internal/methods/get_transaction_test.go @@ -64,6 +64,7 @@ func TestGetTransaction(t *testing.T) { Status: TransactionStatusSuccess, ApplicationOrder: 1, FeeBump: false, + TransactionHash: hash, EnvelopeXDR: expectedEnvelope, ResultXDR: expectedTxResult, ResultMetaXDR: expectedTxMeta, @@ -120,6 +121,7 @@ func TestGetTransaction(t *testing.T) { Status: TransactionStatusFailed, ApplicationOrder: 1, FeeBump: false, + TransactionHash: hash, EnvelopeXDR: expectedEnvelope, ResultXDR: expectedTxResult, ResultMetaXDR: expectedTxMeta, @@ -155,6 +157,7 @@ func TestGetTransaction(t *testing.T) { Status: TransactionStatusSuccess, ApplicationOrder: 1, FeeBump: false, + TransactionHash: hash, EnvelopeXDR: expectedEnvelope, ResultXDR: expectedTxResult, ResultMetaXDR: expectedTxMeta, From 69ef25340c4cb2387de60092bc0d7d58a1a0bef2 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 28 Oct 2024 16:42:30 -0700 Subject: [PATCH 4/5] Add hash to not-found test --- cmd/soroban-rpc/internal/methods/get_transaction_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/soroban-rpc/internal/methods/get_transaction_test.go b/cmd/soroban-rpc/internal/methods/get_transaction_test.go index 7c339481..91d6f0ce 100644 --- a/cmd/soroban-rpc/internal/methods/get_transaction_test.go +++ b/cmd/soroban-rpc/internal/methods/get_transaction_test.go @@ -37,7 +37,8 @@ func TestGetTransaction(t *testing.T) { require.NoError(t, err) require.Equal(t, GetTransactionResponse{ TransactionDetails: TransactionDetails{ - Status: TransactionStatusNotFound, + Status: TransactionStatusNotFound, + TransactionHash: hash, }, }, tx) From df39578edee6ffecbf398833504ccf4ffe19b01a Mon Sep 17 00:00:00 2001 From: George Date: Mon, 28 Oct 2024 16:48:40 -0700 Subject: [PATCH 5/5] One more missing hash case :facepalm: --- cmd/soroban-rpc/internal/methods/get_transaction_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/soroban-rpc/internal/methods/get_transaction_test.go b/cmd/soroban-rpc/internal/methods/get_transaction_test.go index 91d6f0ce..03f35658 100644 --- a/cmd/soroban-rpc/internal/methods/get_transaction_test.go +++ b/cmd/soroban-rpc/internal/methods/get_transaction_test.go @@ -90,6 +90,7 @@ func TestGetTransaction(t *testing.T) { TransactionDetails: TransactionDetails{ Status: TransactionStatusSuccess, ApplicationOrder: 1, + TransactionHash: hash, FeeBump: false, EnvelopeXDR: expectedEnvelope, ResultXDR: expectedTxResult,