Skip to content

Conversation

@ahangsu
Copy link
Contributor

@ahangsu ahangsu commented Oct 13, 2021

Summary

  • Removed data/abi/abi_value.go
  • Encode/Decode method take golang values, the behavior should be based on ABI type schemes

closes #3027

Test Plan

  • keep all the current testing methods
  • modify all the previous testing involved encoding/decoding methods to accept only golang values

Minor Question

We will have to use reflection for inferring if interface{} typed value can be type-asserted to be []interface{}.

We cannot directly do a.([]interface{}), that's why reflection comes in to achieve interface{} -> []interface{}.

Any thoughts on possible work-arounds? The perf seems not penalized...

jasonpaulos
jasonpaulos previously approved these changes Oct 14, 2021
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.

Looks good, just one nit

Copy link
Contributor

@jannotti jannotti left a comment

Choose a reason for hiding this comment

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

To combine a couple of my points into one, maybe you should just have one TypeOf(string) function, which would replace TypeFromString(), and would be used even for getting other types. TypeOf("bool") for example. Provides a nice narrow interface. I don't know if callers need MakeUintType(int). I suspect not, and that TypeOf("uint16") etc is better, because callers will not be dynamically selecting a type programatically.

Perhaps the others would continue to exist, but not as public (capitalized) functions.

@ahangsu
Copy link
Contributor Author

ahangsu commented Oct 18, 2021

My thoughts is that, probably hide most of the Make...Type functions, and directly construct ABI-types from TypeOf.
We might want to export some of the basic type constants like: ByteType, StringType, AddressType, BoolType.

NVM, we are hiding all these type constructors for now.

jasonpaulos
jasonpaulos previously approved these changes Oct 19, 2021
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.

Overall looks good, just 2 nits

jasonpaulos
jasonpaulos previously approved these changes Oct 19, 2021
@algojohnlee algojohnlee merged commit 1e5603c into master Oct 20, 2021
@algojohnlee algojohnlee deleted the feature/abi-encoding branch October 20, 2021 14:54
cce pushed a commit to cce/go-algorand that referenced this pull request Oct 28, 2021
Removed data/abi/abi_value.go
Encode/Decode method take golang values, the behavior should be based on ABI type schemes
@egieseke egieseke mentioned this pull request Nov 23, 2021
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.

Reformat ABI implementation, remove redundant Value struct

7 participants