From ab57fa432ba04f24e21dc9f364b1d60d63365814 Mon Sep 17 00:00:00 2001 From: Amisha Singla Date: Fri, 12 Jul 2024 12:40:21 -0700 Subject: [PATCH] Use FeeBumpAccount for setting FeeAccountMuxed (#265) * Use FeeBumpAccount for setting FeeAccountMuxed * dummy commit * Update tests --------- Co-authored-by: Simon Chow --- internal/transform/test_variables_test.go | 10 ++++++++++ internal/transform/transaction.go | 4 ++-- internal/transform/transaction_test.go | 7 ++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/internal/transform/test_variables_test.go b/internal/transform/test_variables_test.go index 7c984e96..43aadbcc 100644 --- a/internal/transform/test_variables_test.go +++ b/internal/transform/test_variables_test.go @@ -95,6 +95,16 @@ var testAccount4Address = "GBVVRXLMNCJQW3IDDXC3X6XCH35B5Q7QXNMMFPENSOGUPQO7WO7HG var testAccount4ID, _ = xdr.AddressToAccountId(testAccount4Address) var testAccount4 = testAccount4ID.ToMuxedAccount() +var dummyEd25519 [32]byte +var testAccount5 = xdr.MuxedAccount{ + Type: xdr.CryptoKeyTypeKeyTypeMuxedEd25519, + Med25519: &xdr.MuxedAccountMed25519{ + Id: xdr.Uint64(1), + Ed25519: xdr.Uint256(dummyEd25519), + }, +} +var testAccount5Address = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF" + // a selection of hardcoded assets and their AssetOutput representations var usdtAsset = xdr.Asset{ diff --git a/internal/transform/transaction.go b/internal/transform/transaction.go index 2ef9cec8..05375791 100644 --- a/internal/transform/transaction.go +++ b/internal/transform/transaction.go @@ -240,8 +240,8 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe if transaction.Envelope.IsFeeBump() { feeBumpAccount := transaction.Envelope.FeeBumpAccount() feeAccount := feeBumpAccount.ToAccountId() - if sourceAccount.Type == xdr.CryptoKeyTypeKeyTypeMuxedEd25519 { - feeAccountMuxed := feeAccount.Address() + if feeBumpAccount.Type == xdr.CryptoKeyTypeKeyTypeMuxedEd25519 { + feeAccountMuxed := feeBumpAccount.Address() transformedTransaction.FeeAccountMuxed = feeAccountMuxed } transformedTransaction.FeeAccount = feeAccount.Address() diff --git a/internal/transform/transaction_test.go b/internal/transform/transaction_test.go index fd1d8b47..7759b3a4 100644 --- a/internal/transform/transaction_test.go +++ b/internal/transform/transaction_test.go @@ -108,7 +108,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) { TransactionResultCode: "TransactionResultCodeTxFailed", }, { - TxEnvelope: "AAAABQAAAABnzACGTDuJFoxqr+C8NHCe0CHFBXLi+YhhNCIILCIpcgAAAAAAABwgAAAAAgAAAACI4aa0pXFSj6qfJuIObLw/5zyugLRGYwxb7wFSr3B9eAAAAAACFPY2AAAAfQAAAAEAAAAAAAAAAAAAAABfBqt0AAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", + TxEnvelope: "AAAABQAAAQAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHCAAAAACAAAAAIjhprSlcVKPqp8m4g5svD/nPK6AtEZjDFvvAVKvcH14AAAAAAIU9jYAAAB9AAAAAQAAAAAAAAAAAAAAAF8Gq3QAAAABAAAAF0hMNWFDZ296UUhJVzdzU2M1WGRjZm1SAAAAAAEAAAABAAAAABxHQZcY7vqkWzjLfy8lUBqeOcuDh6Y26fvMDHSkdwMYAAAAAgAAAAAAAAAAAAAAAAAAAAABAgMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", TxResult: "AAAAA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eTransactionTestOutput() (output []TransactionOutput, err error) { TimeBounds: "[0,1594272628)", Successful: true, InnerTransactionHash: "a87fef5eeb260269c380f2de456aad72b59bb315aaac777860456e09dac0bafb", - FeeAccount: testAccount3Address, + FeeAccount: testAccount5Address, + FeeAccountMuxed: "MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFNZG", NewMaxFee: 7200, ClosedAt: time.Date(2020, time.July, 9, 5, 28, 42, 0, time.UTC), ResourceFee: 0, @@ -251,7 +252,7 @@ func makeTransactionTestInput() (transaction []ingest.LedgerTransaction, history Type: xdr.EnvelopeTypeEnvelopeTypeTxFeeBump, FeeBump: &xdr.FeeBumpTransactionEnvelope{ Tx: xdr.FeeBumpTransaction{ - FeeSource: testAccount3, + FeeSource: testAccount5, Fee: 7200, InnerTx: xdr.FeeBumpTransactionInnerTx{ Type: xdr.EnvelopeTypeEnvelopeTypeTx,