diff --git a/relayer/proto/relayer.gen.go b/relayer/proto/relayer.gen.go index 06a88147..9a75ab49 100644 --- a/relayer/proto/relayer.gen.go +++ b/relayer/proto/relayer.gen.go @@ -1,4 +1,4 @@ -// sequence-relayer v0.4.1 7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f +// sequence-relayer v0.4.1 381aab1c8d53149311790b7f6631af093819aeec // -- // Code generated by webrpc-gen@v0.31.2 with golang generator. DO NOT EDIT. // @@ -35,7 +35,7 @@ func WebRPCSchemaVersion() string { // Schema hash generated from your RIDL schema func WebRPCSchemaHash() string { - return "7f8a4b83b00e0b6849c76c2ff0e23931e26b3d9f" + return "381aab1c8d53149311790b7f6631af093819aeec" } // @@ -71,6 +71,12 @@ type RelayerClient interface { FeeOptions(ctx context.Context, wallet string, to string, data string, simulate *bool) ([]*FeeOption, bool, *string, error) // TODO: deprecated, to be removed by https://github.com/0xsequence/stack/pull/356 at a later date GetMetaTxnNetworkFeeOptions(ctx context.Context, walletConfig interface{}, payload string) ([]*FeeOption, error) + // + // Sender administration + // + StartSender(ctx context.Context, sender int) error + StopSender(ctx context.Context, sender int) error + ResetSender(ctx context.Context, sender int) (uint64, error) GetMetaTransactions(ctx context.Context, projectId uint64, page *Page) (*Page, []*MetaTxnLog, error) GetTransactionCost(ctx context.Context, projectId uint64, from time.Time, to time.Time) (float64, error) // Sent transactions from an account. If filter is omitted then it will return all transactions. @@ -122,6 +128,8 @@ const ( ETHTxnStatus_FAILED ETHTxnStatus = 6 // txn accepted by relayer, waiting for preconditions to be satisfied ETHTxnStatus_PENDING_PRECONDITION ETHTxnStatus = 7 + // waiting for receipt + ETHTxnStatus_MINED ETHTxnStatus = 8 ) var ETHTxnStatus_name = map[uint]string{ @@ -133,6 +141,7 @@ var ETHTxnStatus_name = map[uint]string{ 5: "PARTIALLY_FAILED", 6: "FAILED", 7: "PENDING_PRECONDITION", + 8: "MINED", } var ETHTxnStatus_value = map[string]uint{ @@ -144,6 +153,7 @@ var ETHTxnStatus_value = map[string]uint{ "PARTIALLY_FAILED": 5, "FAILED": 6, "PENDING_PRECONDITION": 7, + "MINED": 8, } func (x ETHTxnStatus) String() string { @@ -324,37 +334,23 @@ func (x *FeeTokenType) Is(values ...FeeTokenType) bool { return false } -type SortOrder uint32 +type Order string const ( - SortOrder_DESC SortOrder = 0 - SortOrder_ASC SortOrder = 1 + Order_DESC Order = "DESC" + Order_ASC Order = "ASC" ) -var SortOrder_name = map[uint32]string{ - 0: "DESC", - 1: "ASC", -} - -var SortOrder_value = map[string]uint32{ - "DESC": 0, - "ASC": 1, -} - -func (x SortOrder) String() string { - return SortOrder_name[uint32(x)] +func (x Order) MarshalText() ([]byte, error) { + return []byte(x), nil } -func (x SortOrder) MarshalText() ([]byte, error) { - return []byte(SortOrder_name[uint32(x)]), nil -} - -func (x *SortOrder) UnmarshalText(b []byte) error { - *x = SortOrder(SortOrder_value[string(b)]) +func (x *Order) UnmarshalText(b []byte) error { + *x = Order(string(b)) return nil } -func (x *SortOrder) Is(values ...SortOrder) bool { +func (x *Order) Is(values ...Order) bool { if x == nil { return false } @@ -391,6 +387,7 @@ type SenderStatus struct { Index uint32 `json:"index"` Address string `json:"address"` EtherBalance float64 `json:"etherBalance"` + Enabled bool `json:"enabled"` Active bool `json:"active"` } @@ -482,7 +479,7 @@ type MetaTxnLog struct { Input prototyp.Hash `json:"input" db:"input"` // TODO: review this field.. we may not want it.. what goes in here..? is it just // the input/target from MetaTxn above? we already have these as separate columns.. - TxnArgs map[string]interface{} `json:"txnArgs" db:"txn_args"` + TxnArgs TxnArgs `json:"txnArgs" db:"txn_args"` TxnReceipt map[string]interface{} `json:"txnReceipt" db:"txn_receipt,omitempty"` WalletAddress prototyp.Hash `json:"walletAddress" db:"wallet_address"` MetaTxnNonce prototyp.BigInt `json:"metaTxnNonce" db:"metatx_nonce"` @@ -601,26 +598,16 @@ type FeeToken struct { // Page represents a results page. This can be used both to request a page and // to store the state of a page. type Page struct { - // Common for both numbered pages and cursor: Number of items per page - PageSize *uint32 `json:"pageSize"` - // Numbered pages: Page number, this is multiplied by the value of the parameter. - Page *uint32 `json:"page"` - More *bool `json:"more"` - // Number of total items on this query. - TotalRecords *uint64 `json:"total_records,omitempty"` - // Cursor: column to compare before/after to - Column *string `json:"column,omitempty"` - // Cursor: return column < before - include to get previous page - Before *interface{} `json:"before,omitempty"` - // Cursor: return column > after - include to get next page - After *interface{} `json:"after,omitempty"` - // Sorting filter - Sort []*SortBy `json:"sort,omitempty"` -} - -type SortBy struct { - Column string `json:"column"` - Order SortOrder `json:"order"` + PageSize uint32 `json:"pageSize"` + Page uint32 `json:"page"` + More bool `json:"more"` + Column string `json:"column"` + Sort []*Sort `json:"sort"` +} + +type Sort struct { + Column string `json:"column"` + Order Order `json:"order"` } // @@ -631,12 +618,12 @@ const RelayerPathPrefix = "/rpc/Relayer/" type relayerClient struct { client HTTPClient - urls [33]string + urls [36]string } func NewRelayerClient(addr string, client HTTPClient) RelayerClient { prefix := urlBase(addr) + RelayerPathPrefix - urls := [33]string{ + urls := [36]string{ prefix + "Ping", prefix + "Version", prefix + "RuntimeStatus", @@ -651,6 +638,9 @@ func NewRelayerClient(addr string, client HTTPClient) RelayerClient { prefix + "FeeTokens", prefix + "FeeOptions", prefix + "GetMetaTxnNetworkFeeOptions", + prefix + "StartSender", + prefix + "StopSender", + prefix + "ResetSender", prefix + "GetMetaTransactions", prefix + "GetTransactionCost", prefix + "SentTransactions", @@ -942,6 +932,57 @@ func (c *relayerClient) GetMetaTxnNetworkFeeOptions(ctx context.Context, walletC return out.Ret0, err } +func (c *relayerClient) StartSender(ctx context.Context, sender int) error { + in := struct { + Arg0 int `json:"sender"` + }{sender} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[14], in, nil) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return err +} + +func (c *relayerClient) StopSender(ctx context.Context, sender int) error { + in := struct { + Arg0 int `json:"sender"` + }{sender} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[15], in, nil) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return err +} + +func (c *relayerClient) ResetSender(ctx context.Context, sender int) (uint64, error) { + in := struct { + Arg0 int `json:"sender"` + }{sender} + out := struct { + Ret0 uint64 `json:"deleted"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[16], in, &out) + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCausef("failed to close response body: %w", cerr) + } + } + + return out.Ret0, err +} + func (c *relayerClient) GetMetaTransactions(ctx context.Context, projectId uint64, page *Page) (*Page, []*MetaTxnLog, error) { in := struct { Arg0 uint64 `json:"projectId"` @@ -952,7 +993,7 @@ func (c *relayerClient) GetMetaTransactions(ctx context.Context, projectId uint6 Ret1 []*MetaTxnLog `json:"transactions"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[14], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[17], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -973,7 +1014,7 @@ func (c *relayerClient) GetTransactionCost(ctx context.Context, projectId uint64 Ret0 float64 `json:"cost"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[15], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[18], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -994,7 +1035,7 @@ func (c *relayerClient) SentTransactions(ctx context.Context, filter *SentTransa Ret1 []*Transaction `json:"transactions"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[16], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[19], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1014,7 +1055,7 @@ func (c *relayerClient) PendingTransactions(ctx context.Context, page *Page) (*P Ret1 []*Transaction `json:"transactions"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[17], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[20], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1033,7 +1074,7 @@ func (c *relayerClient) GetGasTank(ctx context.Context, id uint64) (*GasTank, er Ret0 *GasTank `json:"gasTank"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[18], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[21], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1055,7 +1096,7 @@ func (c *relayerClient) AddGasTank(ctx context.Context, name string, feeMarkupFa Ret1 *GasTank `json:"gasTank"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[19], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[22], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1078,7 +1119,7 @@ func (c *relayerClient) UpdateGasTank(ctx context.Context, id uint64, name *stri Ret1 *GasTank `json:"gasTank"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[20], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[23], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1097,7 +1138,7 @@ func (c *relayerClient) NextGasTankBalanceAdjustmentNonce(ctx context.Context, i Ret0 uint64 `json:"nonce"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[21], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[24], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1119,7 +1160,7 @@ func (c *relayerClient) AdjustGasTankBalance(ctx context.Context, id uint64, non Ret1 *GasTankBalanceAdjustment `json:"adjustment"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[22], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[25], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1139,7 +1180,7 @@ func (c *relayerClient) GetGasTankBalanceAdjustment(ctx context.Context, id uint Ret0 *GasTankBalanceAdjustment `json:"adjustment"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[23], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[26], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1160,7 +1201,7 @@ func (c *relayerClient) ListGasTankBalanceAdjustments(ctx context.Context, id ui Ret1 []*GasTankBalanceAdjustment `json:"adjustments"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[24], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[27], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1181,7 +1222,7 @@ func (c *relayerClient) ListGasSponsors(ctx context.Context, projectId uint64, p Ret1 []*GasSponsor `json:"gasSponsors"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[25], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[28], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1201,7 +1242,7 @@ func (c *relayerClient) GetGasSponsor(ctx context.Context, projectId uint64, id Ret0 *GasSponsor `json:"gasSponsor"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[26], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[29], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1224,7 +1265,7 @@ func (c *relayerClient) AddGasSponsor(ctx context.Context, projectId uint64, add Ret1 *GasSponsor `json:"gasSponsor"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[27], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[30], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1247,7 +1288,7 @@ func (c *relayerClient) UpdateGasSponsor(ctx context.Context, projectId uint64, Ret1 *GasSponsor `json:"gasSponsor"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[28], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[31], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1267,7 +1308,7 @@ func (c *relayerClient) RemoveGasSponsor(ctx context.Context, projectId uint64, Ret0 bool `json:"status"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[29], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[32], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1288,7 +1329,7 @@ func (c *relayerClient) AddressGasSponsors(ctx context.Context, address string, Ret1 []*GasSponsor `json:"gasSponsors"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[30], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[33], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1307,7 +1348,7 @@ func (c *relayerClient) GetProjectBalance(ctx context.Context, projectId uint64) Ret0 float64 `json:"balance"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[31], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[34], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1328,7 +1369,7 @@ func (c *relayerClient) AdjustProjectBalance(ctx context.Context, projectId uint Ret0 float64 `json:"balance"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[32], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[35], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil {