Skip to content

Commit 82a6777

Browse files
MakerOnlyApiKeys
1 parent 3455381 commit 82a6777

3 files changed

Lines changed: 334 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import asyncio, json, lighter
2+
from utils import default_example_setup
3+
4+
async def main():
5+
client, api_client, _ = default_example_setup()
6+
auth_token, err = client.create_auth_token_with_expiry()
7+
assert err is None
8+
9+
account_api = lighter.AccountApi(api_client)
10+
11+
resp = await account_api.set_maker_only_api_keys(
12+
account_index=client.account_index,
13+
api_key_indexes=json.dumps([4, 5, 6]),
14+
authorization=auth_token,
15+
)
16+
print("set:", resp)
17+
18+
resp = await account_api.get_maker_only_api_keys(
19+
account_index=client.account_index,
20+
authorization=auth_token,
21+
)
22+
print("get:", resp)
23+
await client.close()
24+
await api_client.close()
25+
26+
if __name__ == "__main__":
27+
asyncio.run(main())

lighter/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,10 @@
203203
from lighter.models.withdraw_history import WithdrawHistory
204204
from lighter.models.withdraw_history_item import WithdrawHistoryItem
205205
from lighter.models.zk_lighter_info import ZkLighterInfo
206+
from lighter.models.resp_get_maker_only_api_keys import RespGetMakerOnlyApiKeys
207+
from lighter.models.resp_set_maker_only_api_keys import RespSetMakerOnlyApiKeys
208+
from lighter.models.req_get_partner_stats import ReqGetPartnerStats
209+
from lighter.models.req_get_maker_only_api_keys import ReqGetMakerOnlyApiKeys
210+
from lighter.models.partner_stats import PartnerStats
206211
from lighter.ws_client import WsClient
207212
from lighter.signer_client import SignerClient, create_api_key

lighter/api/account_api.py

Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from lighter.models.resp_get_lease_options import RespGetLeaseOptions
3434
from lighter.models.resp_get_leases import RespGetLeases
3535
from lighter.models.resp_get_maker_only_api_keys import RespGetMakerOnlyApiKeys
36+
from lighter.models.resp_set_maker_only_api_keys import RespSetMakerOnlyApiKeys
3637
from lighter.models.resp_post_api_token import RespPostApiToken
3738
from lighter.models.resp_public_pools_metadata import RespPublicPoolsMetadata
3839
from lighter.models.resp_revoke_api_token import RespRevokeApiToken
@@ -2425,7 +2426,308 @@ def _get_maker_only_api_keys_serialize(
24252426
_request_auth=_request_auth
24262427
)
24272428

