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

ABI Support for JS library #454

Merged
merged 19 commits into from
Nov 5, 2021
Merged

ABI Support for JS library #454

merged 19 commits into from
Nov 5, 2021

Conversation

algochoi
Copy link
Contributor

@algochoi algochoi commented Oct 11, 2021

This PR adds ABI type encoding support for the JS SDK library.

Closes #425

tests/10.ABI.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
Copy link
Member

@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'm not sure why the build is failing. If you rebase/merge with develop, that might help

src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
tests/10.ABI.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
@algochoi algochoi marked this pull request as ready for review October 25, 2021 13:49
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
Copy link
Member

@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 have the following file organization suggestions, what do you think?

  • Move the functions bigIntToBytes and bytesToBigInt to a new file src/encoding/bigint.ts, since they are useful in general
  • Right now all ABI code is in a folder by itself. Since we can't split up the file easily without introducing circular imports, I think moving the file to src/encoding/abi.ts would make more sense. EDIT: actually having the abi folder makes sense, since ABI JSON description handling code can live there too.

Also, some exporting suggestions:

  • I just realized if we export the code as is, users would do import { Type } from 'algosdk', which is not great because Type is pretty general. Probably renaming to ABIType makes more sense.
  • src/main.ts needs to be updated to actually export the new class. If you adopt the above changes, export { ABIType } from './encoding/abi'; should do it

(somehow half my review got submitted early, that was not intentional)

src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
src/abi/abi_type.ts Outdated Show resolved Hide resolved
@jasonpaulos
Copy link
Member

jasonpaulos commented Nov 4, 2021

Weirdly it looks like the latest commit is failing on travis because of new cucumber tests from algorand/algorand-sdk-testing#145, but that shouldn't be happening because they're hidden behind the @unit.transactions.keyreg tag...

edit: will be fixed by algorand/algorand-sdk-testing#147

Copy link
Member

@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, except there are still some bigint literals 😄

After fixing, this looks good to merge to me!

src/encoding/bigint.ts Outdated Show resolved Hide resolved
@algochoi algochoi merged commit fe6e79d into develop Nov 5, 2021
@algochoi algochoi deleted the abi/encoding branch November 5, 2021 14:14
aldur pushed a commit that referenced this pull request Jan 20, 2022
* added abi files

* Temporarily disable linter for require() warning

* Update tests for ABI types

* Minor import change

* Remove separate encode file

* Add basic encoding tests

* Enforce Bigint args in uint/ufixed types

* Fix linter errors

* Fix more linting errors

* Address PR comments

* Add decoding functions and tests

* Fix chrome test errors by disabling crypto

* Address PR comments and try to see if we can resolve Travis errors

* Resolve circular dependencies in tests

* Change exports, naming and file structure

* Change bigint literals to BigInt()

* Remove more bigint literals

Co-authored-by: shiqi.zheng@algorand.com <shiqi.zheng@algorand.com>
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.

Add ABI encoding support
4 participants