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

feat: expose AtomicTransactionComposer.methodCalls #860

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

joe-p
Copy link
Contributor

@joe-p joe-p commented Mar 7, 2024

Makes AtomicTransactionComposer.methodCalls public. This is useful for modifying/retrieving the method calls in an ATC externally.

Specifically useful for algorandfoundation/algokit-utils-ts#234

@@ -122,9 +122,11 @@ export class AtomicTransactionComposer {
/** The maximum size of an atomic transaction group. */
static MAX_GROUP_SIZE: number = 16;

/** A map of tranasction indexes to the respective ABI method being called. Used for properly decoding return values. */
methodCalls: Map<number, ABIMethod> = new Map();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer you leave the field as it was, but introduce a new getter method like getMethodCalls which returns a copy of the map.

That helps with maintainability and prevents clients from unintentionally modifying the internal map

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 problem is that modifying the map is sometimes necessary. For example, if you have an ABI method call that takes in another ABI method call as an argument. The ATC does not currently support this, so you need to get the appl transaction and update methodCalls if you want the return values. I suppose we could add support for that, but it would be a larger change to the ATC.

Copy link
Contributor

Choose a reason for hiding this comment

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

If that's the use case you're pursuing, then yes I think we need to talk about how the interface can support that. Directly modifying the internal map is not a stable solution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose we could also have a method setMethodCall(idx: number, method: ABIMethod) in addition to getMethodCalls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And there can be sanity checks that it's an appl that doesn't already have a method set

Choose a reason for hiding this comment

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

Idea: what if we allow you to optionally pass in an ABIMethod when you call addTransaction? and then have a readonly property to expose method calls so you can read them out after using addMethodCall. Those two together would suffice?

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