|
1 | | -# Copyright 2019 Dragonchain, Inc. or its affiliates. All Rights Reserved. |
| 1 | +# Copyright 2020 Dragonchain, Inc. or its affiliates. All Rights Reserved. |
2 | 2 | # Licensed under the Apache License, Version 2.0 (the "License"); |
3 | 3 | # you may not use this file except in compliance with the License. |
4 | 4 | # You may obtain a copy of the License at |
@@ -304,21 +304,30 @@ def update_smart_contract( # noqa: C901 |
304 | 304 |
|
305 | 305 | return self.request.put("/v1/contract/{}".format(smart_contract_id), body) |
306 | 306 |
|
307 | | - def delete_smart_contract(self, smart_contract_id: str) -> "request_response": |
| 307 | + def delete_smart_contract(self, smart_contract_id: Optional[str] = None, transaction_type: Optional[str] = None) -> "request_response": |
308 | 308 | """Delete an existing contract |
309 | 309 |
|
310 | 310 | Args: |
311 | | - smart_contract_id (str): Transaction type of the contract to delete |
| 311 | + smart_contract_id (str, optional): Contract ID of the contract to delete |
| 312 | + transaction_type (str, optional): Transaction type of the contract to delete |
312 | 313 |
|
313 | 314 | Raises: |
314 | 315 | TypeError: with bad parameter types |
315 | 316 |
|
316 | 317 | Returns: |
317 | 318 | The results of the delete request |
318 | 319 | """ |
319 | | - if not isinstance(smart_contract_id, str): |
320 | | - raise TypeError('Parameter "state" must be of type str.') |
321 | | - return self.request.delete("/v1/contract/{}".format(smart_contract_id)) |
| 320 | + if smart_contract_id and transaction_type: |
| 321 | + raise TypeError('Only one of "smart_contract_id" or "transaction_type" can be specified') |
| 322 | + if smart_contract_id and not isinstance(smart_contract_id, str): |
| 323 | + raise TypeError('Parameter "smart_contract_id" must be of type str.') |
| 324 | + if transaction_type and not isinstance(transaction_type, str): |
| 325 | + raise TypeError('Parameter "transaction_type" must be of type str.') |
| 326 | + if smart_contract_id: |
| 327 | + return self.request.delete("/v1/contract/{}".format(smart_contract_id)) |
| 328 | + if transaction_type: |
| 329 | + return self.request.delete("/v1/contract/txn_type/{}".format(transaction_type)) |
| 330 | + raise TypeError('At least one of "smart_contract_id" or "transaction_type" must be supplied') |
322 | 331 |
|
323 | 332 | def query_transactions( |
324 | 333 | self, |
@@ -1178,6 +1187,30 @@ def get_default_interchain_network(self) -> "request_response": |
1178 | 1187 | """ |
1179 | 1188 | return self.request.get("/v1/interchains/default") |
1180 | 1189 |
|
| 1190 | + def publish_interchain_transaction(self, blockchain: str, name: str, signed_transaction: str) -> "request_response": |
| 1191 | + """Publish an interchain transaction that's already been signed |
| 1192 | +
|
| 1193 | + Args: |
| 1194 | + blockchain (str): The blockchain type to set (i.e. 'bitcoin', 'ethereum') |
| 1195 | + name (str): The name of the that blockchain's network to use (set when creating the network) |
| 1196 | + signed_transaction (str): Signed transaction string (return from sign_<network>_transaction function) |
| 1197 | +
|
| 1198 | + Raises: |
| 1199 | + TypeError: with bad parameter type |
| 1200 | +
|
| 1201 | + Returns: |
| 1202 | + The transaction hash (or equivalent) of the published transaction |
| 1203 | + """ |
| 1204 | + if not isinstance(blockchain, str): |
| 1205 | + raise TypeError('Parameter "blockchain" must be of type str.') |
| 1206 | + if not isinstance(name, str): |
| 1207 | + raise TypeError('Parameter "name" must be of type str.') |
| 1208 | + if not isinstance(signed_transaction, str): |
| 1209 | + raise TypeError('Parameter "signed_transaction" must be of type str.') |
| 1210 | + return self.request.post( |
| 1211 | + "/v1/interchains/transaction/publish", {"version": "1", "blockchain": blockchain, "name": name, "signed_txn": signed_transaction} |
| 1212 | + ) |
| 1213 | + |
1181 | 1214 | def create_bitcoin_transaction( |
1182 | 1215 | self, |
1183 | 1216 | network: str, |
|
0 commit comments