diff --git a/algosdk/algod.py b/algosdk/algod.py index 2cf6de32..0b1f9529 100644 --- a/algosdk/algod.py +++ b/algosdk/algod.py @@ -1,14 +1,13 @@ -from urllib.request import Request, urlopen -from urllib import parse -import urllib.error -import json import base64 +import json +import urllib.error +import warnings +from urllib import parse +from urllib.request import Request, urlopen + import msgpack -from . import error -from . import encoding -from . import constants -from . import transaction -from . import future + +from . import constants, encoding, error, future from .v2client.algod import _specify_round_string api_version_path_prefix = "/v1" @@ -16,6 +15,10 @@ class AlgodClient: """ + NOTE: This class is deprecated: + v1 algod APIs are deprecated. + Please use the v2 equivalent in `v2client.algod` instead. + Client class for kmd. Handles all algod requests. Args: @@ -30,6 +33,11 @@ class AlgodClient: """ def __init__(self, algod_token, algod_address, headers=None): + warnings.warn( + "`AlgodClient` is a part of v1 algod APIs that is deprecated. " + "Please use the v2 equivalent in `v2client.algod` instead.", + DeprecationWarning, + ) self.algod_token = algod_token self.algod_address = algod_address self.headers = headers diff --git a/algosdk/encoding.py b/algosdk/encoding.py index 2edbb9a5..26b180f8 100644 --- a/algosdk/encoding.py +++ b/algosdk/encoding.py @@ -1,8 +1,11 @@ import base64 -import msgpack +import warnings from collections import OrderedDict + +import msgpack from Cryptodome.Hash import SHA512 -from . import transaction, error, auction, constants, future + +from . import auction, constants, error, future, transaction def msgpack_encode(obj): @@ -94,6 +97,9 @@ def future_msgpack_decode(enc): def msgpack_decode(enc): """ + NOTE: This method is deprecated: + Please use `future_msgpack_decode` instead. + Decode a msgpack encoded object from a string. Args: @@ -103,6 +109,11 @@ def msgpack_decode(enc): Transaction, SignedTransaction, Multisig, Bid, or SignedBid:\ decoded object """ + warnings.warn( + "`msgpack_decode` is being deprecated. " + "Please use `future_msgpack_decode` instead.", + DeprecationWarning, + ) decoded = enc if not isinstance(enc, dict): decoded = msgpack.unpackb(base64.b64decode(enc), raw=False) diff --git a/algosdk/future/transaction.py b/algosdk/future/transaction.py index c26c0cc6..ab3e1cd7 100644 --- a/algosdk/future/transaction.py +++ b/algosdk/future/transaction.py @@ -1,18 +1,16 @@ -from typing import List, Union import base64 import binascii +import warnings +from collections import OrderedDict from enum import IntEnum +from typing import List, Union + import msgpack -from collections import OrderedDict -from .. import account -from .. import constants -from .. import encoding -from .. import error -from .. import logic -from .. import transaction -from ..v2client import algod, models -from nacl.signing import SigningKey, VerifyKey from nacl.exceptions import BadSignatureError +from nacl.signing import SigningKey, VerifyKey + +from .. import account, constants, encoding, error, logic, transaction +from ..v2client import algod, models class SuggestedParams: @@ -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): + warnings.warn( + "You are trying to check equality of an older `transaction` " + " format that is being deprecated. " + "Please use the v2 equivalent in `future.transaction` instead.", + DeprecationWarning, + ) return ( self.sender == other.sender and self.fee == other.fee diff --git a/algosdk/kmd.py b/algosdk/kmd.py index efa661d5..0d06bb68 100644 --- a/algosdk/kmd.py +++ b/algosdk/kmd.py @@ -1,12 +1,10 @@ -from urllib.request import Request, urlopen -from urllib import parse -import urllib.error -import json import base64 -from . import encoding -from . import error -from . import transaction -from . import constants +import json +import urllib.error +from urllib import parse +from urllib.request import Request, urlopen + +from . import constants, encoding, error, future api_version_path_prefix = "/v1" @@ -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( result["multisig_version"], result["threshold"], pks ) return msig diff --git a/algosdk/template.py b/algosdk/template.py index 9ef92e74..59890510 100644 --- a/algosdk/template.py +++ b/algosdk/template.py @@ -6,6 +6,10 @@ class Template: + """ + NOTE: This class is deprecated + """ + def get_address(self): """ Return the address of the contract. @@ -18,6 +22,8 @@ def get_program(self): class Split(Template): """ + NOTE: This class is deprecated + Split allows locking algos in an account which allows transfering to two predefined addresses in a specified ratio such that for the given ratn and ratd parameters we have: @@ -164,6 +170,8 @@ def get_split_funds_transaction( class HTLC(Template): """ + NOTE: This class is deprecated + Hash Time Locked Contract allows a user to recieve the Algo prior to a deadline (in terms of a round) by proving knowledge of a special value or to forfeit the ability to claim, returning it to the payer. @@ -433,6 +441,8 @@ def sign_dynamic_fee(self, private_key, gh): class PeriodicPayment(Template): """ + NOTE: This class is deprecated + PeriodicPayment contract enables creating an account which allows the withdrawal of a fixed amount of assets every fixed number of rounds to a specific Algrorand Address. In addition, the contract allows to add @@ -543,6 +553,8 @@ def get_withdrawal_transaction(contract, first_valid, gh, fee): class LimitOrder(Template): """ + NOTE: This class is deprecated + Limit Order allows to trade Algos for other assets given a specific ratio; for N Algos, swap for Rate * N Assets. diff --git a/algosdk/transaction.py b/algosdk/transaction.py index f6389a6d..bec36028 100644 --- a/algosdk/transaction.py +++ b/algosdk/transaction.py @@ -1,19 +1,20 @@ import base64 -import msgpack import binascii +import warnings from collections import OrderedDict -from . import account -from . import constants -from . import encoding -from . import error -from . import logic -from . import future -from nacl.signing import SigningKey, VerifyKey + +import msgpack from nacl.exceptions import BadSignatureError +from nacl.signing import SigningKey, VerifyKey + +from . import account, constants, encoding, error, future, logic class Transaction: """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Superclass for various transaction types. """ @@ -30,6 +31,11 @@ def __init__( txn_type, rekey_to, ): + warnings.warn( + "`Transaction` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) self.sender = sender self.fee = fee self.first_valid_round = first @@ -52,6 +58,9 @@ def __init__( def get_txid(self): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Get the transaction's ID. Returns: @@ -65,6 +74,9 @@ def get_txid(self): def sign(self, private_key): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Sign the transaction with a private key. Args: @@ -83,6 +95,9 @@ def sign(self, private_key): def raw_sign(self, private_key): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Sign the transaction. Args: @@ -100,11 +115,19 @@ def raw_sign(self, private_key): return sig def estimate_size(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ sk, _ = account.generate_account() stx = self.sign(sk) return len(base64.b64decode(encoding.msgpack_encode(stx))) def dictify(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ d = dict() if self.fee: d["fee"] = self.fee @@ -129,6 +152,10 @@ def dictify(self): @staticmethod def undictify(d): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ args = { "sender": encoding.encode_address(d["snd"]), "fee": d["fee"] if "fee" in d else 0, @@ -166,6 +193,10 @@ def undictify(d): return txn def __eq__(self, other): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ if not isinstance( other, (Transaction, future.transaction.Transaction) ): @@ -187,6 +218,9 @@ def __eq__(self, other): class PaymentTxn(Transaction): """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Represents a payment transaction. Args: @@ -310,6 +344,9 @@ def __eq__(self, other): class KeyregTxn(Transaction): """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Represents a key registration transaction. Args: @@ -432,6 +469,9 @@ def __eq__(self, other): class AssetConfigTxn(Transaction): """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Represents a transaction for asset creation, reconfiguration, or destruction. @@ -709,6 +749,9 @@ def __eq__(self, other): class AssetFreezeTxn(Transaction): """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Represents a transaction for freezing or unfreezing an account's asset holdings. Must be issued by the asset's freeze manager. @@ -825,6 +868,9 @@ def __eq__(self, other): class AssetTransferTxn(Transaction): """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Represents a transaction for asset transfer. To begin accepting an asset, supply the same address as both sender and receiver, and set amount to 0. @@ -977,6 +1023,9 @@ def __eq__(self, other): class SignedTransaction: """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Represents a signed transaction. Args: @@ -991,11 +1040,24 @@ class SignedTransaction: """ def __init__(self, transaction, signature, authorizing_address=None): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ + warnings.warn( + "`SignedTransaction` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) self.signature = signature self.transaction = transaction self.authorizing_address = authorizing_address def dictify(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ od = OrderedDict() if self.signature: od["sig"] = base64.b64decode(self.signature) @@ -1006,6 +1068,10 @@ def dictify(self): @staticmethod def undictify(d): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ sig = None if "sig" in d: sig = base64.b64encode(d["sig"]).decode() @@ -1017,6 +1083,10 @@ def undictify(d): return stx def __eq__(self, other): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ if not isinstance( other, (SignedTransaction, future.transaction.SignedTransaction) ): @@ -1030,6 +1100,9 @@ def __eq__(self, other): class MultisigTransaction: """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Represents a signed transaction. Args: @@ -1042,11 +1115,23 @@ class MultisigTransaction: """ def __init__(self, transaction, multisig): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ + warnings.warn( + "`MultisigTransaction` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) self.transaction = transaction self.multisig = multisig def sign(self, private_key): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Sign the multisig transaction. Args: @@ -1076,6 +1161,10 @@ def sign(self, private_key): self.multisig.subsigs[index].signature = sig def dictify(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ od = OrderedDict() if self.multisig: od["msig"] = self.multisig.dictify() @@ -1084,6 +1173,10 @@ def dictify(self): @staticmethod def undictify(d): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ msig = None if "msig" in d: msig = Multisig.undictify(d["msig"]) @@ -1094,6 +1187,9 @@ def undictify(d): @staticmethod def merge(part_stxs): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Merge partially signed multisig transactions. Args: @@ -1133,6 +1229,10 @@ def merge(part_stxs): return msigstx def __eq__(self, other): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ if not isinstance( other, (MultisigTransaction, future.transaction.MultisigTransaction), @@ -1146,6 +1246,9 @@ def __eq__(self, other): class Multisig: """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Represents a multisig account and signatures. Args: @@ -1160,6 +1263,15 @@ class Multisig: """ def __init__(self, version, threshold, addresses): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ + warnings.warn( + "`Multisig` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) self.version = version self.threshold = threshold self.subsigs = [] @@ -1167,7 +1279,12 @@ def __init__(self, version, threshold, addresses): self.subsigs.append(MultisigSubsig(encoding.decode_address(a))) def validate(self): - """Check if the multisig account is valid.""" + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + + Check if the multisig account is valid. + """ if not self.version == 1: raise error.UnknownMsigVersionError if ( @@ -1180,7 +1297,12 @@ def validate(self): raise error.MultisigAccountSizeError def address(self): - """Return the multisig account address.""" + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + + Return the multisig account address. + """ msig_bytes = ( bytes(constants.msig_addr_prefix, "utf-8") + bytes([self.version]) @@ -1192,7 +1314,12 @@ def address(self): return encoding.encode_address(addr) def verify(self, message): - """Verify that the multisig is valid for the message.""" + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + + Verify that the multisig is valid for the message. + """ try: self.validate() except (error.UnknownMsigVersionError, error.InvalidThresholdError): @@ -1217,6 +1344,10 @@ def verify(self, message): return True def dictify(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ od = OrderedDict() od["subsig"] = [subsig.dictify() for subsig in self.subsigs] od["thr"] = self.threshold @@ -1224,6 +1355,10 @@ def dictify(self): return od def json_dictify(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ d = { "subsig": [subsig.json_dictify() for subsig in self.subsigs], "thr": self.threshold, @@ -1233,12 +1368,20 @@ def json_dictify(self): @staticmethod def undictify(d): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ subsigs = [MultisigSubsig.undictify(s) for s in d["subsig"]] msig = Multisig(d["v"], d["thr"], []) msig.subsigs = subsigs return msig def get_multisig_account(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ """Return a Multisig object without signatures.""" msig = Multisig(self.version, self.threshold, self.get_public_keys()) for s in msig.subsigs: @@ -1246,11 +1389,19 @@ def get_multisig_account(self): return msig def get_public_keys(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ """Return the base32 encoded addresses for the multisig account.""" pks = [encoding.encode_address(s.public_key) for s in self.subsigs] return pks def __eq__(self, other): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ if not isinstance(other, (Multisig, future.transaction.Multisig)): return False return ( @@ -1262,16 +1413,32 @@ def __eq__(self, other): class MultisigSubsig: """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Attributes: public_key (bytes) signature (bytes) """ def __init__(self, public_key, signature=None): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ + warnings.warn( + "`MultisigSubsig` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) self.public_key = public_key self.signature = signature def dictify(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ od = OrderedDict() od["pk"] = self.public_key if self.signature: @@ -1279,6 +1446,10 @@ def dictify(self): return od def json_dictify(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ d = {"pk": base64.b64encode(self.public_key).decode()} if self.signature: d["s"] = base64.b64encode(self.signature).decode() @@ -1286,6 +1457,10 @@ def json_dictify(self): @staticmethod def undictify(d): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ sig = None if "s" in d: sig = d["s"] @@ -1293,6 +1468,10 @@ def undictify(d): return mss def __eq__(self, other): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ if not isinstance( other, (MultisigSubsig, future.transaction.MultisigSubsig) ): @@ -1305,6 +1484,9 @@ def __eq__(self, other): class LogicSig: """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Represents a logic signature. Arguments: @@ -1319,6 +1501,15 @@ class LogicSig: """ def __init__(self, program, args=None): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ + warnings.warn( + "`LogicSig` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) self._sanity_check_program(program) self.logic = program self.args = args @@ -1328,6 +1519,9 @@ def __init__(self, program, args=None): @staticmethod def _sanity_check_program(program): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Performs heuristic program validation: check if passed in bytes are Algorand address, or they are B64 encoded, rather than Teal bytes @@ -1368,6 +1562,10 @@ def is_ascii_printable(program_bytes): ) def dictify(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ od = OrderedDict() if self.args: od["arg"] = self.args @@ -1380,6 +1578,10 @@ def dictify(self): @staticmethod def undictify(d): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ lsig = LogicSig(d["l"], d.get("arg", None)) if "sig" in d: lsig.sig = base64.b64encode(d["sig"]).decode() @@ -1389,6 +1591,9 @@ def undictify(d): def verify(self, public_key): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Verifies LogicSig against the transaction's sender address Args: @@ -1425,6 +1630,9 @@ def verify(self, public_key): def address(self): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Compute hash of the logic sig program (that is the same as escrow account address) as string address @@ -1435,6 +1643,10 @@ def address(self): @staticmethod def sign_program(program, private_key): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ private_key = base64.b64decode(private_key) signing_key = SigningKey(private_key[: constants.key_len_bytes]) to_sign = constants.logic_prefix + program @@ -1443,6 +1655,10 @@ def sign_program(program, private_key): @staticmethod def single_sig_multisig(program, private_key, multisig): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ index = -1 public_key = base64.b64decode(bytes(private_key, "utf-8")) public_key = public_key[constants.key_len_bytes :] @@ -1458,6 +1674,9 @@ def single_sig_multisig(program, private_key, multisig): def sign(self, private_key, multisig=None): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Creates signature (if no pk provided) or multi signature Args: @@ -1469,7 +1688,6 @@ def sign(self, private_key, multisig=None): InvalidSecretKeyError: if no matching private key in multisig\ object """ - if not multisig: self.sig = LogicSig.sign_program(self.logic, private_key) else: @@ -1481,6 +1699,9 @@ def sign(self, private_key, multisig=None): def append_to_multisig(self, private_key): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Appends a signature to multi signature Args: @@ -1490,7 +1711,6 @@ def append_to_multisig(self, private_key): InvalidSecretKeyError: if no matching private key in multisig\ object """ - if self.msig is None: raise error.InvalidSecretKeyError sig, index = LogicSig.single_sig_multisig( @@ -1499,6 +1719,10 @@ def append_to_multisig(self, private_key): self.msig.subsigs[index].signature = base64.b64decode(sig) def __eq__(self, other): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ if not isinstance(other, (LogicSig, future.transaction.LogicSig)): return False return ( @@ -1511,6 +1735,9 @@ def __eq__(self, other): class LogicSigTransaction: """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + Represents a logic signed transaction. Arguments: @@ -1523,11 +1750,23 @@ class LogicSigTransaction: """ def __init__(self, transaction, lsig): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ + warnings.warn( + "`LogicSigTransaction` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) self.transaction = transaction self.lsig = lsig def verify(self): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Verify LogicSig against the transaction Returns: @@ -1539,6 +1778,10 @@ def verify(self): return self.lsig.verify(public_key) def dictify(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ od = OrderedDict() if self.lsig: od["lsig"] = self.lsig.dictify() @@ -1547,6 +1790,10 @@ def dictify(self): @staticmethod def undictify(d): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ lsig = None if "lsig" in d: lsig = LogicSig.undictify(d["lsig"]) @@ -1555,6 +1802,10 @@ def undictify(d): return lstx def __eq__(self, other): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ if not isinstance( other, (LogicSigTransaction, future.transaction.LogicSigTransaction), @@ -1567,6 +1818,9 @@ def __eq__(self, other): def write_to_file(objs, path, overwrite=True): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Write signed or unsigned transactions to a file. Args: @@ -1590,7 +1844,11 @@ def write_to_file(objs, path, overwrite=True): Returns: bool: true if the transactions have been written to the file """ - + warnings.warn( + "`write_to_file` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) f = None if overwrite: f = open(path, "wb") @@ -1613,6 +1871,9 @@ def write_to_file(objs, path, overwrite=True): def retrieve_from_file(path): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Retrieve encoded objects from a file. Args: @@ -1621,7 +1882,11 @@ def retrieve_from_file(path): Returns: Object[]: list of objects """ - + warnings.warn( + "`retrieve_from_file` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) f = open(path, "rb") objs = [] unp = msgpack.Unpacker(f, raw=False) @@ -1632,7 +1897,21 @@ def retrieve_from_file(path): class TxGroup: + """ + NOTE: This class is deprecated: + Please use the equivalent in `future.transaction` instead. + """ + def __init__(self, txns): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ + warnings.warn( + "`TxGroup` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) assert isinstance(txns, list) """ Transactions specifies a list of transactions that must appear @@ -1645,18 +1924,29 @@ def __init__(self, txns): self.transactions = txns def dictify(self): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ od = OrderedDict() od["txlist"] = self.transactions return od @staticmethod def undictify(d): + """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + """ txg = TxGroup(d["txlist"]) return txg def calculate_group_id(txns): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Calculate group id for a given list of unsigned transactions Args: @@ -1665,6 +1955,11 @@ def calculate_group_id(txns): Returns: bytes: checksum value representing the group id """ + warnings.warn( + "`calculate_group_id` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) if len(txns) > constants.tx_group_limit: raise error.TransactionGroupSizeError txids = [] @@ -1683,6 +1978,9 @@ def calculate_group_id(txns): def assign_group_id(txns, address=None): """ + NOTE: This method is deprecated: + Please use the equivalent in `future.transaction` instead. + Assign group id to a given list of unsigned transactions. Args: @@ -1693,6 +1991,11 @@ def assign_group_id(txns, address=None): Returns: txns (list): list of unsigned transactions with group property set """ + warnings.warn( + "`assign_group_id` is a part of an older `transaction` format that is being deprecated. " + "Please use the equivalent in `future.transaction` instead.", + DeprecationWarning, + ) if len(txns) > constants.tx_group_limit: raise error.TransactionGroupSizeError gid = calculate_group_id(txns)