-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
176 additions
and
280 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,66 @@ | ||
package abi | ||
|
||
import ( | ||
"fmt" | ||
"math" | ||
|
||
"github.com/algorand/go-algorand/data/abi" | ||
avm_abi "github.com/algorand/avm-abi/abi" | ||
) | ||
|
||
type Type = abi.Type | ||
type Type = avm_abi.Type | ||
|
||
func TypeOf(str string) (Type, error) { | ||
return abi.TypeOf(str) | ||
return avm_abi.TypeOf(str) | ||
} | ||
|
||
// MakeTupleType makes tuple ABI type by taking an array of tuple element types as argument. | ||
func MakeTupleType(argumentTypes []Type) (Type, error) { | ||
if len(argumentTypes) == 0 { | ||
return Type{}, fmt.Errorf("tuple must contain at least one type") | ||
} | ||
return avm_abi.MakeTupleType(argumentTypes) | ||
} | ||
|
||
// AnyTransactionType is the ABI argument type string for a nonspecific transaction argument | ||
const AnyTransactionType = avm_abi.AnyTransactionType | ||
|
||
// PaymentTransactionType is the ABI argument type string for a payment transaction argument | ||
const PaymentTransactionType = avm_abi.PaymentTransactionType | ||
|
||
// KeyRegistrationTransactionType is the ABI argument type string for a key registration transaction | ||
// argument | ||
const KeyRegistrationTransactionType = avm_abi.KeyRegistrationTransactionType | ||
|
||
// AssetConfigTransactionType is the ABI argument type string for an asset configuration transaction | ||
// argument | ||
const AssetConfigTransactionType = avm_abi.AssetConfigTransactionType | ||
|
||
// AssetTransferTransactionType is the ABI argument type string for an asset transfer transaction | ||
// argument | ||
const AssetTransferTransactionType = avm_abi.AssetTransferTransactionType | ||
|
||
if len(argumentTypes) >= math.MaxUint16 { | ||
return Type{}, fmt.Errorf("tuple type child type number larger than maximum uint16 error") | ||
} | ||
// AssetFreezeTransactionType is the ABI argument type string for an asset freeze transaction | ||
// argument | ||
const AssetFreezeTransactionType = avm_abi.AssetFreezeTransactionType | ||
|
||
strTuple := "(" + argumentTypes[0].String() | ||
for i := 1; i < len(argumentTypes); i++ { | ||
strTuple += "," + argumentTypes[i].String() | ||
} | ||
strTuple += ")" | ||
// ApplicationCallTransactionType is the ABI argument type string for an application call | ||
// transaction argument | ||
const ApplicationCallTransactionType = avm_abi.ApplicationCallTransactionType | ||
|
||
return TypeOf(strTuple) | ||
// IsTransactionType checks if a type string represents a transaction type | ||
// argument, such as "txn", "pay", "keyreg", etc. | ||
func IsTransactionType(typeStr string) bool { | ||
return avm_abi.IsTransactionType(typeStr) | ||
} | ||
|
||
// AccountReferenceType is the ABI argument type string for account references | ||
const AccountReferenceType = avm_abi.AccountReferenceType | ||
|
||
// AssetReferenceType is the ABI argument type string for asset references | ||
const AssetReferenceType = avm_abi.AssetReferenceType | ||
|
||
// ApplicationReferenceType is the ABI argument type string for application references | ||
const ApplicationReferenceType = avm_abi.ApplicationReferenceType | ||
|
||
// IsReferenceType checks if a type string represents a reference type argument, | ||
// such as "account", "asset", or "application". | ||
func IsReferenceType(typeStr string) bool { | ||
return avm_abi.IsReferenceType(typeStr) | ||
} | ||
|
||
// VoidReturnType is the ABI return type string for a method that does not return any value | ||
const VoidReturnType = avm_abi.VoidReturnType |
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
Oops, something went wrong.