-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Any, Dict, Optional, Protocol | ||
|
||
from multiversx_sdk_network_providers import GenericError, ProxyNetworkProvider | ||
Check failure on line 3 in multiversx_sdk_cli/custom_network_provider.py GitHub Actions / runner / mypy
|
||
|
||
from multiversx_sdk_cli.errors import ProxyError | ||
from multiversx_sdk_cli.interfaces import ISimulateResponse, ITransaction | ||
|
||
|
||
class ITransactionOnNetwork(Protocol): | ||
hash: str | ||
is_completed: Optional[bool] | ||
|
||
def to_dictionary(self) -> Dict[str, Any]: | ||
... | ||
|
||
|
||
class CustomNetworkProvider: | ||
def __init__(self, url: str) -> None: | ||
self._provider = ProxyNetworkProvider(url) | ||
|
||
def send_transaction(self, transaction: ITransaction) -> str: | ||
try: | ||
hash = self._provider.send_transaction(transaction) | ||
return hash | ||
Check failure on line 24 in multiversx_sdk_cli/custom_network_provider.py GitHub Actions / runner / mypy
|
||
except GenericError as ge: | ||
url = ge.url | ||
message = ge.data.get("error", "") | ||
data = ge.data.get("data", "") | ||
code = ge.data.get("code", "") | ||
raise ProxyError(message, url, data, code) | ||
|
||
def get_transaction(self, tx_hash: str, with_process_status: Optional[bool] = False) -> ITransactionOnNetwork: | ||
return self._provider.get_transaction(tx_hash, with_process_status) | ||
Check failure on line 33 in multiversx_sdk_cli/custom_network_provider.py GitHub Actions / runner / mypy
|
||
|
||
def simulate_transaction(self, transaction: ITransaction) -> ISimulateResponse: | ||
return self._provider.simulate_transaction(transaction) | ||
Check failure on line 36 in multiversx_sdk_cli/custom_network_provider.py GitHub Actions / runner / mypy
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters