Skip to content

Commit

Permalink
Add signatures result in transaction output (#271)
Browse files Browse the repository at this point in the history
* Add signatures result in transaction output

* update tests

* Add signature for fee bump account as well
  • Loading branch information
amishas157 authored Jul 30, 2024
1 parent e8aaa9c commit ffe275c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/transform/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +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"`
}

type LedgerTransactionOutput struct {
Expand Down
12 changes: 12 additions & 0 deletions internal/transform/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe
TotalNonRefundableResourceFeeCharged: outputTotalNonRefundableResourceFeeCharged,
TotalRefundableResourceFeeCharged: outputTotalRefundableResourceFeeCharged,
RentFeeCharged: outputRentFeeCharged,
Signatures: getSignatures(transaction.Envelope.Signatures()),
}

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

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

return transformedTransaction, nil
Expand Down Expand Up @@ -295,3 +298,12 @@ func formatSigners(s []xdr.SignerKey) pq.StringArray {

return signers
}

func getSignatures(xdrSignatures []xdr.DecoratedSignature) []string {
signatures := make([]string, len(xdrSignatures))
for i, sig := range xdrSignatures {
signatures[i] = base64.StdEncoding.EncodeToString(sig.Signature)
}

return signatures
}
27 changes: 24 additions & 3 deletions internal/transform/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) {
correctTime, err := time.Parse("2006-1-2 15:04:05 MST", "2020-07-09 05:28:42 UTC")
output = []TransactionOutput{
{
TxEnvelope: "AAAAAgAAAACI4aa0pXFSj6qfJuIObLw/5zyugLRGYwxb7wFSr3B9eAABX5ABjydzAABBtwAAAAEAAAAAAAAAAAAAAABfBqt0AAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
TxEnvelope: "AAAAAgAAAACI4aa0pXFSj6qfJuIObLw/5zyugLRGYwxb7wFSr3B9eAABX5ABjydzAABBtwAAAAEAAAAAAAAAAAAAAABfBqt0AAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFjQq+PAAAAQPRri1y9nM9PVDgCRksW7TJk8p+xG/BCerYtvU4Ffxo9s+7lTCDOeg2ahZSVHfowhCxWozggLEtX4vtMBDu2hAg=",
TxResult: "AAAAAAAAASz/////AAAAAQAAAAAAAAAAAAAAAAAAAAA=",
TxMeta: "AAAAAQAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAAA",
TxFeeMeta: "AAAAAA==",
Expand All @@ -106,9 +106,10 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) {
SorobanResourcesReadBytes: 0,
SorobanResourcesWriteBytes: 0,
TransactionResultCode: "TransactionResultCodeTxFailed",
Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0wEO7aECA=="},
},
{
TxEnvelope: "AAAABQAAAQAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAAA",
TxFeeMeta: "AAAAAA==",
Expand All @@ -135,9 +136,10 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) {
SorobanResourcesReadBytes: 0,
SorobanResourcesWriteBytes: 0,
TransactionResultCode: "TransactionResultCodeTxFeeBumpInnerSuccess", //inner fee bump success
Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAAA",
TxFeeMeta: "AAAAAA==",
Expand All @@ -164,6 +166,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) {
SorobanResourcesReadBytes: 0,
SorobanResourcesWriteBytes: 0,
TransactionResultCode: "TransactionResultCodeTxInsufficientBalance",
Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0wEO7aECA=="},
},
}
return
Expand Down Expand Up @@ -232,6 +235,12 @@ func makeTransactionTestInput() (transaction []ingest.LedgerTransaction, history
},
},
},
Signatures: []xdr.DecoratedSignature{
{
Hint: xdr.SignatureHint{99, 66, 175, 143},
Signature: xdr.Signature{244, 107, 139, 92, 189, 156, 207, 79, 84, 56, 2, 70, 75, 22, 237, 50, 100, 242, 159, 177, 27, 240, 66, 122, 182, 45, 189, 78, 5, 127, 26, 61, 179, 238, 229, 76, 32, 206, 122, 13, 154, 133, 148, 149, 29, 250, 48, 132, 44, 86, 163, 56, 32, 44, 75, 87, 226, 251, 76, 4, 59, 182, 132, 8},
},
},
},
},
Result: xdr.TransactionResultPair{
Expand Down Expand Up @@ -286,6 +295,12 @@ func makeTransactionTestInput() (transaction []ingest.LedgerTransaction, history
},
},
},
Signatures: []xdr.DecoratedSignature{
{
Hint: xdr.SignatureHint{99, 66, 175, 143},
Signature: xdr.Signature{244, 107, 139, 92, 189, 156, 207, 79, 84, 56, 2, 70, 75, 22, 237, 50, 100, 242, 159, 177, 27, 240, 66, 122, 182, 45, 189, 78, 5, 127, 26, 61, 179, 238, 229, 76, 32, 206, 122, 13, 154, 133, 148, 149, 29, 250, 48, 132, 44, 86, 163, 56, 32, 44, 75, 87, 226, 251, 76, 4, 59, 182, 132, 8},
},
},
},
},
Result: xdr.TransactionResultPair{
Expand Down Expand Up @@ -355,6 +370,12 @@ func makeTransactionTestInput() (transaction []ingest.LedgerTransaction, history
},
},
},
Signatures: []xdr.DecoratedSignature{
{
Hint: xdr.SignatureHint{99, 66, 175, 143},
Signature: xdr.Signature{244, 107, 139, 92, 189, 156, 207, 79, 84, 56, 2, 70, 75, 22, 237, 50, 100, 242, 159, 177, 27, 240, 66, 122, 182, 45, 189, 78, 5, 127, 26, 61, 179, 238, 229, 76, 32, 206, 122, 13, 154, 133, 148, 149, 29, 250, 48, 132, 44, 86, 163, 56, 32, 44, 75, 87, 226, 251, 76, 4, 59, 182, 132, 8},
},
},
},
},
Result: xdr.TransactionResultPair{
Expand Down

0 comments on commit ffe275c

Please sign in to comment.