From bc8e840b39ec3d77d08f9ca69242ac650e0ffb8e Mon Sep 17 00:00:00 2001 From: Philip Vu Date: Wed, 20 Nov 2024 12:36:53 -0800 Subject: [PATCH] Removed strictness warnings with aip-80 parsing --- CHANGELOG.md | 3 +++ aptos_sdk/asymmetric_crypto.py | 9 ++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9d4fec..1d839c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to the Aptos Python SDK will be captured in this file. This ## Unreleased +- `PrivateKey.format_private_key` can now format a AIP-80 compliant private key +- Removed strictness warnnings for `PrivateKey.parse_hex_input` + ## 0.10.0 - Added support for deserialize RawTransactionWithData diff --git a/aptos_sdk/asymmetric_crypto.py b/aptos_sdk/asymmetric_crypto.py index 6486621..f2ee235 100644 --- a/aptos_sdk/asymmetric_crypto.py +++ b/aptos_sdk/asymmetric_crypto.py @@ -50,7 +50,10 @@ def format_private_key( key_value: str | None = None if isinstance(private_key, str): - key_value = private_key + if private_key.startswith(aip80_prefix): + key_value = private_key.split("-")[2] + else: + key_value = private_key elif isinstance(private_key, bytes): key_value = f"0x{private_key.hex()}" else: @@ -97,10 +100,6 @@ def parse_hex_input( ) raise ValueError("Invalid HexString input.") elif isinstance(value, bytes): - if strict is None: - print( - "It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)." - ) return value else: raise TypeError("Input value must be a string or bytes.")