Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix optional dependency import #182

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

- name: Store Pull Request comment to be posted
if: matrix.os == 'ubuntu-latest' && steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' # Run only on Ubuntu
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: python-coverage-comment-action
path: python-coverage-comment-action.txt
18 changes: 10 additions & 8 deletions multiversx_sdk/ledger/ledger_app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from enum import Enum

from ledgercomm import Transport

from multiversx_sdk.ledger.config import LedgerAppConfiguration
from multiversx_sdk.ledger.errors import LedgerError

Expand Down Expand Up @@ -29,25 +27,29 @@ class Apdu:

class LedgerApp:
def __init__(self) -> None:
try:
from ledgercomm import Transport
except ImportError as e:
raise ImportError(
"The ledgercomm package is not installed. Please install it using "
"pip install multiversx_sdk[ledger]."
) from e

try:
self.transport = Transport(interface="hid", debug=False) # Nano S/X using HID interface
except Exception:
raise LedgerError(CONNECTION_ERROR_MSG)

def set_address(self, address_index: int = 0):
data = DEFAULT_ACCOUNT_INDEX.to_bytes(4, byteorder="big") + address_index.to_bytes(
4, byteorder="big"
)
data = DEFAULT_ACCOUNT_INDEX.to_bytes(4, byteorder="big") + address_index.to_bytes(4, byteorder="big")
self.transport.send(cla=0xED, ins=0x05, p1=0x00, p2=0x00, cdata=data)
sw, _ = self.transport.recv()
err = get_error(sw)
if err != "":
raise LedgerError(err)

def get_address(self, address_index: int = 0) -> str:
data = DEFAULT_ACCOUNT_INDEX.to_bytes(4, byteorder="big") + address_index.to_bytes(
4, byteorder="big"
)
data = DEFAULT_ACCOUNT_INDEX.to_bytes(4, byteorder="big") + address_index.to_bytes(4, byteorder="big")

self.transport.send(cla=0xED, ins=0x03, p1=0x00, p2=0x00, cdata=data)
sw, response = self.transport.recv()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ allow-direct-references = true

[project]
name = "multiversx-sdk"
version = "1.0.0b0"
version = "1.0.0b1"
authors = [
{ name="MultiversX" },
]
Expand Down
Loading