Skip to content

Commit

Permalink
feat(plugin): publish TX sender addresses
Browse files Browse the repository at this point in the history
This will simplify linking transactions to accounts in the indexer.
  • Loading branch information
Thomasvdam committed Apr 11, 2024
1 parent fd14b10 commit ac2332f
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions plugins/indexing/base/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto/tmhash"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
txtype "github.com/cosmos/cosmos-sdk/types/tx"

types "github.com/sedaprotocol/seda-chain/plugins/indexing/types"
Expand Down Expand Up @@ -37,16 +38,32 @@ func ExtractTransactionUpdates(ctx *types.BlockContext, cdc codec.Codec, req abc
return nil, err
}

signersBytes, _, err := tx.GetSigners(cdc)
if err != nil {
return nil, err
}

signers := make([]string, 0, len(signersBytes))
for _, signerBytes := range signersBytes {
var signer sdk.AccAddress
if err := signer.Unmarshal(signerBytes); err != nil {
return nil, err
}
signers = append(signers, signer.String())
}

data := struct {
Hash string `json:"hash"`
Time time.Time `json:"time"`
Tx *wrappedTx `json:"tx"`
Result *abci.ExecTxResult `json:"result"`
Hash string `json:"hash"`
Time time.Time `json:"time"`
Tx *wrappedTx `json:"tx"`
Signers []string `json:"signers"`
Result *abci.ExecTxResult `json:"result"`
}{
Hash: txHash,
Time: timestamp,
Tx: &wrappedTx{cdc: cdc, Tx: &tx},
Result: txResult,
Hash: txHash,
Time: timestamp,
Tx: &wrappedTx{cdc: cdc, Tx: &tx},
Signers: signers,
Result: txResult,
}

messages = append(messages, types.NewMessage("tx", data, ctx))
Expand Down

0 comments on commit ac2332f

Please sign in to comment.