Skip to content
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
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:
run: |
poetry run pytest --doctest-modules --ignore=examples --cov=pycardano --cov-config=.coveragerc --cov-report=xml
- name: "Upload coverage to Codecov"
if: ${{ matrix.python-version == '3.11' }}
if: ${{ matrix.python-version == '3.13' }}
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN || '' }}
- name: Run static analyses
if: ${{ matrix.python-version == '3.11' }}
if: ${{ matrix.python-version == '3.13' }}
run: |
make qa

Expand All @@ -47,7 +47,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.11']
python-version: ['3.13']

steps:
- uses: actions/checkout@v4
Expand All @@ -69,7 +69,7 @@ jobs:
cd integration-test && ./run_tests.sh

- name: "Upload coverage to Codecov"
if: ${{ matrix.python-version == '3.11' }}
if: ${{ matrix.python-version == '3.13' }}
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
Expand Down
6 changes: 2 additions & 4 deletions examples/raw_multi_asset_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@
tx_body = TransactionBody(inputs=[tx_in], outputs=[output1, output2], fee=165897)

# Create signing key from a secret json file
sk = PaymentSigningKey.from_json(
"""{
sk = PaymentSigningKey.from_json("""{
"type": "GenesisUTxOSigningKey_ed25519",
"description": "Genesis Initial UTxO Signing Key",
"cborHex": "5820093be5cd3987d0c9fd8854ef908f7746b69e2d73320db6dc0f780d81585b84c2"
}"""
)
}""")

# Derive a verification key from the signing key
vk = PaymentVerificationKey.from_signing_key(sk)
Expand Down
6 changes: 2 additions & 4 deletions examples/raw_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
tx_body = TransactionBody(inputs=[tx_in], outputs=[output1, output2], fee=165897)

# Create signing key from a secret json file
sk = PaymentSigningKey.from_json(
"""{
sk = PaymentSigningKey.from_json("""{
"type": "GenesisUTxOSigningKey_ed25519",
"description": "Genesis Initial UTxO Signing Key",
"cborHex": "5820093be5cd3987d0c9fd8854ef908f7746b69e2d73320db6dc0f780d81585b84c2"
}"""
)
}""")

# Derive a verification key from the signing key
vk = PaymentVerificationKey.from_signing_key(sk)
Expand Down
2,007 changes: 1,053 additions & 954 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pycardano/crypto/bech32.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

"""Reference implementation for Bech32/Bech32m and segwit addresses."""


from enum import Enum


Expand Down
4 changes: 2 additions & 2 deletions pycardano/crypto/bip32.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def _derive_private_child_key_by_index(

"""
# unpack argument
(kLP, kRP, AP, cP, path) = private_pnode
kLP, kRP, AP, cP, path = private_pnode
assert 0 <= index < 2**32

i_bytes = index.to_bytes(4, "little")
Expand Down Expand Up @@ -457,7 +457,7 @@ def _derive_public_child_key_by_index(
HDWallet with child node derived.
"""
# unpack argument
(AP, cP, path) = public_pnode
AP, cP, path = public_pnode
assert 0 <= index < 2**32

i_bytes = index.to_bytes(4, "little")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pytest = ">=8.2.0"
pytest-cov = ">=5.0.0"
flake8 = ">=7.0.0"
isort = ">=5.11.4"
black = ">=24.4.2"
black = {version = ">=26.1.0", python = ">=3.10"}
sphinx-copybutton = ">=0.5.0"
retry = ">=0.9.2"
Flask = ">=2.0.3"
Expand Down
6 changes: 2 additions & 4 deletions test/pycardano/test_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@


def test_payment_addr():
vk = PaymentVerificationKey.from_json(
"""{
vk = PaymentVerificationKey.from_json("""{
"type": "GenesisUTxOVerificationKey_ed25519",
"description": "Genesis Initial UTxO Verification Key",
"cborHex": "58208be8339e9f3addfa6810d59e2f072f85e64d4c024c087e0d24f8317c6544f62f"
}"""
)
}""")
assert (
Address(vk.hash(), network=Network.TESTNET).encode()
== "addr_test1vr2p8st5t5cxqglyjky7vk98k7jtfhdpvhl4e97cezuhn0cqcexl7"
Expand Down
36 changes: 12 additions & 24 deletions test/pycardano/test_cip8.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,42 @@
)
from pycardano.network import Network

EXTENDED_SK = ExtendedSigningKey.from_json(
"""{
EXTENDED_SK = ExtendedSigningKey.from_json("""{
"type": "PaymentExtendedSigningKeyShelley_ed25519_bip32",
"description": "Payment Signing Key",
"cborHex": "5880e8428867ab9cc9304379a3ce0c238a592bd6d2349d2ebaf8a6ed2c6d2974a15ad59c74b6d8fa3edd032c6261a73998b7deafe983b6eeaff8b6fb3fab06bdf8019b693a62bce7a3cad1b9c02d22125767201c65db27484bb67d3cee7df7288d62c099ac0ce4a215355b149fd3114a2a7ef0438f01f8872c4487a61b469e26aae4"
}"""
)
}""")

EXTENDED_VK = ExtendedVerificationKey.from_json(
"""{
EXTENDED_VK = ExtendedVerificationKey.from_json("""{
"type": "PaymentExtendedVerificationKeyShelley_ed25519_bip32",
"description": "Payment Verification Key",
"cborHex": "58409b693a62bce7a3cad1b9c02d22125767201c65db27484bb67d3cee7df7288d62c099ac0ce4a215355b149fd3114a2a7ef0438f01f8872c4487a61b469e26aae4"
}"""
)
}""")


SK = PaymentSigningKey.from_json(
"""{
SK = PaymentSigningKey.from_json("""{
"type": "GenesisUTxOSigningKey_ed25519",
"description": "Genesis Initial UTxO Signing Key",
"cborHex": "5820093be5cd3987d0c9fd8854ef908f7746b69e2d73320db6dc0f780d81585b84c2"
}"""
)
}""")

VK = PaymentVerificationKey.from_json(
"""{
VK = PaymentVerificationKey.from_json("""{
"type": "GenesisUTxOVerificationKey_ed25519",
"description": "Genesis Initial UTxO Verification Key",
"cborHex": "58208be8339e9f3addfa6810d59e2f072f85e64d4c024c087e0d24f8317c6544f62f"
}"""
)
}""")

STAKE_SK = StakeSigningKey.from_json(
"""{
STAKE_SK = StakeSigningKey.from_json("""{
"type": "StakeSigningKeyShelley_ed25519",
"description": "Stake Signing Key",
"cborHex": "5820ff3a330df8859e4e5f42a97fcaee73f6a00d0cf864f4bca902bd106d423f02c0"
}"""
)
}""")

STAKE_VK = StakeVerificationKey.from_json(
"""{
STAKE_VK = StakeVerificationKey.from_json("""{
"type": "StakeVerificationKeyShelley_ed25519",
"description": "Stake Verification Key",
"cborHex": "58205edaa384c658c2bd8945ae389edac0a5bd452d0cfd5d1245e3ecd540030d1e3c"
}"""
)
}""")


def test_verify_message():
Expand Down
36 changes: 12 additions & 24 deletions test/pycardano/test_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,41 @@
StakePoolVerificationKey,
)

