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

Deprecation: Add deprecation warnings on v1 algod API and old transaction format #381

Merged
merged 6 commits into from
Sep 16, 2022

Conversation

algochoi
Copy link
Contributor

@algochoi algochoi commented Sep 6, 2022

This PR adds deprecation warnings to v1 algod APIs and the old transaction format. In addition, there are warnings raised when the deprecated methods are called.

The PR also adds a deprecation comment to template - previously, a similar comment was put in for future.template.

The DeprecationWarning that is added to this PR and the langspec PR does trigger warnings on pytest (pytest tests/unit_tests). The corresponding tests should also be deleted when these features are removed from the SDK.

Related issue: algorand/algorand-sdk-testing#218

Get the transaction's ID.

Returns:
str: transaction ID
"""
warnings.warn(
Copy link
Contributor Author

@algochoi algochoi Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding warnings to each method might be pedantic (compared to just having a warning in the constructor and static methods) - in algod.py, only the constructor has a DeprecationWarning triggered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree warnings in each method is likely too much. If there's a warning in the constructor, that should be good enough in my opinion

@@ -6,6 +6,9 @@


class Template:
"""
NOTE: This class is deprecated
Copy link
Contributor Author

@algochoi algochoi Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: future.template already has a deprecation warning in the comments.

@algochoi algochoi changed the title Deprecate v1 algod API and old transaction format Deprecation: Add deprecation warnings on v1 algod API and old transaction format Sep 6, 2022
@@ -383,7 +381,7 @@ def export_multisig(self, handle, address):
result = self.kmd_request("POST", req, data=query)
pks = result["pks"]
pks = [encoding.encode_address(base64.b64decode(p)) for p in pks]
msig = transaction.Multisig(
msig = future.transaction.Multisig(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old and new Multisig should be the same - changed to used the new class in future here.

@@ -273,6 +271,13 @@ def undictify(d):
def __eq__(self, other):
if not isinstance(other, (Transaction, transaction.Transaction)):
return False
if isinstance(other, transaction.Transaction):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a warning for people who might try to compare the old Transaction object to a future.Transaction object

algosdk/transaction.py Outdated Show resolved Hide resolved
Copy link
Contributor

@ahangsu ahangsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally looking good to me

Copy link
Contributor

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly good, but I agree with your earlier comment that we may want to scale back the warnings in transaction methods

Get the transaction's ID.

Returns:
str: transaction ID
"""
warnings.warn(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree warnings in each method is likely too much. If there's a warning in the constructor, that should be good enough in my opinion

Copy link
Contributor

@ahangsu ahangsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment on lines +112 to +116
warnings.warn(
"`msgpack_decode` is being deprecated. "
"Please use `future_msgpack_decode` instead.",
DeprecationWarning,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have much objection here, just a minor question: since encode-decode is coupled, do we want to mark encode as deprecated? Or it is because of Transaction had a structural change (i.e., some new fields)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Serializing into msgpack is okay - the old Transaction and new Transaction can both be serialized into msgpack as long as the fields are ordered and can be represented by a key-value map/dict. Decoding msgpack into the old Transaction does not seem preferable, so marked it with the deprecation warning here.

@algochoi algochoi merged commit b53a53d into develop Sep 16, 2022
@algochoi algochoi deleted the deprecate-v1-apis branch September 16, 2022 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants