Skip to content

Commit

Permalink
Export signer account instead of signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
amishas157 committed Jul 30, 2024
1 parent ffe275c commit aaaad05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
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
15 changes: 9 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 @@ -224,7 +225,7 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe
TotalNonRefundableResourceFeeCharged: outputTotalNonRefundableResourceFeeCharged,
TotalRefundableResourceFeeCharged: outputTotalRefundableResourceFeeCharged,
RentFeeCharged: outputRentFeeCharged,
Signatures: getSignatures(transaction.Envelope.Signatures()),
TxSigners: getTxSigners(transaction.Envelope.Signatures()),
}

// Add Muxed Account Details, if exists
Expand All @@ -250,7 +251,7 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe
transformedTransaction.InnerTransactionHash = hex.EncodeToString(innerHash[:])
transformedTransaction.NewMaxFee = uint32(transaction.Envelope.FeeBumpFee())

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

return transformedTransaction, nil
Expand Down Expand Up @@ -299,11 +300,13 @@ 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 {
signers := make([]string, len(xdrSignatures))

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

return signatures
return signers
}
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

0 comments on commit aaaad05

Please sign in to comment.