SK = PaymentSigningKey.from_json(
"""{
SK = PaymentSigningKey.from_json("""{
"type": "GenesisUTxOSigningKey_ed25519",
"description": "Genesis Initial UTxO Signing Key",
"cborHex": "5820093be5cd3987d0c9fd8854ef908f7746b69e2d73320db6dc0f780d81585b84c2"
}"""
)
}""")

VK = PaymentVerificationKey.from_json(
"""{
VK = PaymentVerificationKey.from_json("""{
"type": "GenesisUTxOVerificationKey_ed25519",
"description": "Genesis Initial UTxO Verification Key",
"cborHex": "58208be8339e9f3addfa6810d59e2f072f85e64d4c024c087e0d24f8317c6544f62f"
}"""
)
}""")

SPSK = StakePoolSigningKey.from_json(
"""{
SPSK = StakePoolSigningKey.from_json("""{
"type": "StakePoolSigningKey_ed25519",
"description": "StakePoolSigningKey_ed25519",
"cborHex": "582044181bd0e6be21cea5b0751b8c6d4f88a5cb2d5dfec31a271add617f7ce559a9"
}"""
)
}""")

SPVK = StakePoolVerificationKey.from_json(
"""{
SPVK = StakePoolVerificationKey.from_json("""{
"type": "StakePoolVerificationKey_ed25519",
"description": "StakePoolVerificationKey_ed25519",
"cborHex": "5820354ce32da92e7116f6c70e9be99a3a601d33137d0685ab5b7e2ff5b656989299"
}"""
)
}""")

EXTENDED_SK = ExtendedSigningKey.from_json(
"""{
EXTENDED_SK = ExtendedSigningKey.from_json("""{
"type": "PaymentExtendedSigningKeyShelley_ed25519_bip32",
"description": "Payment Signing Key",
"cborHex": "5880e8428867ab9cc9304379a3ce0c238a592bd6d2349d2ebaf8a6ed2c6d2974a15ad59c74b6d8fa3edd032c6261a73998b7deafe983b6eeaff8b6fb3fab06bdf8019b693a62bce7a3cad1b9c02d22125767201c65db27484bb67d3cee7df7288d62c099ac0ce4a215355b149fd3114a2a7ef0438f01f8872c4487a61b469e26aae4"
}"""
)
}""")

EXTENDED_VK = ExtendedVerificationKey.from_json(
"""{
EXTENDED_VK = ExtendedVerificationKey.from_json("""{
"type": "PaymentExtendedVerificationKeyShelley_ed25519_bip32",
"description": "Payment Verification Key",
"cborHex": "58409b693a62bce7a3cad1b9c02d22125767201c65db27484bb67d3cee7df7288d62c099ac0ce4a215355b149fd3114a2a7ef0438f01f8872c4487a61b469e26aae4"
}"""
)
}""")


def test_invalid_key_type():
Expand Down
6 changes: 2 additions & 4 deletions test/pycardano/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,11 @@ def test_full_tx():

def test_transaction():
tx_body = make_transaction_body()
sk = PaymentSigningKey.from_json(
"""{
sk = PaymentSigningKey.from_json("""{
"type": "GenesisUTxOSigningKey_ed25519",
"description": "Genesis Initial UTxO Signing Key",
"cborHex": "5820093be5cd3987d0c9fd8854ef908f7746b69e2d73320db6dc0f780d81585b84c2"
}"""
)
}""")
vk = VerificationKey(PaymentKeyPair.from_signing_key(sk).verification_key.payload)
signature = sk.sign(tx_body.hash())
assert (
Expand Down