Skip to content

Comments

Multisig transactions factory#231

Merged
popenta merged 7 commits intofeat/nextfrom
multisig-transactions-factory
Apr 29, 2025
Merged

Multisig transactions factory#231
popenta merged 7 commits intofeat/nextfrom
multisig-transactions-factory

Conversation

@popenta
Copy link
Collaborator

@popenta popenta commented Apr 15, 2025

No description provided.

@popenta popenta self-assigned this Apr 15, 2025
@github-actions
Copy link

github-actions bot commented Apr 15, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  multiversx_sdk
  __init__.py
  multiversx_sdk/abi
  code_metadata_value.py
  variadic_values.py
  multiversx_sdk/multisig
  __init__.py
  multisig_transactions_factory.py 225, 275, 286, 314, 350-363, 417, 457, 480
  resources.py 20-23, 67, 70
  multiversx_sdk/smart_contracts
  smart_contract_transactions_factory.py 199, 223
Project Total  

This report was generated by python-coverage-comment-action


class MultisigTransactionsFactory:
def __init__(self, config: TransactionsFactoryConfig, abi: Optional[Abi] = None) -> None:
self._sc_factory = SmartContractTransactionsFactory(config, abi)
Copy link
Contributor

Choose a reason for hiding this comment

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

To be decided - can be either inheritance or composition, but we should stick to the same choice in both JS and PY.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We've decided to go with inheritance, but as we've seen, that is not really possible here. Added the workaround discussed, to simply add the create_transaction_for_execute method from the SmartContractTransactionsFactory.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the controllers, don't forget to also "export" query().

function: Optional[str] = None,
arguments: Optional[list[Any]] = None,
) -> Transaction:
if not function:
Copy link
Contributor

Choose a reason for hiding this comment

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

Slightly different from JS (regarding the named constructors of ProposeTransferExecuteContractInput) - if possible, we should have similar implementations.

https://github.com/multiversx/mx-sdk-js-core/blob/TOOL-329-add-mustisig-factory/src/multisig/multisigTransactionsFactory.ts#L137

Also - naming ProposeTransferExecuteContractInput (JS) vs. ProposeTransferExecuteInput (PY).

Though, which one to choose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, the parameters are the same. I'd go for ProposeTransferExecuteInput.

TransferTransactionsFactory,
)


Copy link
Contributor

Choose a reason for hiding this comment

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

In JS, it seems there are no named constructors, and the corresponding logic is moved to the factories themselves.

https://github.com/multiversx/mx-sdk-js-core/blob/TOOL-329-add-mustisig-factory/src/multisig/resources.ts

Either way is fine, but perhaps we should have a similar implementation. I know it cannot be the same, of course (especially since the ABI components differ a bit).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved most of the logic out of the resources file.

pass


class EsdtTokenPayment(StructValue):
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work if we use a regular Python class (not a StructValue)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it does not if the abi is not provided

if is_list_of_typed_values(args):
return self.serializer.serialize_to_parts(args)

if all(isinstance(arg, bytes) for arg in args):
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the best fallback possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

indeed

@popenta popenta merged commit 315dcc1 into feat/next Apr 29, 2025
6 checks passed
@popenta popenta deleted the multisig-transactions-factory branch April 29, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants