Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relayer: remove UpdateMetaTxnGasLimits #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
31 changes: 20 additions & 11 deletions relayer/proto/relayer.gen.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// sequence-relayer v0.4.0 59a862f763edcaca2fb2e11901b24873c4c02034
// sequence-relayer v0.4.0 e870aab3d2d1c607ee9142f897e79e8e659b4348
// --
// This file has been generated by https://github.com/webrpc/webrpc using gen/golang
// Do not edit by hand. Update your webrpc schema and re-generate.
Expand Down Expand Up @@ -31,7 +31,7 @@ func WebRPCSchemaVersion() string {

// Schema hash generated from your RIDL schema
func WebRPCSchemaHash() string {
return "59a862f763edcaca2fb2e11901b24873c4c02034"
return "e870aab3d2d1c607ee9142f897e79e8e659b4348"
}

//
Expand Down Expand Up @@ -280,6 +280,7 @@ type MetaTxnLog struct {
MetaTxnID *string `json:"metaTxnID" db:"meta_txn_id"`
TxnStatus ETHTxnStatus `json:"txnStatus" db:"txn_status"`
TxnRevertReason string `json:"txnRevertReason" db:"txn_revert_reason"`
Requeues uint `json:"requeues" db:"requeues"`
Target prototyp.Hash `json:"target" db:"target"`
Input prototyp.Hash `json:"input" db:"input"`
TxnArgs map[string]interface{} `json:"txnArgs" db:"txn_args"`
Expand Down Expand Up @@ -348,6 +349,15 @@ type SentTransactionsFilter struct {
Failed *bool `json:"failed"`
}

type SimulateResult struct {
Executed bool `json:"executed"`
Succeeded bool `json:"succeeded"`
Result *string `json:"result"`
Reason *string `json:"reason"`
GasUsed uint `json:"gasUsed"`
GasLimit uint `json:"gasLimit"`
}

type FeeOption struct {
Token *FeeToken `json:"token"`
To string `json:"to"`
Expand Down Expand Up @@ -391,7 +401,7 @@ type Relayer interface {
SendMetaTxn(ctx context.Context, call *MetaTxn) (bool, string, error)
GetMetaTxnNonce(ctx context.Context, walletContractAddress string, space *string) (string, error)
GetMetaTxnReceipt(ctx context.Context, metaTxID string) (*MetaTxnReceipt, error)
UpdateMetaTxnGasLimits(ctx context.Context, walletAddress string, walletConfig *WalletConfig, payload string) (string, error)
Simulate(ctx context.Context, wallet string, transactions string) ([]*SimulateResult, error)
FeeTokens(ctx context.Context) (bool, []*FeeToken, error)
GetMetaTxnNetworkFeeOptions(ctx context.Context, walletConfig *WalletConfig, payload string) ([]*FeeOption, error)
SentTransactions(ctx context.Context, filter *SentTransactionsFilter, page *Page) (*Page, []*Transaction, error)
Expand All @@ -408,7 +418,7 @@ var WebRPCServices = map[string][]string{
"SendMetaTxn",
"GetMetaTxnNonce",
"GetMetaTxnReceipt",
"UpdateMetaTxnGasLimits",
"Simulate",
"FeeTokens",
"GetMetaTxnNetworkFeeOptions",
"SentTransactions",
Expand Down Expand Up @@ -438,7 +448,7 @@ func NewRelayerClient(addr string, client HTTPClient) Relayer {
prefix + "SendMetaTxn",
prefix + "GetMetaTxnNonce",
prefix + "GetMetaTxnReceipt",
prefix + "UpdateMetaTxnGasLimits",
prefix + "Simulate",
prefix + "FeeTokens",
prefix + "GetMetaTxnNetworkFeeOptions",
prefix + "SentTransactions",
Expand Down Expand Up @@ -533,14 +543,13 @@ func (c *relayerClient) GetMetaTxnReceipt(ctx context.Context, metaTxID string)
return out.Ret0, err
}

func (c *relayerClient) UpdateMetaTxnGasLimits(ctx context.Context, walletAddress string, walletConfig *WalletConfig, payload string) (string, error) {
func (c *relayerClient) Simulate(ctx context.Context, wallet string, transactions string) ([]*SimulateResult, error) {
in := struct {
Arg0 string `json:"walletAddress"`
Arg1 *WalletConfig `json:"walletConfig"`
Arg2 string `json:"payload"`
}{walletAddress, walletConfig, payload}
Arg0 string `json:"wallet"`
Arg1 string `json:"transactions"`
}{wallet, transactions}
out := struct {
Ret0 string `json:"payload"`
Ret0 []*SimulateResult `json:"results"`
}{}

err := doJSONRequest(ctx, c.client, c.urls[8], in, &out)
Expand Down
15 changes: 5 additions & 10 deletions relayer/rpc_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,17 @@ func (r *RpcRelayer) EstimateGasLimits(ctx context.Context, walletConfig sequenc
return nil, err
}

config, err := r.protoConfig(ctx, &walletConfig, walletAddress)
response, err := r.Service.Simulate(ctx, walletAddress.Hex(), hexutil.Encode(requestData))
if err != nil {
return nil, err
}

response, err := r.Service.UpdateMetaTxnGasLimits(ctx, walletAddress.Hex(), config, hexutil.Encode(requestData))
if err != nil {
return nil, err
}

responseData, err := hexutil.Decode(response)
if err != nil {
return nil, err
txns = txns.Clone()
for i, txn := range txns {
txn.GasLimit = big.NewInt(int64(response[i].GasLimit))
}

return sequence.DecodeRawTransactions(responseData)
return txns, nil
}

// NOTE: nonce space is 160 bits wide
Expand Down