-
Notifications
You must be signed in to change notification settings - Fork 36
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
Replace transaction class with the one from sdk-core #278
Conversation
@@ -9,6 +9,6 @@ semver | |||
requests-cache | |||
rich==13.3.4 | |||
|
|||
multiversx-sdk-core>=0.5.0 | |||
multiversx-sdk-core==0.6.0b1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good, we reference the release from feat/*, for now.
@@ -62,7 +62,7 @@ class IContractQueryResponse(Protocol): | |||
|
|||
|
|||
class SmartContract: | |||
def __init__(self, address: Optional[Address] = None, bytecode=None, metadata=None): | |||
def __init__(self, address: Optional[IAddress] = EmptyAddress(), bytecode=None, metadata=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think SmartContract
is the next in line, to be removed (replaced).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I don't know if we should do it now or wait for the sdk to be compliant with the specs.
transaction.signature = alice.sign_transaction(transaction) | ||
|
||
assert "0e69f27e24aba2f3b7a8842dc7e7c085a0bfb5b29112b258318eed73de9c8809889756f8afaa74c7b3c7ce20a028b68ba90466a249aaf999a1a78dcf7f4eb40c" == transaction.signature | ||
transaction = Transaction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these tests can be removed (the one with signing a transaction), since we have them (most of the flow, at least) in sdk-core, as well. Can stay for now, but we can remove them in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, indeed. Will be removed in the future.
fields = json.loads(data_json).get("tx") or json.loads(data_json).get("emittedTransaction") | ||
|
||
instance = JSONTransaction() | ||
instance.__dict__.update(fields) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could have used Transaction.from_dictionary
?
https://github.com/multiversx/mx-sdk-py-core/blob/main/multiversx_sdk_core/transaction.py#L105
Then, we can remove JSONTransaction
as well, I think.
(for a future PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. I forgot we have that in sdk-core. Will be replaced in a future PR.
In this PR the class
BunchOfTransactions
has also been removed, as it was not used withinmxpy
.As some people were referencing
mxpy
as a package just to use this class, the following code is an alternative implementation to that class, that can be copied into your own project and used directly.