Skip to content

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

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

@algochoi algochoi marked this pull request as ready for review October 25, 2021 13:49
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 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)

@jasonpaulos
Copy link
Contributor

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

@algochoi algochoi requested a review from jasonpaulos November 4, 2021 20:35
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, except there are still some bigint literals 😄

After fixing, this looks good to merge to me!

@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

5 participants