dfns-sdk 0.0.0.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. dfns_sdk/__init__.py +24 -0
  2. dfns_sdk/_internal/__init__.py +5 -0
  3. dfns_sdk/_internal/http_client.py +395 -0
  4. dfns_sdk/auth.py +137 -0
  5. dfns_sdk/base_auth_api.py +129 -0
  6. dfns_sdk/client.py +81 -0
  7. dfns_sdk/delegated_client.py +97 -0
  8. dfns_sdk/generated/__init__.py +47 -0
  9. dfns_sdk/generated/agreements/__init__.py +7 -0
  10. dfns_sdk/generated/agreements/client.py +55 -0
  11. dfns_sdk/generated/agreements/delegated_client.py +95 -0
  12. dfns_sdk/generated/agreements/types.py +20 -0
  13. dfns_sdk/generated/allocations/__init__.py +7 -0
  14. dfns_sdk/generated/allocations/client.py +118 -0
  15. dfns_sdk/generated/allocations/delegated_client.py +187 -0
  16. dfns_sdk/generated/allocations/types.py +69 -0
  17. dfns_sdk/generated/auth/__init__.py +7 -0
  18. dfns_sdk/generated/auth/client.py +1215 -0
  19. dfns_sdk/generated/auth/delegated_client.py +1825 -0
  20. dfns_sdk/generated/auth/types.py +702 -0
  21. dfns_sdk/generated/exchanges/__init__.py +7 -0
  22. dfns_sdk/generated/exchanges/client.py +209 -0
  23. dfns_sdk/generated/exchanges/delegated_client.py +341 -0
  24. dfns_sdk/generated/exchanges/types.py +96 -0
  25. dfns_sdk/generated/fee_sponsors/__init__.py +7 -0
  26. dfns_sdk/generated/fee_sponsors/client.py +161 -0
  27. dfns_sdk/generated/fee_sponsors/delegated_client.py +287 -0
  28. dfns_sdk/generated/fee_sponsors/types.py +89 -0
  29. dfns_sdk/generated/keys/__init__.py +7 -0
  30. dfns_sdk/generated/keys/client.py +310 -0
  31. dfns_sdk/generated/keys/delegated_client.py +518 -0
  32. dfns_sdk/generated/keys/types.py +229 -0
  33. dfns_sdk/generated/networks/__init__.py +7 -0
  34. dfns_sdk/generated/networks/client.py +176 -0
  35. dfns_sdk/generated/networks/delegated_client.py +274 -0
  36. dfns_sdk/generated/networks/types.py +77 -0
  37. dfns_sdk/generated/permissions/__init__.py +7 -0
  38. dfns_sdk/generated/permissions/client.py +185 -0
  39. dfns_sdk/generated/permissions/delegated_client.py +344 -0
  40. dfns_sdk/generated/permissions/types.py +107 -0
  41. dfns_sdk/generated/policies/__init__.py +7 -0
  42. dfns_sdk/generated/policies/client.py +187 -0
  43. dfns_sdk/generated/policies/delegated_client.py +311 -0
  44. dfns_sdk/generated/policies/types.py +70 -0
  45. dfns_sdk/generated/signers/__init__.py +7 -0
  46. dfns_sdk/generated/signers/client.py +45 -0
  47. dfns_sdk/generated/signers/delegated_client.py +56 -0
  48. dfns_sdk/generated/signers/types.py +13 -0
  49. dfns_sdk/generated/staking/__init__.py +7 -0
  50. dfns_sdk/generated/staking/client.py +142 -0
  51. dfns_sdk/generated/staking/delegated_client.py +211 -0
  52. dfns_sdk/generated/staking/types.py +64 -0
  53. dfns_sdk/generated/swaps/__init__.py +7 -0
  54. dfns_sdk/generated/swaps/client.py +118 -0
  55. dfns_sdk/generated/swaps/delegated_client.py +157 -0
  56. dfns_sdk/generated/swaps/types.py +99 -0
  57. dfns_sdk/generated/wallets/__init__.py +7 -0
  58. dfns_sdk/generated/wallets/client.py +805 -0
  59. dfns_sdk/generated/wallets/delegated_client.py +1231 -0
  60. dfns_sdk/generated/wallets/types.py +534 -0
  61. dfns_sdk/generated/webhooks/__init__.py +7 -0
  62. dfns_sdk/generated/webhooks/client.py +193 -0
  63. dfns_sdk/generated/webhooks/delegated_client.py +320 -0
  64. dfns_sdk/generated/webhooks/types.py +101 -0
  65. dfns_sdk/types.py +72 -0
  66. dfns_sdk-0.0.0.dev0.dist-info/METADATA +191 -0
  67. dfns_sdk-0.0.0.dev0.dist-info/RECORD +69 -0
  68. dfns_sdk-0.0.0.dev0.dist-info/WHEEL +4 -0
  69. dfns_sdk-0.0.0.dev0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,229 @@
