Skip to content

Commit

Permalink
Merge branch 'b/testnet' into b/master
Browse files Browse the repository at this point in the history
  • Loading branch information
romever committed Nov 26, 2024
2 parents 26debf6 + 2e610b4 commit 58a5f90
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions api/internal/logic/runtime/runtimetransactioninfologic.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package runtime

import (
"context"
"encoding/hex"
"encoding/json"
"errors"
"github.com/ethereum/go-ethereum/common/hexutil"
eth_types "github.com/ethereum/go-ethereum/core/types"
"github.com/oasisprotocol/oasis-core/go/common/cbor"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/client"
sdkClient "github.com/oasisprotocol/oasis-sdk/client-sdk/go/client"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/modules/accounts"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/modules/consensusaccounts"
Expand Down Expand Up @@ -65,7 +65,7 @@ func (l *RuntimeTransactionInfoLogic) RuntimeTransactionInfo(req *types.RuntimeT

var consensusTx *types.RuntimeTransactionConsensusTx = nil
var evmTx *types.RuntimeTransactionEvmTx = nil
txr := new(client.TransactionWithResults)
txr := new(sdkClient.TransactionWithResults)
if err := json.Unmarshal([]byte(txModel.Raw), txr); err != nil {
logc.Errorf(l.ctx, "transaction json unmarshal error, %v", err)
return nil, errort.NewDefaultError()
Expand Down Expand Up @@ -108,6 +108,26 @@ func (l *RuntimeTransactionInfoLogic) RuntimeTransactionInfo(req *types.RuntimeT
Amount: amountFloat.String(),
Nonce: int64(sdkTx.AuthInfo.SignerInfo[0].Nonce),
}

if txModel.Method == "consensus.Withdraw" {
for _, si := range sdkTx.AuthInfo.SignerInfo {
var (
data []byte
ethAddr string
)
spec := si.AddressSpec.Signature
if spec.Secp256k1Eth != nil {
untaggedPk, _ := si.AddressSpec.Signature.Secp256k1Eth.MarshalBinaryUncompressedUntagged()
data = common.SliceEthAddress(common.Keccak256(untaggedPk))
ethAddr = hex.EncodeToString(data)
if !strings.HasPrefix(ethAddr, "0x") {
ethAddr = "0x" + ethAddr
}
consensusTx.From = ethAddr
break
}
}
}
}

//events
Expand Down

0 comments on commit 58a5f90

Please sign in to comment.