diff --git a/relayer/proto/relayer.gen.go b/relayer/proto/relayer.gen.go index 06a88147..5db6d1c7 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 3af6da1dad525c89afca98ae34bfb818103556a4 // -- // 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 "3af6da1dad525c89afca98ae34bfb818103556a4" } // @@ -69,8 +69,19 @@ type RelayerClient interface { UpdateMetaTxnGasLimits(ctx context.Context, walletAddress string, walletConfig interface{}, payload string) (string, error) FeeTokens(ctx context.Context) (bool, []*FeeToken, string, error) FeeOptions(ctx context.Context, wallet string, to string, data string, simulate *bool) ([]*FeeOption, bool, *string, error) + // Bridge gas endpoints for S2S calls + // Used for bridge fees (e.g., LayerZero messaging fees) that require msg.value to be fronted at runtime. + // bridgeGas will be included in fee calculation so the relayer gets reimbursed. + SendMetaTxnWithBridgeGas(ctx context.Context, call *MetaTxn, quote *string, projectID *uint64, bridgeGas string, preconditions []*TransactionPrecondition) (bool, string, error) + FeeOptionsWithBridgeGas(ctx context.Context, wallet string, to string, data string, simulate *bool, bridgeGas string) ([]*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 +133,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 +146,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 +158,7 @@ var ETHTxnStatus_value = map[string]uint{ "PARTIALLY_FAILED": 5, "FAILED": 6, "PENDING_PRECONDITION": 7, + "MINED": 8, } func (x ETHTxnStatus) String() string { @@ -324,37 +339,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 SortOrder) MarshalText() ([]byte, error) { - return []byte(SortOrder_name[uint32(x)]), nil +func (x Order) MarshalText() ([]byte, error) { + return []byte(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 +392,7 @@ type SenderStatus struct { Index uint32 `json:"index"` Address string `json:"address"` EtherBalance float64 `json:"etherBalance"` + Enabled bool `json:"enabled"` Active bool `json:"active"` } @@ -450,8 +452,7 @@ type GasSponsorUsage struct { EndTime *time.Time `json:"endTime"` } -// TODO: rename this to MetaTxnRaw (eventually), we can leave it for now to not break compat -// or name it, MetaTxnArgs ..? +// TODO: rename fields eventually (contract -> to, input -> execdata), rename struct to MetaTxnRaw type MetaTxn struct { WalletAddress string `json:"walletAddress" db:"wallet_address"` // TODO (later): rename this to `to: string` @@ -480,9 +481,12 @@ type MetaTxnLog struct { MinedAt *time.Time `json:"minedAt" db:"mined_at,omitempty"` Target prototyp.Hash `json:"target" db:"target"` Input prototyp.Hash `json:"input" db:"input"` + // Bridge gas (in wei) to be fronted at runtime with the transaction. + // Used for bridge fees (e.g., LayerZero messaging fees) that require msg.value. + BridgeGas *prototyp.BigInt `json:"bridgeGas" db:"bridge_gas"` // 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 +605,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 +625,12 @@ const RelayerPathPrefix = "/rpc/Relayer/" type relayerClient struct { client HTTPClient - urls [33]string + urls [38]string } func NewRelayerClient(addr string, client HTTPClient) RelayerClient { prefix := urlBase(addr) + RelayerPathPrefix - urls := [33]string{ + urls := [38]string{ prefix + "Ping", prefix + "Version", prefix + "RuntimeStatus", @@ -650,7 +644,12 @@ func NewRelayerClient(addr string, client HTTPClient) RelayerClient { prefix + "UpdateMetaTxnGasLimits", prefix + "FeeTokens", prefix + "FeeOptions", + prefix + "SendMetaTxnWithBridgeGas", + prefix + "FeeOptionsWithBridgeGas", prefix + "GetMetaTxnNetworkFeeOptions", + prefix + "StartSender", + prefix + "StopSender", + prefix + "ResetSender", prefix + "GetMetaTransactions", prefix + "GetTransactionCost", prefix + "SentTransactions", @@ -922,6 +921,55 @@ func (c *relayerClient) FeeOptions(ctx context.Context, wallet string, to string return out.Ret0, out.Ret1, out.Ret2, err } +func (c *relayerClient) SendMetaTxnWithBridgeGas(ctx context.Context, call *MetaTxn, quote *string, projectID *uint64, bridgeGas string, preconditions []*TransactionPrecondition) (bool, string, error) { + in := struct { + Arg0 *MetaTxn `json:"call"` + Arg1 *string `json:"quote"` + Arg2 *uint64 `json:"projectID"` + Arg3 string `json:"bridgeGas"` + Arg4 []*TransactionPrecondition `json:"preconditions"` + }{call, quote, projectID, bridgeGas, preconditions} + out := struct { + Ret0 bool `json:"status"` + Ret1 string `json:"txnHash"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[13], 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, out.Ret1, err +} + +func (c *relayerClient) FeeOptionsWithBridgeGas(ctx context.Context, wallet string, to string, data string, simulate *bool, bridgeGas string) ([]*FeeOption, bool, *string, error) { + in := struct { + Arg0 string `json:"wallet"` + Arg1 string `json:"to"` + Arg2 string `json:"data"` + Arg3 *bool `json:"simulate"` + Arg4 string `json:"bridgeGas"` + }{wallet, to, data, simulate, bridgeGas} + out := struct { + Ret0 []*FeeOption `json:"options"` + Ret1 bool `json:"sponsored"` + Ret2 *string `json:"quote"` + }{} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[14], 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, out.Ret1, out.Ret2, err +} + func (c *relayerClient) GetMetaTxnNetworkFeeOptions(ctx context.Context, walletConfig interface{}, payload string) ([]*FeeOption, error) { in := struct { Arg0 interface{} `json:"walletConfig"` @@ -931,7 +979,58 @@ func (c *relayerClient) GetMetaTxnNetworkFeeOptions(ctx context.Context, walletC Ret0 []*FeeOption `json:"options"` }{} - resp, err := doHTTPRequest(ctx, c.client, c.urls[13], in, &out) + resp, err := doHTTPRequest(ctx, c.client, c.urls[15], 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) StartSender(ctx context.Context, sender int) error { + in := struct { + Arg0 int `json:"sender"` + }{sender} + + resp, err := doHTTPRequest(ctx, c.client, c.urls[16], 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[17], 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[18], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -952,7 +1051,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[19], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -973,7 +1072,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[20], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -994,7 +1093,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[21], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1014,7 +1113,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[22], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1033,7 +1132,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[23], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1055,7 +1154,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[24], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1078,7 +1177,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[25], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1097,7 +1196,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[26], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1119,7 +1218,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[27], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1139,7 +1238,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[28], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1160,7 +1259,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[29], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1181,7 +1280,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[30], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1201,7 +1300,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[31], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1224,7 +1323,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[32], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1247,7 +1346,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[33], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1267,7 +1366,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[34], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1288,7 +1387,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[35], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1307,7 +1406,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[36], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1328,7 +1427,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[37], in, &out) if resp != nil { cerr := resp.Body.Close() if err == nil && cerr != nil { @@ -1705,10 +1804,11 @@ var ( ErrRateLimited = WebRPCError{Code: 1007, Name: "RateLimited", Message: "Rate-limited. Please slow down.", HTTPStatus: 429} ErrProjectNotFound = WebRPCError{Code: 1008, Name: "ProjectNotFound", Message: "Project not found", HTTPStatus: 401} ErrAccessKeyNotFound = WebRPCError{Code: 1101, Name: "AccessKeyNotFound", Message: "Access key not found", HTTPStatus: 401} - ErrAccessKeyMismatch = WebRPCError{Code: 1102, Name: "AccessKeyMismatch", Message: "Access key mismatch", HTTPStatus: 409} + ErrAccessKeyMismatch = WebRPCError{Code: 1102, Name: "AccessKeyMismatch", Message: "Access key mismatch", HTTPStatus: 403} ErrInvalidOrigin = WebRPCError{Code: 1103, Name: "InvalidOrigin", Message: "Invalid origin for Access Key", HTTPStatus: 403} ErrInvalidService = WebRPCError{Code: 1104, Name: "InvalidService", Message: "Service not enabled for Access key", HTTPStatus: 403} ErrUnauthorizedUser = WebRPCError{Code: 1105, Name: "UnauthorizedUser", Message: "Unauthorized user", HTTPStatus: 403} + ErrInvalidChain = WebRPCError{Code: 1106, Name: "InvalidChain", Message: "Network not enabled for Access key", HTTPStatus: 403} ErrQuotaExceeded = WebRPCError{Code: 1200, Name: "QuotaExceeded", Message: "Quota request exceeded", HTTPStatus: 429} ErrQuotaRateLimit = WebRPCError{Code: 1201, Name: "QuotaRateLimit", Message: "Quota rate limit exceeded", HTTPStatus: 429} ErrNoDefaultKey = WebRPCError{Code: 1300, Name: "NoDefaultKey", Message: "No default access key found", HTTPStatus: 403}