2429+
@validate_call
2430+
async def set_maker_only_api_keys(
2431+
self,
2432+
authorization: StrictStr,
2433+
account_index: StrictInt,
2434+
api_key_indexes: Annotated[StrictStr, Field(
2435+
description="JSON array string of API key indexes, e.g. \\\"[4,5]\\\". Use [] to clear all maker-only restrictions.")],
2436+
_request_timeout: Union[
2437+
None,
2438+
Annotated[StrictFloat, Field(gt=0)],
2439+
Tuple[
2440+
Annotated[StrictFloat, Field(gt=0)],
2441+
Annotated[StrictFloat, Field(gt=0)]
2442+
]
2443+
] = None,
2444+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
2445+
_content_type: Optional[StrictStr] = None,
2446+
_headers: Optional[Dict[StrictStr, Any]] = None,
2447+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
2448+
) -> RespSetMakerOnlyApiKeys:
2449+
"""setMakerOnlyApiKeys
2450+
2451+
Set maker-only API key indexes. This replaces the current list; pass all indexes you want marked as maker-only. Pass [] to clear all maker-only restrictions.
2452+
2453+
:param authorization: (required)
2454+
:type authorization: str
2455+
:param account_index: (required)
2456+
:type account_index: int
2457+
:param api_key_indexes: JSON array string of API key indexes, e.g. \\\"[4,5]\\\". Use [] to clear all maker-only restrictions. (required)
2458+
:type api_key_indexes: str
2459+
:param _request_timeout: timeout setting for this request. If one
2460+
number provided, it will be total request
2461+
timeout. It can also be a pair (tuple) of
2462+
(connection, read) timeouts.
2463+
:type _request_timeout: int, tuple(int, int), optional
2464+
:param _request_auth: set to override the auth_settings for an a single
2465+
request; this effectively ignores the
2466+
authentication in the spec for a single request.
2467+
:type _request_auth: dict, optional
2468+
:param _content_type: force content-type for the request.
2469+
:type _content_type: str, Optional
2470+
:param _headers: set to override the headers for a single
2471+
request; this effectively ignores the headers
2472+
in the spec for a single request.
2473+
:type _headers: dict, optional
2474+
:param _host_index: set to override the host_index for a single
2475+
request; this effectively ignores the host_index
2476+
in the spec for a single request.
2477+
:type _host_index: int, optional
2478+
:return: Returns the result object.
2479+
""" # noqa: E501
2480+
2481+
_param = self._set_maker_only_api_keys_serialize(
2482+
authorization=authorization,
2483+
account_index=account_index,
2484+
api_key_indexes=api_key_indexes,
2485+
_request_auth=_request_auth,
2486+
_content_type=_content_type,
2487+
_headers=_headers,
2488+
_host_index=_host_index
2489+
)
2490+
2491+
_response_types_map: Dict[str, Optional[str]] = {
2492+
'200': "RespSetMakerOnlyApiKeys",
2493+
'400': "ResultCode",
2494+
}
2495+
response_data = await self.api_client.call_api(
2496+
*_param,
2497+
_request_timeout=_request_timeout
2498+
)
2499+
await response_data.read()
2500+
return self.api_client.response_deserialize(
2501+
response_data=response_data,
2502+
response_types_map=_response_types_map,
2503+
).data
2504+
2505+
@validate_call
2506+
async def set_maker_only_api_keys_with_http_info(
2507+
self,
2508+
authorization: StrictStr,
2509+
account_index: StrictInt,
2510+
api_key_indexes: Annotated[StrictStr, Field(
2511+
description="JSON array string of API key indexes, e.g. \\\"[4,5]\\\". Use [] to clear all maker-only restrictions.")],
2512+
_request_timeout: Union[
2513+
None,
2514+
Annotated[StrictFloat, Field(gt=0)],
2515+
Tuple[
2516+
Annotated[StrictFloat, Field(gt=0)],
2517+
Annotated[StrictFloat, Field(gt=0)]
2518+
]
2519+
] = None,
2520+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
2521+
_content_type: Optional[StrictStr] = None,
2522+
_headers: Optional[Dict[StrictStr, Any]] = None,
2523+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
2524+
) -> ApiResponse[RespSetMakerOnlyApiKeys]:
2525+
"""setMakerOnlyApiKeys
2526+
2527+
Set maker-only API key indexes. This replaces the current list; pass all indexes you want marked as maker-only. Pass [] to clear all maker-only restrictions.
2528+
2529+
:param authorization: (required)
2530+
:type authorization: str
2531+
:param account_index: (required)
2532+
:type account_index: int
2533+
:param api_key_indexes: JSON array string of API key indexes, e.g. \\\"[4,5]\\\". Use [] to clear all maker-only restrictions. (required)
2534+
:type api_key_indexes: str
2535+
:param _request_timeout: timeout setting for this request. If one
2536+
number provided, it will be total request
2537+
timeout. It can also be a pair (tuple) of
2538+
(connection, read) timeouts.
2539+
:type _request_timeout: int, tuple(int, int), optional
2540+
:param _request_auth: set to override the auth_settings for an a single
2541+
request; this effectively ignores the
2542+
authentication in the spec for a single request.
2543+
:type _request_auth: dict, optional
2544+
:param _content_type: force content-type for the request.
2545+
:type _content_type: str, Optional
2546+
:param _headers: set to override the headers for a single
2547+
request; this effectively ignores the headers
2548+
in the spec for a single request.
2549+
:type _headers: dict, optional
2550+
:param _host_index: set to override the host_index for a single
2551+
request; this effectively ignores the host_index
2552+
in the spec for a single request.
2553+
:type _host_index: int, optional
2554+
:return: Returns the result object.
2555+
""" # noqa: E501
2556+
2557+
_param = self._set_maker_only_api_keys_serialize(
2558+
authorization=authorization,
2559+
account_index=account_index,
2560+
api_key_indexes=api_key_indexes,
2561+
_request_auth=_request_auth,
2562+
_content_type=_content_type,
2563+
_headers=_headers,
2564+
_host_index=_host_index
2565+
)
2566+
2567+
_response_types_map: Dict[str, Optional[str]] = {
2568+
'200': "RespSetMakerOnlyApiKeys",
2569+
'400': "ResultCode",
2570+
}
2571+
response_data = await self.api_client.call_api(
2572+
*_param,
2573+
_request_timeout=_request_timeout
2574+
)
2575+
await response_data.read()
2576+
return self.api_client.response_deserialize(
2577+
response_data=response_data,
2578+
response_types_map=_response_types_map,
2579+
)
2580+
2581+
@validate_call
2582+
async def set_maker_only_api_keys_without_preload_content(
2583+
self,
2584+
authorization: StrictStr,
2585+
account_index: StrictInt,
2586+
api_key_indexes: Annotated[StrictStr, Field(
2587+
description="JSON array string of API key indexes, e.g. \\\"[4,5]\\\". Use [] to clear all maker-only restrictions.")],
2588+
_request_timeout: Union[
2589+
None,
2590+
Annotated[StrictFloat, Field(gt=0)],
2591+
Tuple[
2592+
Annotated[StrictFloat, Field(gt=0)],
2593+
Annotated[StrictFloat, Field(gt=0)]
2594+
]
2595+
] = None,
2596+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
2597+
_content_type: Optional[StrictStr] = None,
2598+
_headers: Optional[Dict[StrictStr, Any]] = None,
2599+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
2600+
) -> RESTResponseType:
2601+
"""setMakerOnlyApiKeys
24282602
2603+
Set maker-only API key indexes. This replaces the current list; pass all indexes you want marked as maker-only. Pass [] to clear all maker-only restrictions.
2604+
2605+
:param authorization: (required)
2606+
:type authorization: str
2607+
:param account_index: (required)
2608+
:type account_index: int
2609+
:param api_key_indexes: JSON array string of API key indexes, e.g. \\\"[4,5]\\\". Use [] to clear all maker-only restrictions. (required)
2610+
:type api_key_indexes: str
2611+
:param _request_timeout: timeout setting for this request. If one
2612+
number provided, it will be total request
2613+
timeout. It can also be a pair (tuple) of
2614+
(connection, read) timeouts.
2615+
:type _request_timeout: int, tuple(int, int), optional
2616+
:param _request_auth: set to override the auth_settings for an a single
2617+
request; this effectively ignores the
2618+
authentication in the spec for a single request.
2619+
:type _request_auth: dict, optional
2620+
:param _content_type: force content-type for the request.
2621+
:type _content_type: str, Optional
2622+
:param _headers: set to override the headers for a single
2623+
request; this effectively ignores the headers
2624+
in the spec for a single request.
2625+
:type _headers: dict, optional
2626+
:param _host_index: set to override the host_index for a single
2627+
request; this effectively ignores the host_index
2628+
in the spec for a single request.
2629+
:type _host_index: int, optional
2630+
:return: Returns the result object.
2631+
""" # noqa: E501
2632+
2633+
_param = self._set_maker_only_api_keys_serialize(
2634+
authorization=authorization,
2635+
account_index=account_index,
2636+
api_key_indexes=api_key_indexes,
2637+
_request_auth=_request_auth,
2638+
_content_type=_content_type,
2639+
_headers=_headers,
2640+
_host_index=_host_index
2641+
)
2642+
2643+
_response_types_map: Dict[str, Optional[str]] = {
2644+
'200': "RespSetMakerOnlyApiKeys",
2645+
'400': "ResultCode",
2646+
}
2647+
response_data = await self.api_client.call_api(
2648+
*_param,
2649+
_request_timeout=_request_timeout
2650+
)
2651+
return response_data.response
2652+
2653+
def _set_maker_only_api_keys_serialize(
2654+
self,
2655+
authorization,
2656+
account_index,
2657+
api_key_indexes,
2658+
_request_auth,
2659+
_content_type,
2660+
_headers,
2661+
_host_index,
2662+
) -> RequestSerialized:
2663+
2664+
_host = None
2665+
2666+
_collection_formats: Dict[str, str] = {
2667+
}
2668+
2669+
_path_params: Dict[str, str] = {}
2670+
_query_params: List[Tuple[str, str]] = []
2671+
_header_params: Dict[str, Optional[str]] = _headers or {}
2672+
_form_params: List[Tuple[str, str]] = []
2673+
_files: Dict[
2674+
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
2675+
] = {}
2676+
_body_params: Optional[bytes] = None
2677+
2678+
# process the path parameters
2679+
# process the query parameters
2680+
# process the header parameters
2681+
if authorization is not None:
2682+
_header_params['authorization'] = authorization
2683+
# process the form parameters
2684+
if account_index is not None:
2685+
_form_params.append(('account_index', account_index))
2686+
if api_key_indexes is not None:
2687+
_form_params.append(('api_key_indexes', api_key_indexes))
2688+
# process the body parameter
2689+
2690+
# set the HTTP header `Accept`
2691+
if 'Accept' not in _header_params:
2692+
_header_params['Accept'] = self.api_client.select_header_accept(
2693+
[
2694+
'application/json'
2695+
]
2696+
)
2697+
2698+
# set the HTTP header `Content-Type`
2699+
if _content_type:
2700+
_header_params['Content-Type'] = _content_type
2701+
else:
2702+
_default_content_type = (
2703+
self.api_client.select_header_content_type(
2704+
[
2705+
'application/x-www-form-urlencoded',
2706+
'multipart/form-data'
2707+
]
2708+
)
2709+
)
2710+
if _default_content_type is not None:
2711+
_header_params['Content-Type'] = _default_content_type
2712+
2713+
# authentication setting
2714+
_auth_settings: List[str] = [
2715+
]
2716+
2717+
return self.api_client.param_serialize(
2718+
method='POST',
2719+
resource_path='/api/v1/setMakerOnlyApiKeys',
2720+
path_params=_path_params,
2721+
query_params=_query_params,
2722+
header_params=_header_params,
2723+
body=_body_params,
2724+
post_params=_form_params,
2725+
files=_files,
2726+
auth_settings=_auth_settings,
2727+
collection_formats=_collection_formats,
2728+
_host=_host,
2729+
_request_auth=_request_auth
2730+
)
24292731

24302732

24312733
async def l1_metadata(

0 commit comments

Comments
 (0)