Skip to content

Commit

Permalink
fix transaction reading
Browse files Browse the repository at this point in the history
  • Loading branch information
yerke26 committed Jan 20, 2025
1 parent 4fd1761 commit cb28a1f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions tools/Evm/Evm/T8n/JsonTypes/InputData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ public Transaction[] GetTransactions(TxDecoder decoder, ulong chainId)
for (int i = 0; i < Txs.Length; i++)
{
var transaction = Txs[i].ToTransaction();
transaction.SenderAddress = null; // t8n does not accept SenderAddress from input, so need to reset senderAddress
SignTransaction(transaction, TransactionMetaDataList[i], (LegacyTransactionForRpc) Txs[i]);
transaction.SenderAddress = Txs[i] is LegacyTransactionForRpc ? ((LegacyTransactionForRpc)Txs[i]).From : null;
if (transaction.SenderAddress is null)
{
SignTransaction(transaction, TransactionMetaDataList[i], (LegacyTransactionForRpc) Txs[i]);
}

transactions.Add(transaction);
}
Expand Down
2 changes: 2 additions & 0 deletions tools/Evm/Evm/T8n/JsonTypes/TransactionMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
namespace Evm.T8n.JsonTypes;

public readonly record struct TransactionMetaData(bool? Protected, byte[]? SecretKey);

public readonly record struct TransactionMetaDataWrapper(TransactionMetaData[]? Txs);
6 changes: 5 additions & 1 deletion tools/Evm/Evm/T8n/T8nInputReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ private static InputData ReadStdInput()
using var reader = new StreamReader(Console.OpenStandardInput());
try
{
return EthereumJsonSerializer.Deserialize<InputData>(reader.ReadToEnd());
var jsonText = reader.ReadToEnd();
TransactionMetaDataWrapper txsMetaDataWrapper = EthereumJsonSerializer.Deserialize<TransactionMetaDataWrapper>(jsonText);
InputData inputData = EthereumJsonSerializer.Deserialize<InputData>(jsonText);
inputData.TransactionMetaDataList = txsMetaDataWrapper.Txs;
return inputData;
}
catch (Exception e)
{
Expand Down

0 comments on commit cb28a1f

Please sign in to comment.