Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export signer account instead of signatures #272

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/transform/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type TransactionOutput struct {
TotalNonRefundableResourceFeeCharged int64 `json:"non_refundable_resource_fee_charged"`
TotalRefundableResourceFeeCharged int64 `json:"refundable_resource_fee_charged"`
RentFeeCharged int64 `json:"rent_fee_charged"`
Signatures []string `json:"signatures"`
TxSigners []string `json:"tx_signers"`
}

type LedgerTransactionOutput struct {
Expand Down
27 changes: 21 additions & 6 deletions internal/transform/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/stellar/stellar-etl/internal/utils"

"github.com/stellar/go/ingest"
"github.com/stellar/go/strkey"
"github.com/stellar/go/xdr"
)

Expand Down Expand Up @@ -188,6 +189,11 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe

outputTxResultCode := transaction.Result.Result.Result.Code.String()

txSigners, err := getTxSigners(transaction.Envelope.Signatures())
if err != nil {
return TransactionOutput{}, err
}

outputSuccessful := transaction.Result.Successful()
transformedTransaction := TransactionOutput{
TransactionHash: outputTransactionHash,
Expand Down Expand Up @@ -224,7 +230,7 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe
TotalNonRefundableResourceFeeCharged: outputTotalNonRefundableResourceFeeCharged,
TotalRefundableResourceFeeCharged: outputTotalRefundableResourceFeeCharged,
RentFeeCharged: outputRentFeeCharged,
Signatures: getSignatures(transaction.Envelope.Signatures()),
TxSigners: txSigners,
}

// Add Muxed Account Details, if exists
Expand All @@ -249,8 +255,12 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe
innerHash := transaction.Result.InnerHash()
transformedTransaction.InnerTransactionHash = hex.EncodeToString(innerHash[:])
transformedTransaction.NewMaxFee = uint32(transaction.Envelope.FeeBumpFee())
txSigners, err := getTxSigners(transaction.Envelope.FeeBump.Signatures)
if err != nil {
return TransactionOutput{}, err
}

transformedTransaction.Signatures = getSignatures(transaction.Envelope.FeeBump.Signatures)
transformedTransaction.TxSigners = txSigners
}

return transformedTransaction, nil
Expand Down Expand Up @@ -299,11 +309,16 @@ func formatSigners(s []xdr.SignerKey) pq.StringArray {
return signers
}

func getSignatures(xdrSignatures []xdr.DecoratedSignature) []string {
signatures := make([]string, len(xdrSignatures))
func getTxSigners(xdrSignatures []xdr.DecoratedSignature) ([]string, error) {
signers := make([]string, len(xdrSignatures))

for i, sig := range xdrSignatures {
signatures[i] = base64.StdEncoding.EncodeToString(sig.Signature)
signerAccount, err := strkey.Encode(strkey.VersionByteAccountID, sig.Signature)
if err != nil {
return nil, err
}
signers[i] = signerAccount
}

return signatures
return signers, nil
}
6 changes: 3 additions & 3 deletions internal/transform/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) {
SorobanResourcesReadBytes: 0,
SorobanResourcesWriteBytes: 0,
TransactionResultCode: "TransactionResultCodeTxFailed",
Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0wEO7aECA=="},
TxSigners: []string{"GD2GXC24XWOM6T2UHABEMSYW5UZGJ4U7WEN7AQT2WYW32TQFP4ND3M7O4VGCBTT2BWNILFEVDX5DBBBMK2RTQIBMJNL6F62MAQ53NBAIXUDA"},
},
{
TxEnvelope: "AAAABQAAAQAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHCAAAAACAAAAAIjhprSlcVKPqp8m4g5svD/nPK6AtEZjDFvvAVKvcH14AAAAAAIU9jYAAAB9AAAAAQAAAAAAAAAAAAAAAF8Gq3QAAAABAAAAF0hMNWFDZ296UUhJVzdzU2M1WGRjZm1SAAAAAAEAAAABAAAAABxHQZcY7vqkWzjLfy8lUBqeOcuDh6Y26fvMDHSkdwMYAAAAAgAAAAAAAAAAAAAAAAAAAAABAgMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABY0KvjwAAAED0a4tcvZzPT1Q4AkZLFu0yZPKfsRvwQnq2Lb1OBX8aPbPu5UwgznoNmoWUlR36MIQsVqM4ICxLV+L7TAQ7toQI",
Expand Down Expand Up @@ -136,7 +136,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) {
SorobanResourcesReadBytes: 0,
SorobanResourcesWriteBytes: 0,
TransactionResultCode: "TransactionResultCodeTxFeeBumpInnerSuccess", //inner fee bump success
Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0wEO7aECA=="},
TxSigners: []string{"GD2GXC24XWOM6T2UHABEMSYW5UZGJ4U7WEN7AQT2WYW32TQFP4ND3M7O4VGCBTT2BWNILFEVDX5DBBBMK2RTQIBMJNL6F62MAQ53NBAIXUDA"},
},
{
TxEnvelope: "AAAAAgAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAGQBpLyvsiV6gwAAAAIAAAABAAAAAAAAAAAAAAAAXwardAAAAAEAAAAFAAAACgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAMCAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFjQq+PAAAAQPRri1y9nM9PVDgCRksW7TJk8p+xG/BCerYtvU4Ffxo9s+7lTCDOeg2ahZSVHfowhCxWozggLEtX4vtMBDu2hAg=",
Expand Down Expand Up @@ -166,7 +166,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) {
SorobanResourcesReadBytes: 0,
SorobanResourcesWriteBytes: 0,
TransactionResultCode: "TransactionResultCodeTxInsufficientBalance",
Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0wEO7aECA=="},
TxSigners: []string{"GD2GXC24XWOM6T2UHABEMSYW5UZGJ4U7WEN7AQT2WYW32TQFP4ND3M7O4VGCBTT2BWNILFEVDX5DBBBMK2RTQIBMJNL6F62MAQ53NBAIXUDA"},
},
}
return
Expand Down
Loading