1
+ """Types for the keys domain."""
2
+
3
+ from typing import Any, Literal, NotRequired, Optional, TypedDict, Union
4
+
5
+ class ListKeysResponse(TypedDict, total=False):
6
+ """listKeys response."""
7
+
8
+ items: list[TypedDict]
9
+ next_page_token: NotRequired[str]
10
+
11
+ class ListKeysQuery(TypedDict, total=False):
12
+ """listKeys query parameters."""
13
+
14
+ limit: NotRequired[str]
15
+ pagination_token: NotRequired[str]
16
+ owner: NotRequired[str]
17
+
18
+ class CreateKeyRequest(TypedDict, total=False):
19
+ """createKey request body."""
20
+
21
+ scheme: Literal["DH", "ECDSA", "EdDSA", "Schnorr"]
22
+ curve: Literal["ed25519", "secp256k1", "stark"]
23
+ name: NotRequired[str]
24
+ master_key: NotRequired[bool]
25
+ derive_from: NotRequired[TypedDict]
26
+ store_id: NotRequired[str]
27
+ delegate_to: NotRequired[str]
28
+ delay_delegation: NotRequired[bool]
29
+
30
+ class CreateKeyResponse(TypedDict, total=False):
31
+ """createKey response."""
32
+
33
+ id: str
34
+ scheme: Literal["DH", "ECDSA", "EdDSA", "Schnorr"]
35
+ curve: Literal["ed25519", "secp256k1", "stark"]
36
+ public_key: str
37
+ master_key: NotRequired[bool]
38
+ derived_from: NotRequired[TypedDict]
39
+ name: NotRequired[str]
40
+ status: Literal["Active", "Archived"]
41
+ custodial: bool
42
+ date_created: str
43
+ imported: NotRequired[bool]
44
+ exported: NotRequired[bool]
45
+ date_exported: NotRequired[str]
46
+ date_deleted: NotRequired[str]
47
+
48
+ class DelegateKeyRequest(TypedDict, total=False):
49
+ """delegateKey request body."""
50
+
51
+ delegate_to: str
52
+
53
+ class DelegateKeyResponse(TypedDict, total=False):
54
+ """delegateKey response."""
55
+
56
+ key_id: str
57
+ status: Literal["Delegated"]
58
+
59
+ class GetKeyResponse(TypedDict, total=False):
60
+ """getKey response."""
61
+
62
+ id: str
63
+ scheme: Literal["DH", "ECDSA", "EdDSA", "Schnorr"]
64
+ curve: Literal["ed25519", "secp256k1", "stark"]
65
+ public_key: str
66
+ master_key: NotRequired[bool]
67
+ derived_from: NotRequired[TypedDict]
68
+ name: NotRequired[str]
69
+ status: Literal["Active", "Archived"]
70
+ custodial: bool
71
+ date_created: str
72
+ imported: NotRequired[bool]
73
+ exported: NotRequired[bool]
74
+ date_exported: NotRequired[str]
75
+ date_deleted: NotRequired[str]
76
+ wallets: list[TypedDict]
77
+ store: TypedDict
78
+
79
+ class UpdateKeyRequest(TypedDict, total=False):
80
+ """updateKey request body."""
81
+
82
+ name: Any
83
+
84
+ class UpdateKeyResponse(TypedDict, total=False):
85
+ """updateKey response."""
86
+
87
+ id: str
88
+ scheme: Literal["DH", "ECDSA", "EdDSA", "Schnorr"]
89
+ curve: Literal["ed25519", "secp256k1", "stark"]
90
+ public_key: str
91
+ master_key: NotRequired[bool]
92
+ derived_from: NotRequired[TypedDict]
93
+ name: NotRequired[str]
94
+ status: Literal["Active", "Archived"]
95
+ custodial: bool
96
+ date_created: str
97
+ imported: NotRequired[bool]
98
+ exported: NotRequired[bool]
99
+ date_exported: NotRequired[str]
100
+ date_deleted: NotRequired[str]
101
+
102
+ class DeleteKeyResponse(TypedDict, total=False):
103
+ """deleteKey response."""
104
+
105
+ id: str
106
+ scheme: Literal["DH", "ECDSA", "EdDSA", "Schnorr"]
107
+ curve: Literal["ed25519", "secp256k1", "stark"]
108
+ public_key: str
109
+ master_key: NotRequired[bool]
110
+ derived_from: NotRequired[TypedDict]
111
+ name: NotRequired[str]
112
+ status: Literal["Active", "Archived"]
113
+ custodial: bool
114
+ date_created: str
115
+ imported: NotRequired[bool]
116
+ exported: NotRequired[bool]
117
+ date_exported: NotRequired[str]
118
+ date_deleted: NotRequired[str]
119
+
120
+ class DeriveKeyRequest(TypedDict, total=False):
121
+ """deriveKey request body."""
122
+
123
+ domain: str
124
+ seed: str
125
+
126
+ class DeriveKeyResponse(TypedDict, total=False):
127
+ """deriveKey response."""
128
+
129
+ output: str
130
+
131
+ class ExportKeyRequest(TypedDict, total=False):
132
+ """exportKey request body."""
133
+
134
+ encryption_key: str
135
+ supported_schemes: list[TypedDict]
136
+
137
+ class ExportKeyResponse(TypedDict, total=False):
138
+ """exportKey response."""
139
+
140
+ public_key: str
141
+ protocol: Union[Literal["CGGMP24", "FROST", "FROST_BITCOIN", "GLOW20_DH", "KU23"], Literal["CGGMP21"]]
142
+ curve: Literal["ed25519", "secp256k1", "stark"]
143
+ min_signers: float
144
+ encrypted_key_shares: list[TypedDict]
145
+
146
+ class ListSignaturesResponse(TypedDict, total=False):
147
+ """listSignatures response."""
148
+
149
+ key_id: str
150
+ items: list[TypedDict]
151
+ next_page_token: NotRequired[str]
152
+
153
+ class ListSignaturesQuery(TypedDict, total=False):
154
+ """listSignatures query parameters."""
155
+
156
+ limit: NotRequired[str]
157
+ pagination_token: NotRequired[str]
158
+
159
+ class GenerateSignatureResponse(TypedDict, total=False):
160
+ """generateSignature response."""
161
+
162
+ id: str
163
+ key_id: str
164
+ requester: TypedDict
165
+ request_body: TypedDict
166
+ status: Literal["Pending", "Executing", "Signed", "Confirmed", "Failed", "Rejected"]
167
+ reason: NotRequired[str]
168
+ signature: NotRequired[TypedDict]
169
+ signatures: NotRequired[list[TypedDict]]
170
+ signed_data: NotRequired[str]
171
+ network: NotRequired[Literal["Algorand", "AlgorandTestnet", "Aptos", "AptosTestnet", "ArbitrumOne", "ArbitrumSepolia", "ArcTestnet", "AvalancheC", "AvalancheCFuji", "BabylonGenesis", "BabylonTestnet5", "Base", "BaseSepolia", "Berachain", "BerachainBepolia", "Bitcoin", "BitcoinSignet", "BitcoinTestnet3", "BitcoinCash", "Bob", "BobSepolia", "Bsc", "BscTestnet", "Canton", "CantonTestnet", "Cardano", "CardanoPreprod", "Concordium", "ConcordiumTestnet", "Celo", "CeloAlfajores", "Codex", "CodexSepolia", "CosmosHub4", "CosmosIcsTestnet", "Dogecoin", "Ethereum", "EthereumClassic", "EthereumClassicMordor", "EthereumGoerli", "EthereumSepolia", "EthereumHolesky", "EthereumHoodi", "FantomOpera", "FantomTestnet", "FlareC", "FlareCCoston2", "FlowEvm", "FlowEvmTestnet", "Hedera", "HederaTestnet", "Ink", "InkSepolia", "InternetComputer", "Ion", "IonTestnet", "Iota", "IotaTestnet", "Kaspa", "Kusama", "KusamaAssetHub", "Litecoin", "Near", "NearTestnet", "Optimism", "OptimismSepolia", "Origyn", "Plasma", "PlasmaTestnet", "Plume", "PlumeSepolia", "Paseo", "PaseoAssetHub", "Polkadot", "PolkadotAssetHub", "Polygon", "PolygonAmoy", "Polymesh", "PolymeshTestnet", "Race", "RaceSepolia", "SeiAtlantic2", "SeiPacific1", "Solana", "SolanaDevnet", "Starknet", "StarknetSepolia", "Stellar", "StellarTestnet", "Sui", "SuiTestnet", "Tezos", "TezosGhostnet", "TempoAndantino", "Tsc", "TscTestnet1", "Ton", "TonTestnet", "Tron", "TronNile", "Westend", "WestendAssetHub", "XrpLedger", "XrpLedgerTestnet"]]
172
+ tx_hash: NotRequired[str]
173
+ fee: NotRequired[str]
174
+ approval_id: NotRequired[str]
175
+ date_requested: str
176
+ date_policy_resolved: NotRequired[str]
177
+ date_signed: NotRequired[str]
178
+ date_confirmed: NotRequired[str]
179
+ external_id: NotRequired[str]
180
+
181
+ class GetSignatureResponse(TypedDict, total=False):
182
+ """getSignature response."""
183
+
184
+ id: str
185
+ key_id: str
186
+ requester: TypedDict
187
+ request_body: TypedDict
188
+ status: Literal["Pending", "Executing", "Signed", "Confirmed", "Failed", "Rejected"]
189
+ reason: NotRequired[str]
190
+ signature: NotRequired[TypedDict]
191
+ signatures: NotRequired[list[TypedDict]]
192
+ signed_data: NotRequired[str]
193
+ network: NotRequired[Literal["Algorand", "AlgorandTestnet", "Aptos", "AptosTestnet", "ArbitrumOne", "ArbitrumSepolia", "ArcTestnet", "AvalancheC", "AvalancheCFuji", "BabylonGenesis", "BabylonTestnet5", "Base", "BaseSepolia", "Berachain", "BerachainBepolia", "Bitcoin", "BitcoinSignet", "BitcoinTestnet3", "BitcoinCash", "Bob", "BobSepolia", "Bsc", "BscTestnet", "Canton", "CantonTestnet", "Cardano", "CardanoPreprod", "Concordium", "ConcordiumTestnet", "Celo", "CeloAlfajores", "Codex", "CodexSepolia", "CosmosHub4", "CosmosIcsTestnet", "Dogecoin", "Ethereum", "EthereumClassic", "EthereumClassicMordor", "EthereumGoerli", "EthereumSepolia", "EthereumHolesky", "EthereumHoodi", "FantomOpera", "FantomTestnet", "FlareC", "FlareCCoston2", "FlowEvm", "FlowEvmTestnet", "Hedera", "HederaTestnet", "Ink", "InkSepolia", "InternetComputer", "Ion", "IonTestnet", "Iota", "IotaTestnet", "Kaspa", "Kusama", "KusamaAssetHub", "Litecoin", "Near", "NearTestnet", "Optimism", "OptimismSepolia", "Origyn", "Plasma", "PlasmaTestnet", "Plume", "PlumeSepolia", "Paseo", "PaseoAssetHub", "Polkadot", "PolkadotAssetHub", "Polygon", "PolygonAmoy", "Polymesh", "PolymeshTestnet", "Race", "RaceSepolia", "SeiAtlantic2", "SeiPacific1", "Solana", "SolanaDevnet", "Starknet", "StarknetSepolia", "Stellar", "StellarTestnet", "Sui", "SuiTestnet", "Tezos", "TezosGhostnet", "TempoAndantino", "Tsc", "TscTestnet1", "Ton", "TonTestnet", "Tron", "TronNile", "Westend", "WestendAssetHub", "XrpLedger", "XrpLedgerTestnet"]]
194
+ tx_hash: NotRequired[str]
195
+ fee: NotRequired[str]
196
+ approval_id: NotRequired[str]
197
+ date_requested: str
198
+ date_policy_resolved: NotRequired[str]
199
+ date_signed: NotRequired[str]
200
+ date_confirmed: NotRequired[str]
201
+ external_id: NotRequired[str]
202
+
203
+ class ImportKeyRequest(TypedDict, total=False):
204
+ """importKey request body."""
205
+
206
+ name: NotRequired[str]
207
+ curve: Literal["ed25519", "secp256k1", "stark"]
208
+ protocol: Union[Literal["CGGMP24", "FROST", "FROST_BITCOIN", "GLOW20_DH", "KU23"], Literal["CGGMP21"]]
209
+ min_signers: int
210
+ encrypted_key_shares: list[TypedDict]
211
+ master_key: NotRequired[bool]
212
+
213
+ class ImportKeyResponse(TypedDict, total=False):
214
+ """importKey response."""
215
+
216
+ id: str
217
+ scheme: Literal["DH", "ECDSA", "EdDSA", "Schnorr"]
218
+ curve: Literal["ed25519", "secp256k1", "stark"]
219
+ public_key: str
220
+ master_key: NotRequired[bool]
221
+ derived_from: NotRequired[TypedDict]
222
+ name: NotRequired[str]
223
+ status: Literal["Active", "Archived"]
224
+ custodial: bool
225
+ date_created: str
226
+ imported: NotRequired[bool]
227
+ exported: NotRequired[bool]
228
+ date_exported: NotRequired[str]
229
+ date_deleted: NotRequired[str]
@@ -0,0 +1,7 @@
1
+ """Networks domain module."""
2
+
3
+ from .client import NetworksClient
4
+ from .delegated_client import DelegatedNetworksClient
5
+ from . import types
6
+
7
+ __all__ = ["NetworksClient", "DelegatedNetworksClient", "types"]
@@ -0,0 +1,176 @@
1
+ """Client for the networks domain."""
2
+
3
+ from typing import Any, Literal, Optional, TypedDict, Union
4
+
5
+ from ..._internal import HttpClient
6
+ from . import types as T
7
+
8
+
9
+ class NetworksClient:
10
+ """Client for networks operations."""
11
+
12
+ def __init__(self, http_client: HttpClient):
13
+ self._http = http_client
14
+
15
+ def estimate_fees(self, query: T.EstimateFeesQuery) -> TypedDict:
16
+ """
17
+ Estimate Fees.
18
+
19
+ Gets real-time fee details for a given network, allowing users to make decisions based on their preferences for transaction speed/priority. Three levels of priority will be displayed: `slow`, `standard`, `fast`.
20
+
21
+ Args:
22
+ query: Query parameters.
23
+
24
+ Returns:
25
+ TypedDict: The API response.
26
+ """
27
+ return self._http.request(
28
+ method="GET",
29
+ path="/networks/fees",
30
+ path_params={},
31
+ query_params=query,
32
+ body=None,
33
+ requires_signature=False,
34
+ )
35
+
36
+ def read_contract(self, body: dict[str, Any]) -> T.ReadContractResponse:
37
+ """
38
+ Read Contract.
39
+
40
+ Call a read-only function on a smart contract. In Solidity, this use the `view` keyword.
41
+
42
+ <Note>
43
+ Currently only works on EVM compatible chains.
44
+ </Note>
45
+
46
+ Args:
47
+ body: Request body.
48
+
49
+ Returns:
50
+ T.ReadContractResponse: The API response.
51
+ """
52
+ return self._http.request(
53
+ method="POST",
54
+ path="/networks/read-contract",
55
+ path_params={},
56
+ query_params=None,
57
+ body=body,
58
+ requires_signature=False,
59
+ )
60
+
61
+ def get_canton_validator(self, network: Literal["canton", "canton-devnet", "canton-testnet"], validator_id: str) -> T.GetCantonValidatorResponse:
62
+ """
63
+ Get Canton Validator.
64
+
65
+ Return a configured Canton Validator in your organization.
66
+
67
+ Args:
68
+ network: Path parameter.
69
+ validator_id: Path parameter.
70
+
71
+ Returns:
72
+ T.GetCantonValidatorResponse: The API response.
73
+ """
74
+ return self._http.request(
75
+ method="GET",
76
+ path="/networks/{network}/validators/{validatorId}",
77
+ path_params={"network": network, "validatorId": validator_id},
78
+ query_params=None,
79
+ body=None,
80
+ requires_signature=False,
81
+ )
82
+
83
+ def update_canton_validator(self, network: Literal["canton", "canton-devnet", "canton-testnet"], validator_id: str, body: T.UpdateCantonValidatorRequest) -> T.UpdateCantonValidatorResponse:
84
+ """
85
+ Update Canton Validator.
86
+
87
+ Update an existing Canton Validator configuration.
88
+
89
+ Read details about the process [here](https://docs.dfns.co/networks/canton-validators).
90
+
91
+ Args:
92
+ network: Path parameter.
93
+ validator_id: Path parameter.
94
+ body: Request body.
95
+
96
+ Returns:
97
+ T.UpdateCantonValidatorResponse: The API response.
98
+ """
99
+ return self._http.request(
100
+ method="PUT",
101
+ path="/networks/{network}/validators/{validatorId}",
102
+ path_params={"network": network, "validatorId": validator_id},
103
+ query_params=None,
104
+ body=body,
105
+ requires_signature=True,
106
+ )
107
+
108
+ def delete_canton_validator(self, network: Literal["canton", "canton-devnet", "canton-testnet"], validator_id: str) -> T.DeleteCantonValidatorResponse:
109
+ """
110
+ Delete Canton Validator.
111
+
112
+ Delete a specific Canton Validator configuration.
113
+
114
+ Args:
115
+ network: Path parameter.
116
+ validator_id: Path parameter.
117
+
118
+ Returns:
119
+ T.DeleteCantonValidatorResponse: The API response.
120
+ """
121
+ return self._http.request(
122
+ method="DELETE",
123
+ path="/networks/{network}/validators/{validatorId}",
124
+ path_params={"network": network, "validatorId": validator_id},
125
+ query_params=None,
126
+ body=None,
127
+ requires_signature=True,
128
+ )
129
+
130
+ def list_canton_validators(self, network: Literal["canton", "canton-devnet", "canton-testnet"], query: Optional[T.ListCantonValidatorsQuery] = None) -> T.ListCantonValidatorsResponse:
131
+ """
132
+ List Canton Validators.
133
+
134
+ Retrieve the list of configured Canton Validators in your organization.
135
+
136
+ Args:
137
+ network: Path parameter.
138
+ query: Query parameters.
139
+
140
+ Returns:
141
+ T.ListCantonValidatorsResponse: The API response.
142
+ """
143
+ return self._http.request(
144
+ method="GET",
145
+ path="/networks/{network}/validators",
146
+ path_params={"network": network},
147
+ query_params=query,
148
+ body=None,
149
+ requires_signature=False,
150
+ )
151
+
152
+ def create_canton_validator(self, network: Literal["canton", "canton-devnet", "canton-testnet"], body: dict[str, Any]) -> T.CreateCantonValidatorResponse:
153
+ """
154
+ Create Canton Validator.
155
+
156
+ Link a Canton Validator to your organization. This is required in order to create wallets or interact with the Canton network.
157
+
158
+ The `Shared` option allows you to use a shared validator hosted by DFNS and get started in seconds, while the `Custom` option allows you to connect your own validator and ledger nodes using OAuth2 authentication.
159
+
160
+ Read details about the process [here](https://docs.dfns.co/networks/canton-validators).
161
+
162
+ Args:
163
+ network: Path parameter.
164
+ body: Request body.
165
+
166
+ Returns:
167
+ T.CreateCantonValidatorResponse: The API response.
168
+ """
169
+ return self._http.request(
170
+ method="POST",
171
+ path="/networks/{network}/validators",
172
+ path_params={"network": network},
173
+ query_params=None,
174
+ body=body,
175
+ requires_signature=True,
176
+ )
@@ -0,0 +1,274 @@
1
+ """Delegated client for the networks domain."""
2
+
3
+ import json
4
+ from typing import Any, Literal, Optional, TypedDict, Union
5
+
6
+ from ..._internal import HttpClient
7
+ from ...base_auth_api import (
8
+ BaseAuthApi,
9
+ SignUserActionChallengeRequest,
10
+ UserActionChallengeResponse,
11
+ )
12
+ from . import types as T
13
+
14
+
15
+ class DelegatedNetworksClient:
16
+ """
17
+ Delegated client for networks operations.
18
+
19
+ This client separates user action signing into _init() and _complete() method pairs,
20
+ allowing external systems to handle the signing process.
21
+ """
22
+
23
+ def __init__(self, http_client: HttpClient):
24
+ self._http = http_client
25
+
26
+ def estimate_fees(self, query: T.EstimateFeesQuery) -> TypedDict:
27
+ """
28
+ Estimate Fees.
29
+
30
+ Gets real-time fee details for a given network, allowing users to make decisions based on their preferences for transaction speed/priority. Three levels of priority will be displayed: `slow`, `standard`, `fast`.
31
+
32
+ Args:
33
+ query: Query parameters.
34
+
35
+ Returns:
36
+ TypedDict: The API response.
37
+ """
38
+ return self._http.request(
39
+ method="GET",
40
+ path="/networks/fees",
41
+ path_params={},
42
+ query_params=query,
43
+ body=None,
44
+ requires_signature=False,
45
+ )
46
+
47
+ def read_contract(self, body: dict[str, Any]) -> T.ReadContractResponse:
48
+ """
49
+ Read Contract.
50
+
51
+ Call a read-only function on a smart contract. In Solidity, this use the `view` keyword.
52
+
53
+ <Note>
54
+ Currently only works on EVM compatible chains.
55
+ </Note>
56
+
57
+ Args:
58
+ body: Request body.
59
+
60
+ Returns:
61
+ T.ReadContractResponse: The API response.
62
+ """
63
+ return self._http.request(
64
+ method="POST",
65
+ path="/networks/read-contract",
66
+ path_params={},
67
+ query_params=None,
68
+ body=body,
69
+ requires_signature=False,
70
+ )
71
+
72
+ def get_canton_validator(self, network: Literal["canton", "canton-devnet", "canton-testnet"], validator_id: str) -> T.GetCantonValidatorResponse:
73
+ """
74
+ Get Canton Validator.
75
+
76
+ Return a configured Canton Validator in your organization.
77
+
78
+ Args:
79
+ network: Path parameter.
80
+ validator_id: Path parameter.
81
+
82
+ Returns:
83
+ T.GetCantonValidatorResponse: The API response.
84
+ """
85
+ return self._http.request(
86
+ method="GET",
87
+ path="/networks/{network}/validators/{validatorId}",
88
+ path_params={"network": network, "validatorId": validator_id},
89
+ query_params=None,
90
+ body=None,
91
+ requires_signature=False,
92
+ )
93
+
94
+ def update_canton_validator_init(self, network: Literal["canton", "canton-devnet", "canton-testnet"], validator_id: str, body: T.UpdateCantonValidatorRequest) -> UserActionChallengeResponse:
95
+ """
96
+ Initialize Update Canton Validator.
97
+
98
+ Creates a user action challenge for external signing.
99
+
100
+ Args:
101
+ network: Path parameter.
102
+ validator_id: Path parameter.
103
+ body: Request body.
104
+
105
+ Returns:
106
+ UserActionChallengeResponse: The challenge to sign externally.
107
+ """
108
+ path = "/networks/{network}/validators/{validatorId}"
109
+ path = path.replace("{network}", str(network))
110
+ path = path.replace("{validatorId}", str(validator_id))
111
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
112
+
113
+ return BaseAuthApi.create_user_action_challenge(
114
+ self._http,
115
+ user_action_http_method="PUT",
116
+ user_action_http_path=path,
117
+ user_action_payload=payload,
118
+ )
119
+
120
+ def update_canton_validator_complete(self, network: Literal["canton", "canton-devnet", "canton-testnet"], validator_id: str, body: T.UpdateCantonValidatorRequest, signed_challenge: SignUserActionChallengeRequest) -> T.UpdateCantonValidatorResponse:
121
+ """
122
+ Complete Update Canton Validator.
123
+
124
+ Submits the signed challenge and makes the API request.
125
+
126
+ Args:
127
+ network: Path parameter.
128
+ validator_id: Path parameter.
129
+ body: Request body.
130
+ signed_challenge: The signed challenge from external signing.
131
+
132
+ Returns:
133
+ T.UpdateCantonValidatorResponse: The API response.
134
+ """
135
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
136
+ self._http, signed_challenge
137
+ )
138
+ user_action_token = user_action_result["userAction"]
139
+
140
+ return self._http.request_with_user_action(
141
+ method="PUT",
142
+ path="/networks/{network}/validators/{validatorId}",
143
+ path_params={"network": network, "validatorId": validator_id},
144
+ query_params=None,
145
+ body=body,
146
+ user_action=user_action_token,
147
+ )
148
+
149
+ def delete_canton_validator_init(self, network: Literal["canton", "canton-devnet", "canton-testnet"], validator_id: str) -> UserActionChallengeResponse:
150
+ """
151
+ Initialize Delete Canton Validator.
152
+
153
+ Creates a user action challenge for external signing.
154
+
155
+ Args:
156
+ network: Path parameter.
157
+ validator_id: Path parameter.
158
+
159
+ Returns:
160
+ UserActionChallengeResponse: The challenge to sign externally.
161
+ """
162
+ path = "/networks/{network}/validators/{validatorId}"
163
+ path = path.replace("{network}", str(network))
164
+ path = path.replace("{validatorId}", str(validator_id))
165
+ payload = ""
166
+
167
+ return BaseAuthApi.create_user_action_challenge(
168
+ self._http,
169
+ user_action_http_method="DELETE",
170
+ user_action_http_path=path,
171
+ user_action_payload=payload,
172
+ )
173
+
174
+ def delete_canton_validator_complete(self, network: Literal["canton", "canton-devnet", "canton-testnet"], validator_id: str, signed_challenge: SignUserActionChallengeRequest) -> T.DeleteCantonValidatorResponse:
175
+ """
176
+ Complete Delete Canton Validator.
177
+
178
+ Submits the signed challenge and makes the API request.
179
+
180
+ Args:
181
+ network: Path parameter.
182
+ validator_id: Path parameter.
183
+ signed_challenge: The signed challenge from external signing.
184
+
185
+ Returns:
186
+ T.DeleteCantonValidatorResponse: The API response.
187
+ """
188
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
189
+ self._http, signed_challenge
190
+ )
191
+ user_action_token = user_action_result["userAction"]
192
+
193
+ return self._http.request_with_user_action(
194
+ method="DELETE",
195
+ path="/networks/{network}/validators/{validatorId}",
196
+ path_params={"network": network, "validatorId": validator_id},
197
+ query_params=None,
198
+ body=None,
199
+ user_action=user_action_token,
200
+ )
201
+
202
+ def list_canton_validators(self, network: Literal["canton", "canton-devnet", "canton-testnet"], query: Optional[T.ListCantonValidatorsQuery] = None) -> T.ListCantonValidatorsResponse:
203
+ """
204
+ List Canton Validators.
205
+
206
+ Retrieve the list of configured Canton Validators in your organization.
207
+
208
+ Args:
209
+ network: Path parameter.
210
+ query: Query parameters.
211
+
212
+ Returns:
213
+ T.ListCantonValidatorsResponse: The API response.
214
+ """
215
+ return self._http.request(
216
+ method="GET",
217
+ path="/networks/{network}/validators",
218
+ path_params={"network": network},
219
+ query_params=query,
220
+ body=None,
221
+ requires_signature=False,
222
+ )
223
+
224
+ def create_canton_validator_init(self, network: Literal["canton", "canton-devnet", "canton-testnet"], body: dict[str, Any]) -> UserActionChallengeResponse:
225
+ """
226
+ Initialize Create Canton Validator.
227
+
228
+ Creates a user action challenge for external signing.
229
+
230
+ Args:
231
+ network: Path parameter.
232
+ body: Request body.
233
+
234
+ Returns:
235
+ UserActionChallengeResponse: The challenge to sign externally.
236
+ """
237
+ path = "/networks/{network}/validators"
238
+ path = path.replace("{network}", str(network))
239
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
240
+
241
+ return BaseAuthApi.create_user_action_challenge(
242
+ self._http,
243
+ user_action_http_method="POST",
244
+ user_action_http_path=path,
245
+ user_action_payload=payload,
246
+ )
247
+
248
+ def create_canton_validator_complete(self, network: Literal["canton", "canton-devnet", "canton-testnet"], body: dict[str, Any], signed_challenge: SignUserActionChallengeRequest) -> T.CreateCantonValidatorResponse:
249
+ """
250
+ Complete Create Canton Validator.
251
+
252
+ Submits the signed challenge and makes the API request.
253
+
254
+ Args:
255
+ network: Path parameter.
256
+ body: Request body.
257
+ signed_challenge: The signed challenge from external signing.
258
+
259
+ Returns:
260
+ T.CreateCantonValidatorResponse: The API response.
261
+ """
262
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
263
+ self._http, signed_challenge
264
+ )
265
+ user_action_token = user_action_result["userAction"]
266
+
267
+ return self._http.request_with_user_action(
268
+ method="POST",
269
+ path="/networks/{network}/validators",
270
+ path_params={"network": network},
271
+ query_params=None,
272
+ body=body,
273
+ user_action=user_action_token,
274
+ )