Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 51 additions & 7 deletions pkg/txm/clientwrappers/dualbroadcast/meta_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ type MetaClient struct {

func NewMetaClient(lggr logger.Logger, c MetaClientRPC, ks MetaClientKeystore, customURL *url.URL, chainID *big.Int) *MetaClient {
return &MetaClient{
lggr: logger.Sugared(logger.Named(lggr, "MetaClient")),
lggr: logger.Sugared(logger.Named(lggr, "Txm.Txm.MetaClient")),
c: c,
ks: ks,
customURL: customURL,
Expand All @@ -159,7 +159,7 @@ func (a *MetaClient) SendTransaction(ctx context.Context, tx *types.Transaction,
}

if meta != nil && meta.DualBroadcast != nil && *meta.DualBroadcast && !tx.IsPurgeable && meta.DualBroadcastParams != nil && meta.FwdrDestAddress != nil {
meta, err := a.SendRequest(ctx, tx, attempt, *meta.DualBroadcastParams, *meta.FwdrDestAddress)
meta, err := a.SendRequest(ctx, tx, attempt, *meta.DualBroadcastParams, tx.ToAddress)
if err != nil {
return fmt.Errorf("error sending request for transactionID(%d): %w", tx.ID, err)
}
Expand All @@ -172,6 +172,7 @@ func (a *MetaClient) SendTransaction(ctx context.Context, tx *types.Transaction,
a.lggr.Info("No bids for transactionID(%d): ", tx.ID)
return nil
}
a.lggr.Infow("Broadcasting attempt to public mempool", "tx", tx)
return a.c.SendTransaction(ctx, attempt.SignedTransaction)
}

Expand All @@ -193,6 +194,9 @@ type RequestResponse struct {
}

type ResponseResult struct {
UO *UORaw `json:"userOperation"`
SOS []*SO `json:"solverOperations"`
DO *DO `json:"dAppOperation"`
MetacalldataResponse
}

Expand All @@ -211,15 +215,49 @@ type UO struct {
Data []byte
}

type UORaw struct {
From common.Address `json:"from"`
To common.Address `json:"to"`
Value *hexutil.Big `json:"value"`
Gas *hexutil.Big `json:"gas"`
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
Nonce *hexutil.Big `json:"nonce"`
Deadline *hexutil.Big `json:"deadline"`
Dapp common.Address `json:"dapp"`
Control common.Address `json:"control"`
CallConfig *hexutil.Big `json:"callConfig"`
DappGasLimit *hexutil.Big `json:"dappGasLimit,omitempty"`
SessionKey common.Address `json:"sessionKey"`
Data hexutil.Bytes `json:"data"`
Signature hexutil.Bytes `json:"signature"`
}

type SO struct {
To common.Address
Control common.Address
From common.Address `json:"from"`
To common.Address `json:"to"`
Value *hexutil.Big `json:"value"`
Gas *hexutil.Big `json:"gas"`
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
Deadline *hexutil.Big `json:"deadline"`
Solver common.Address `json:"solver"`
Control common.Address `json:"control"`
UserOpHash common.Hash `json:"userOpHash"`
BidToken common.Address `json:"bidToken"`
BidAmount *hexutil.Big `json:"bidAmount"`
Data hexutil.Bytes `json:"data"`
Signature hexutil.Bytes `json:"signature"`
}

type DO struct {
To common.Address
Control common.Address
Bundler common.Address
From common.Address `json:"from"`
To common.Address `json:"to"`
Nonce *hexutil.Big `json:"nonce"`
Deadline *hexutil.Big `json:"deadline"`
Control common.Address `json:"control"`
Bundler common.Address `json:"bundler"`
UserOpHash common.Hash `json:"userOpHash"`
CallChainHash common.Hash `json:"callChainHash"`
Signature hexutil.Bytes `json:"signature"`
}

type Metacalldata struct {
Expand Down Expand Up @@ -309,6 +347,12 @@ func (a *MetaClient) SendRequest(parentCtx context.Context, tx *types.Transactio
return nil, nil
}

r, err := json.MarshalIndent(response.Result, "", " ")
if err != nil {
return nil, err
}
a.lggr.Info("Response: ", string(r))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add some tests to ensure the serialization works as expected

return VerifyResponse(response.Result.MetacalldataResponse, dualBroadcastParams, tx.Data, tx.FromAddress, fwdrDestAddress)
}

Expand Down
Loading