99
1010 "github.com/ethereum/go-ethereum/common"
1111 "github.com/ethereum/go-ethereum/common/hexutil"
12- ethTypes "github.com/ethereum/go-ethereum/core/types"
1312 "github.com/ethereum/go-ethereum/rpc"
1413)
1514
@@ -69,12 +68,12 @@ func (p PendingTxInputList) IsPendingTxInput(txInput []byte, pendingTxWaitDurati
6968
7069func (s * peggyContract ) SubscribeToPendingTxs (alchemyWebsocketURL string ) {
7170 args := map [string ]interface {}{
72- "address " : s .peggyAddress .Hex (),
71+ "toAddress " : s .peggyAddress .Hex (),
7372 }
7473
7574 wsClient , err := rpc .Dial (alchemyWebsocketURL )
7675 if err != nil {
77- log .WithField ("Websocket endpoint" , alchemyWebsocketURL ).WithError (err ).Fatalln ("Failed to connect to Ethereum Alchemy websocket" )
76+ log .WithField ("Websocket endpoint" , alchemyWebsocketURL ).WithError (err ).Warningln ("Failed to connect to Ethereum Alchemy websocket" )
7877 return
7978 }
8079
@@ -83,38 +82,35 @@ func (s *peggyContract) SubscribeToPendingTxs(alchemyWebsocketURL string) {
8382
8483 // Subscribe to Transactions
8584 ch := make (chan * RPCTransaction )
86- _ , err = wsClient .EthSubscribe (ctx , ch , "alchemy_filteredNewFullPendingTransactions " , args )
85+ _ , err = wsClient .EthSubscribe (ctx , ch , "alchemy_pendingTransactions " , args )
8786 if err != nil {
88- log .WithField ("Subscription error" , alchemyWebsocketURL ).WithError (err ).Fatalln ("Failed to subscribe to pending transactions" )
87+ log .WithField ("Subscription error" , alchemyWebsocketURL ).WithError (err ).Warningln ("Failed to subscribe to pending transactions" )
8988 return
9089 }
9190
9291 for {
9392 // Check that the transaction was send over the channel
9493 pendingTransaction := <- ch
94+ log .WithField ("hash" , pendingTransaction .Hash ).Infoln ("received pending transaction" )
9595 s .pendingTxInputList .AddPendingTxInput (pendingTransaction )
9696 }
9797}
9898
9999// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
100100type RPCTransaction struct {
101- BlockHash * common.Hash `json:"blockHash"`
102- BlockNumber * hexutil.Big `json:"blockNumber"`
103- From common.Address `json:"from"`
104- Gas hexutil.Uint64 `json:"gas"`
105- GasPrice * hexutil.Big `json:"gasPrice"`
106- GasFeeCap * hexutil.Big `json:"maxFeePerGas,omitempty"`
107- GasTipCap * hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
108- Hash common.Hash `json:"hash"`
109- Input hexutil.Bytes `json:"input"`
110- Nonce hexutil.Uint64 `json:"nonce"`
111- To * common.Address `json:"to"`
112- TransactionIndex * hexutil.Uint64 `json:"transactionIndex"`
113- Value * hexutil.Big `json:"value"`
114- Type hexutil.Uint64 `json:"type"`
115- Accesses * ethTypes.AccessList `json:"accessList,omitempty"`
116- ChainID * hexutil.Big `json:"chainId,omitempty"`
117- V * hexutil.Big `json:"v"`
118- R * hexutil.Big `json:"r"`
119- S * hexutil.Big `json:"s"`
101+ BlockHash * common.Hash `json:"blockHash"`
102+ BlockNumber * hexutil.Big `json:"blockNumber"`
103+ From common.Address `json:"from"`
104+ Gas hexutil.Uint64 `json:"gas"`
105+ GasPrice * hexutil.Big `json:"gasPrice"`
106+ Hash common.Hash `json:"hash"`
107+ Input hexutil.Bytes `json:"input"`
108+ Nonce hexutil.Uint64 `json:"nonce"`
109+ To * common.Address `json:"to"`
110+ TransactionIndex * hexutil.Uint64 `json:"transactionIndex"`
111+ Value * hexutil.Big `json:"value"`
112+ Type hexutil.Uint64 `json:"type"`
113+ V * hexutil.Big `json:"v"`
114+ R * hexutil.Big `json:"r"`
115+ S * hexutil.Big `json:"s"`
120116}
0 commit comments