From dc9c83e32e500ab4627831fe7536d38401381b29 Mon Sep 17 00:00:00 2001 From: Simon Chow Date: Thu, 22 Feb 2024 14:15:40 -0500 Subject: [PATCH] Fix soroban hashes to hexstring --- internal/transform/contract_code.go | 4 +--- internal/transform/contract_code_test.go | 4 ++-- internal/transform/contract_data_test.go | 2 +- internal/transform/operation.go | 3 +-- internal/transform/ttl.go | 4 +--- internal/transform/ttl_test.go | 2 +- internal/utils/main.go | 3 +-- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/internal/transform/contract_code.go b/internal/transform/contract_code.go index a243038a..8bfcf574 100644 --- a/internal/transform/contract_code.go +++ b/internal/transform/contract_code.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/stellar/go/ingest" - "github.com/stellar/go/strkey" "github.com/stellar/go/xdr" "github.com/stellar/stellar-etl/internal/utils" ) @@ -30,8 +29,7 @@ func TransformContractCode(ledgerChange ingest.Change, header xdr.LedgerHeaderHi contractCodeExtV := contractCode.Ext.V - contractCodeHashByte, _ := contractCode.Hash.MarshalBinary() - contractCodeHash, _ := strkey.Encode(strkey.VersionByteContract, contractCodeHashByte) + contractCodeHash := contractCode.Hash.HexString() closedAt, err := utils.TimePointToUTCTimeStamp(header.Header.ScpValue.CloseTime) if err != nil { diff --git a/internal/transform/contract_code_test.go b/internal/transform/contract_code_test.go index 72ba3408..812bd446 100644 --- a/internal/transform/contract_code_test.go +++ b/internal/transform/contract_code_test.go @@ -86,14 +86,14 @@ func makeContractCodeTestInput() []ingest.Change { func makeContractCodeTestOutput() []ContractCodeOutput { return []ContractCodeOutput{ { - ContractCodeHash: "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4", + ContractCodeHash: "0000000000000000000000000000000000000000000000000000000000000000", ContractCodeExtV: 1, LastModifiedLedger: 24229503, LedgerEntryChange: 1, Deleted: false, LedgerSequence: 10, ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC), - LedgerKeyHash: "CDP62BQ5XZDE4D7TEB2E7TLAJLAIWOO2U5H2EQIQSNTFJS6LSFOMZRZJ", + LedgerKeyHash: "dfed061dbe464e0ff320744fcd604ac08b39daa74fa24110936654cbcb915ccc", }, } } diff --git a/internal/transform/contract_data_test.go b/internal/transform/contract_data_test.go index c215a4bd..d09ab588 100644 --- a/internal/transform/contract_data_test.go +++ b/internal/transform/contract_data_test.go @@ -138,7 +138,7 @@ func makeContractDataTestOutput() []ContractDataOutput { Deleted: false, LedgerSequence: 10, ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC), - LedgerKeyHash: "CCV7YMZHECK2TX2MGEGP6GEQIAMSVCXON5VCHNVUMKEJCFGYA4UMUUCA", + LedgerKeyHash: "abfc33272095a9df4c310cff189040192a8aee6f6a23b6b462889114d80728ca", }, } } diff --git a/internal/transform/operation.go b/internal/transform/operation.go index 36463ab8..9229419b 100644 --- a/internal/transform/operation.go +++ b/internal/transform/operation.go @@ -1707,8 +1707,7 @@ func contractCodeFromContractData(ledgerKey xdr.LedgerKey) string { return "" } - contractCodeHashByte, _ := contractCode.Hash.MarshalBinary() - contractCodeHash, _ := strkey.Encode(strkey.VersionByteContract, contractCodeHashByte) + contractCodeHash := contractCode.Hash.HexString() return contractCodeHash } diff --git a/internal/transform/ttl.go b/internal/transform/ttl.go index 4a81a701..cb9218e1 100644 --- a/internal/transform/ttl.go +++ b/internal/transform/ttl.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/stellar/go/ingest" - "github.com/stellar/go/strkey" "github.com/stellar/go/xdr" "github.com/stellar/stellar-etl/internal/utils" ) @@ -26,8 +25,7 @@ func TransformTtl(ledgerChange ingest.Change, header xdr.LedgerHeaderHistoryEntr return TtlOutput{}, nil } - keyHashByte, _ := ttl.KeyHash.MarshalBinary() - keyHash, _ := strkey.Encode(strkey.VersionByteContract, keyHashByte) + keyHash := ttl.KeyHash.HexString() liveUntilLedgerSeq := ttl.LiveUntilLedgerSeq closedAt, err := utils.TimePointToUTCTimeStamp(header.Header.ScpValue.CloseTime) diff --git a/internal/transform/ttl_test.go b/internal/transform/ttl_test.go index 2307fe0c..4d49a54b 100644 --- a/internal/transform/ttl_test.go +++ b/internal/transform/ttl_test.go @@ -95,7 +95,7 @@ func makeTtlTestInput() []ingest.Change { func makeTtlTestOutput() []TtlOutput { return []TtlOutput{ { - KeyHash: "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4", + KeyHash: "0000000000000000000000000000000000000000000000000000000000000000", LiveUntilLedgerSeq: 123, LastModifiedLedger: 1, LedgerEntryChange: 1, diff --git a/internal/utils/main.go b/internal/utils/main.go index 7a0a940d..1a36eabb 100644 --- a/internal/utils/main.go +++ b/internal/utils/main.go @@ -16,7 +16,6 @@ import ( "github.com/stellar/go/ingest/ledgerbackend" "github.com/stellar/go/keypair" "github.com/stellar/go/network" - "github.com/stellar/go/strkey" "github.com/stellar/go/support/storage" "github.com/stellar/go/txnbuild" "github.com/stellar/go/xdr" @@ -710,7 +709,7 @@ func LedgerEntryToLedgerKeyHash(ledgerEntry xdr.LedgerEntry) string { ledgerKey, _ := ledgerEntry.LedgerKey() ledgerKeyByte, _ := ledgerKey.MarshalBinary() hashedLedgerKeyByte := hash.Hash(ledgerKeyByte) - ledgerKeyHash, _ := strkey.Encode(strkey.VersionByteContract, hashedLedgerKeyByte[:]) + ledgerKeyHash := hex.EncodeToString(hashedLedgerKeyByte[:]) return ledgerKeyHash }