Skip to content

Conversation

@algochoi
Copy link
Contributor

@algochoi algochoi commented Oct 27, 2021

This PR enables developers to invoke on-chain contract methods using off-chain applications, as defined by ARC-0004.

  • Define an object for an ABI method description and expose the signature and selector
  • Define an object for an ABI interface description
  • Define an object for an ABI contract description
  • Define and implement AtomicTransactionComposer
  • Merge signatures for TransactionSigners
  • Parse logs for return arguments
  • Add cucumber tests and add tags to the Makefile
  • Support foreign objects as ABI arguments (Will require follow up ticket)

Closes #242

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.

I guess the spec doesn't say anything about this currently, but could you add methods to re-encode the Method, Interface, and Contract objects to JSON? For symmetry this would be good to have.

@algochoi algochoi marked this pull request as ready for review November 16, 2021 23:54
)
def append_app_args_to_method_args(context, method_args):
# Returns a list of ABI method arguments
app_args = split_and_process_abi_args(context.abi_method, method_args)
Copy link
Contributor

Choose a reason for hiding this comment

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

This works for now so it doesn't need to be changed in this PR, but I'd like this step to not assume that method_args match the arguments from context.abi_method.

Meaning it should be possible to call this step many times to append arguments, and then only in the I add a method call... step should the arguments be decoded. This will give us more flexibility to mix transaction args and normal args, like (uint64,pay,uint64,axfer,uint64).

This is how I did in the JS SDK: https://github.com/algorand/js-algorand-sdk/blob/6cb22886b089544349448bc1097164dc70a085b8/tests/cucumber/steps/steps.js#L4750-L4791

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point, we should make the step as general as possible.

Copy link
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

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

Left various suggestions. All basically minor improvements or ignoreable.

@tzaffi
Copy link
Contributor

tzaffi commented Nov 23, 2021

Looks like you shouldn't follow my f-string or @dataclass suggestions since we are stuck on Python 3.5. I'll bring this up for discussion during standup.

@algochoi algochoi requested a review from tzaffi November 23, 2021 22:09
Copy link
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

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

LGTM

@algochoi algochoi merged commit d8b29d9 into develop Nov 24, 2021
@algochoi algochoi deleted the algochoi/abi-interaction branch November 24, 2021 13:58
aldur pushed a commit that referenced this pull request Feb 8, 2022
* Start ABI JSON interaction

* Add static annoation

* Fix Method argument parsing

* Add ABI Typing to Method arguments

* [WIP] Add AtomicTransactionComposer build functions

* [WIP] Sign and send atomic transaction groups

* Add unit tests for object parsing

* Clean up method calls

* Address PR comments on JSON objects

* Refactor ABI Type to ABIType so it can be exposed to outside world

* Add cucumber steps for ABI tests and update existing implementation so it can pass these tests

* Refactor TransactionSigner to Abstract class and merge signatures when signing

* Update testing to reflect json unit tests and composer tests

* Formatting and docstring fixes

* Clean up imports

* Fix unit test for appId

* Refactor some names and add txn as an arg type

* Partially address PR comments

* Add some additional checks for safety

* Fix a step so we check for empty string instead of None

* MInclude returns tests and check for a valid returns from a ABI call

* Addressing PR comments about type hints and returning self

* Ensure group ids are zero when adding transactions
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.

ABI Interaction - off-chain programs invoking on-chain contracts

6 participants