-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Foreign objects as ABI arguments and address ARC-4 changes (#251
) * 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 * Add foreign types for method arguments * Clean up imports * Fix unit test for appId * Add unit test for foreign array * Refactor some names and add txn as an arg type * Partially address PR comments * Fix encoding args for foreign types * Add some additional checks for safety * Fix a step so we check for empty string instead of None * Correct foreign app and account indices accounting for the implicit argument * Resolve formatting * Fix unit tests * Fix foreign objects to compact duplicates and special values * Refactor foreign objects, transactions, and address some new ABI changes * ABI composer modifications and test updates * Change Interface and Contract to newest ABI changes * Fix some integration tests for composer * Fix remaining composer tests * Formatting changes * Fix method json tests * Address PR Comments, clean up and refactor composer and contract * Create helper function for populating foreign objects * Change type hints on reference and transaction checks * Add generics and fix dictifying network info * Fix step for cucumber test contract parsing
- Loading branch information
Showing
9 changed files
with
554 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import Any | ||
|
||
|
||
class ABIReferenceType: | ||
# Account reference type | ||
ACCOUNT = "account" | ||
|
||
# Application reference type | ||
APPLICATION = "application" | ||
|
||
# Asset reference type | ||
ASSET = "asset" | ||
|
||
|
||
def is_abi_reference_type(t: Any) -> bool: | ||
return t in ( | ||
ABIReferenceType.ACCOUNT, | ||
ABIReferenceType.APPLICATION, | ||
ABIReferenceType.ASSET, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from typing import Any | ||
|
||
from algosdk import constants | ||
from algosdk.future.transaction import Transaction | ||
|
||
|
||
class ABITransactionType: | ||
# Any transaction type | ||
ANY = "txn" | ||
|
||
# Payment transaction type | ||
PAY = constants.PAYMENT_TXN | ||
|
||
# Key registration transaction type | ||
KEYREG = constants.KEYREG_TXN | ||
|
||
# Asset configuration transaction type | ||
ACFG = constants.ASSETCONFIG_TXN | ||
|
||
# Asset transfer transaction type | ||
AXFER = constants.ASSETTRANSFER_TXN | ||
|
||
# Asset freeze transaction type | ||
AFRZ = constants.ASSETFREEZE_TXN | ||
|
||
# Application transaction type | ||
APPL = constants.APPCALL_TXN | ||
|
||
|
||
def is_abi_transaction_type(t: Any) -> bool: | ||
return t in ( | ||
ABITransactionType.ANY, | ||
ABITransactionType.PAY, | ||
ABITransactionType.KEYREG, | ||
ABITransactionType.ACFG, | ||
ABITransactionType.AXFER, | ||
ABITransactionType.AFRZ, | ||
ABITransactionType.APPL, | ||
) | ||
|
||
|
||
def check_abi_transaction_type(t: Any, txn: Transaction) -> bool: | ||
if t == ABITransactionType.ANY: | ||
return True | ||
return txn.type and txn.type == t |
Oops, something went wrong.