1
1
import json
2
2
import os
3
3
4
+ from cdp import __version__
4
5
from cdp .api_clients import ApiClients
5
6
from cdp .cdp_api_client import CdpApiClient
7
+ from cdp .constants import SDK_DEFAULT_SOURCE
6
8
from cdp .errors import InvalidConfigurationError
7
9
8
10
@@ -54,6 +56,8 @@ def configure(
54
56
debugging : bool = False ,
55
57
base_path : str = "https://api.cdp.coinbase.com/platform" ,
56
58
max_network_retries : int = 3 ,
59
+ source : str = SDK_DEFAULT_SOURCE ,
60
+ source_version : str = __version__ ,
57
61
) -> None :
58
62
"""Configure the CDP SDK.
59
63
@@ -64,6 +68,8 @@ def configure(
64
68
debugging (bool): Whether debugging is enabled. Defaults to False.
65
69
base_path (str): The base URL for the CDP API. Defaults to "https://api.cdp.coinbase.com/platform".
66
70
max_network_retries (int): The maximum number of network retries. Defaults to 3.
71
+ source (Optional[str]): Specifies whether the sdk is being used directly or if it's an Agentkit extension.
72
+ source_version (Optional[str]): The version of the source package.
67
73
68
74
"""
69
75
cls .api_key_name = api_key_name
@@ -74,7 +80,13 @@ def configure(
74
80
cls .max_network_retries = max_network_retries
75
81
76
82
cdp_client = CdpApiClient (
77
- api_key_name , private_key , base_path , debugging , max_network_retries
83
+ api_key_name ,
84
+ private_key ,
85
+ base_path ,
86
+ debugging ,
87
+ max_network_retries ,
88
+ source ,
89
+ source_version ,
78
90
)
79
91
cls .api_clients = ApiClients (cdp_client )
80
92
@@ -86,6 +98,8 @@ def configure_from_json(
86
98
debugging : bool = False ,
87
99
base_path : str = "https://api.cdp.coinbase.com/platform" ,
88
100
max_network_retries : int = 3 ,
101
+ source : str = SDK_DEFAULT_SOURCE ,
102
+ source_version : str = __version__ ,
89
103
) -> None :
90
104
"""Configure the CDP SDK from a JSON file.
91
105
@@ -95,6 +109,8 @@ def configure_from_json(
95
109
debugging (bool): Whether debugging is enabled. Defaults to False.
96
110
base_path (str): The base URL for the CDP API. Defaults to "https://api.cdp.coinbase.com/platform".
97
111
max_network_retries (int): The maximum number of network retries. Defaults to 3.
112
+ source (Optional[str]): Specifies whether the sdk is being used directly or if it's an Agentkit extension.
113
+ source_version (Optional[str]): The version of the source package.
98
114
99
115
Raises:
100
116
InvalidConfigurationError: If the JSON file is missing the 'api_key_name' or 'private_key'.
@@ -108,12 +124,13 @@ def configure_from_json(
108
124
raise InvalidConfigurationError ("Invalid JSON format: Missing 'api_key_name'" )
109
125
if not private_key :
110
126
raise InvalidConfigurationError ("Invalid JSON format: Missing 'private_key'" )
111
-
112
127
cls .configure (
113
128
api_key_name ,
114
129
private_key ,
115
130
use_server_signer ,
116
131
debugging ,
117
132
base_path ,
118
133
max_network_retries ,
134
+ source ,
135
+ source_version ,
119
136
)
0 commit comments