78 Commits

Author SHA1 Message Date
aaroncox 27cadab49b Fix tests so they pass in node 20 2026-05-05 13:40:39 -07:00
aaroncox 7c47d2f984 Better readonly exception handling 2026-05-05 13:15:49 -07:00
Aaron Cox 7df3e66822 Add debug flag to allow json: true on table requests 2024-12-21 11:16:03 -08:00
Aaron Cox 513e0f5b38 Fixed false-y nature of JS 0 in table query
Fixes #70
2024-06-16 10:10:35 -07:00
Daniel Fugere c8c774db15 add reverse param to query method (#67)
* enhancement: add reverse param to query method

closes issue #46

* Added test for reverse

---------

Co-authored-by: Aaron Cox <aaron@greymass.com>
2024-01-30 09:31:13 -08:00
Aaron Cox 8c47751db5 Make data optional 2024-01-16 17:08:06 -08:00
Aaron Cox f65a8c3eb4 Implemented readonly method 2024-01-16 11:41:15 -08:00
dafuga 27756ee22a fix: get() returns undefined when no data is returned 2024-01-04 19:27:53 -05:00
Aaron Cox 559b24691d Added missing mock data for get_info 2023-11-07 12:43:50 -08:00
Aaron Cox 597286cb3c 0.4.3 - Bug Fixes
* Fixed issue with `scope` not being applied to queries

Fixes #56

* Updating dependencies

* Adding `index_position` as a fallback since `index` doesn't work most of the time

* Version 0.4.3
2023-08-31 14:35:23 -07:00
Daniel Fugere 22d5f7b37b Removed codegen logic (#55)
* chore: removed codegen logic

* Removed a few more things

---------

Co-authored-by: Aaron Cox <aaron@greymass.com>
2023-08-28 17:27:50 -07:00
Aaron Cox d1b2afd78d All system contract compatibility and better tests (#52)
* Rewrote tests to remove recursion and throw

* removed try/catch

* Fixed issue with Symbol typing

* Switching imports to wharfkit/antelope

* catching `Bool` type

* Dynamically import all core types related to ABIs

* Adding missing types

* Fixing TableNames key stringify

* Updating tests to support many contracts

* Changing imports over to wharfkit/antelope instead of session

* Removed notes

* Only override `action` and `table` call if data for those exist

* Scopes should accept generic numbers and cast to strings

Fixes #53

* Fixed scope logic

It was casting undefined to a string and never using `this.account`

* Allow passing `scope` as 2nd param to `contract.table`

This matches the syntax used in the CDT, as discussed here:

https://github.com/orgs/wharfkit/discussions/5#discussioncomment-6515701

* Version 0.4.1

* chore: renamed EOSIO_CORE variables

* refactor: added helper folder

* enhancement: making sure that Name is always in contract imports

* fix: removing $ from field name when applicable

* chore: added full eosio abi

* cleanup: removed contracts folder

* fix: parsing data types properly

* fix: using proper eosio abi

* fix: handling variant and alias types

* fix: handling booleans properly

* fix: handling variants in external and internal types

* cleanup: removed redundant Types namespace from Struct field type

* style: linted

---------

Co-authored-by: dafuga <danielfugere28@gmail.com>
2023-08-26 08:51:02 -07:00
Daniel Fugere 17a4b85097 Adjusting codegen script (#51)
* fix: unit tests tweaking

* fix: getting the codegen to output correct structs

* fix: getting the codegen class to import correct dependencies

* chore: added action method to generated Contract class

* chore: generating interfaces

* chore: got codegen script geenrating correct rewards.gm helper class

* style: linted

* cleanup: code cleanup
2023-08-19 20:17:51 -07:00
Aaron Cox a08cfcb673 Supporting typed actions and enabling autocomplete (#45)
* Altering action calls to be able to support typed inputs

* Delete example-contract.ts

* Renamed ActionData to ActionDataType

* Use prettier on generated code, and fixed tests

* Adding prettier plugin to cleanup imports

* Reverting back to old action syntax + new table syntax

* Implementing scope calls and cursors (#48)

* Moved `TableCursor` to `TableRowCursor` and extended abstract

* Version 0.4.0-beta1

* Implemented scope cursors
2023-08-16 14:34:08 -07:00
Aaron Cox 1160a92989 Generated vs mocked (#43)
* Moved ABI data to root of namespace

* Removed underscore in front of namespace

* Added new test setup to test mock and generated at the same time

* Add test to ensure the generated and mock contracts are equal

* Added note

* Linting + Ignore mock file

* Removed unused parameter

* Implemented `PartialBy` generic on generated contract

Fixes #44

* Re-enabled some tests

* Renamed `types` to `Types` in namespace

This matches the other camel casing we're doing

* Started migrating some contract tests to a generic function

This will allow us to run the same tests are run in the Contract tests against the generated tests

* Removing unused test data

* Updated ABICache

* Version 0.3.2

* Updating dependencies for ESR + Session

* Version 0.3.3

* Updating mock-data

* Removed export of codegen

Resolves #40

* Version 0.3.4
2023-08-08 09:58:31 -07:00
Daniel Fugere 6c85e09859 Adjusting codegen script (#39)
* cleanup: codegen cleanup

* fix: getting codegen script running again

* enhancement: generating contract class in correct format

* chore: added codegen tests

* chore: added tests for utils functions

* style: linted

* cleanup: code cleanup
2023-07-28 22:24:21 -07:00
Aaron Cox b3170851c7 Upgrading ABICache 2023-07-28 12:24:57 -07:00
Aaron Cox 001f0733a4 Migrating from @greymass/eosio to @wharfkit/antelope 2023-07-28 10:06:25 -07:00
Aaron Cox 3a0ced260c Query Merge (#36)
undefined
2023-07-26 17:30:04 -07:00
Aaron Cox 53566ccaac Make query in get() optional to just fetch first row 2023-07-24 23:28:25 -07:00
Aaron Cox 9472e1e238 Allow rowType on contract.table() method as 2nd param 2023-07-24 22:24:16 -07:00
Aaron Cox aa3c1f52c1 Independent Table Elements (#34)
* Prevent serialization if `rowType` is defined.

* Adding failing test

* Removing generics to serve as a reset to re-add

* Potential fix?

* Test showing it working

* TableCursor2 test

* Additional test data

* Merge

* Generics testing

* Moved new TableCursor as default cursor

* Altered Table to use new Cursor

* Removed secondary Cursor export

* Updated tests for new Cursor

* Reapplied mock data

* Reworked Table to no longer require a Contract

* Update src/contract/table-cursor.ts

Co-authored-by: Daniel Fugere <danielfugere28@gmail.com>

* Comments and splitting logic a bit

* Removing old test for now

See: https://github.com/wharfkit/contract/pull/34#discussion_r1272800905

* Split out limit/bounds logic, and added comments.

Same logic as before, just different syntax.

* Defaulting to MAX_SAFE_INTEGER

Resulting logic is the same, just simplified the Math.min() call

* Documentation pass

* Remove timeout from ci-test build

* Moved structs into better location

---------

Co-authored-by: Daniel Fugere <danielfugere28@gmail.com>
2023-07-24 16:09:03 -07:00
Aaron Cox 405bee17ec Utilize raw data (#27)
* Use `json: false` and handle serialization internally

* New test data

* Adjusting tests to be less specific, but still cover same concerns
2023-07-20 12:39:31 -07:00
Daniel Fugere 4b4518cacd More refactor (#23)
* chore: added cursor#query test

* chore: merging query and queryOptions params

* fix: getting tests passing

* revert: put example-contract back in

* enhancement: adding ability to pass rowsPerAPICall number on next() call

* style: linted

* Format should also run eslint against tests

* Include tests in check as well

* Fixing lint issues

* cleanup: removed empty test

* More cleanup failing test (#26)

* Adding check to make sure `next` after exhausting returns no rows

* Added test to highlight expected behavior

* enhancement: adding the rowsPerAPIRequest param to query() and next()

* style: linted

* cleanup: code cleanup

---------

Co-authored-by: Aaron Cox <aaron@greymass.com>
2023-07-20 12:32:39 -07:00
Aaron Cox d1c3f24079 Dynamic table row serialization and limit/maxRow changes (#21)
* All rows are not loaded when querying

* Typed rows by default

* Adding more coverage where we'd expect typed responses

* Force deserialization since get_table_rows doesn't support it?

* Fixed tests now that typed responses are returning

* Added singular default row limit

* Allow `scope` on `table.first()`

* Added `maxRows` for `table.first` to separate from `limit`

* Ensure cursors return static amounts

* The `limit` on a cursor should be per-query, not total.

* Ensure a `first` query doesn't return more on `next`

* Bulk updating test data
2023-07-19 09:55:17 -07:00
Aaron Cox f1ce51bbdc Remove Session Kit dependency (#19)
* Update README.md

* Changed to no longer depend on session kit

* Added eosio-signing-request

* Removed call method and local Session instance

* Reworked imports to use greymass/eosio instead of session kit

* Adding @wharfkit/abicache
2023-07-18 19:14:48 -07:00
Aaron Cox 7b00ffc515 Accessing/Calling Actions (#17)
* Base action/call implementation

* Capitalized Kit for test grep

* Removed Session tests

* Add `ricardian` method to retrieve contract description

* Fixing imports

* Added `hasAction` method

* Renamed `tables` getter to `tableNames`

* Implemented `hasTables`

* Fixed `tableNames` tests

* Added coverage

* Added check to ensure the array of actions passed to a Session transact
2023-07-18 10:49:45 -07:00
Daniel Fugere 50d0fe2bf7 New API (#12)
* enhancement: using internal types when applicable

* chore: added unit tests for generated rewards.gm contract

* chore: added missing cursor and all methods to codegen contract classes

* chore: implementing new table API

* chore: got base tests passing

* chore: adapting codegen to new API

* chore: got all tests passing again

* cleanup: code cleanup

* enhancement: added errors when wrong params are passed to find and where

* chore: added a where method on cursor

* enhancement: renamed where to query and find to get

* chore: commenting out codegen tests for now

* enhancement: passing lower and upper_bound without data wrapping

* chore: passing lower and upper_bound without data wrapping in cursor

* chore: wrapping all index values in core classes

* chore: updated dependencies

* fix: got tests passing

* cleanup: code cleanup

* Adding instance check

* Combining "cursor" test suites

* Removed unneeded check

* Corrected row result numbers

* Removed unused Errors

* Simplified table ABI retrieval

* Throws immediately on invalid table name

* Use local table ABI definition

* Removing async from getFieldToIndex

* More test coverage

---------

Co-authored-by: Aaron Cox <aaron@greymass.com>
2023-07-17 10:49:27 -07:00
Aaron Cox c4169db2b6 ContractKit + Contract (#14)
* Initial kit implementation

* Upgrading to next session/mock-data again

* Disabling some codegen stuff for now

* Start of modified Contract class

The `Contract` now requires an ABI, Account, and Client

The `call` method is currently not implemented.

* Setting Session on Contract when exists

* Uncommented call method
2023-07-07 13:25:45 -07:00
Aaron Cox c98326f724 Updating one last reference to local mock and removing mock files 2023-07-05 15:38:04 -07:00
Aaron Cox 96558c1fdf Reworked tests and cleaned up test data 2023-07-05 15:32:43 -07:00
Aaron Cox 71a881daa9 Fixed codegen test 2023-07-05 15:14:50 -07:00
dafuga 12321859a5 cleanup: post rebase cleanup 2023-07-05 12:38:52 -04:00
Aaron Cox 0046ebd470 Initial tests 2023-07-05 12:35:41 -04:00
dafuga 189c2cc4f1 style: linted 2023-07-05 12:35:41 -04:00
dafuga a8398bb3c6 chore: added missing cursor and all methods to codegen contract classes 2023-07-05 12:35:39 -04:00
dafuga 3f2c381a98 enhancement: handling the case where a table has no defined indexes 2023-07-05 12:34:29 -04:00
dafuga e8cbe4a7d7 fix: generating proper types 2023-07-05 12:34:29 -04:00
dafuga e74eec6a1d chore: added more failing tests for codegen classes 2023-07-05 12:34:29 -04:00
dafuga bca81b29df enhancement: generating contract class and deleting it with each test run 2023-07-05 12:34:29 -04:00
dafuga db032f1f66 fix: fixed codegen unit tests 2023-07-05 12:34:29 -04:00
dafuga 895272bf9a chore: updated requests data 2023-07-05 12:34:29 -04:00
dafuga f79c30cc13 chore: added unit tests for generated rewards.gm contract 2023-07-05 12:34:29 -04:00
dafuga bb88fee899 chore: adding unit tests for codegen function 2023-07-05 12:34:29 -04:00
dafuga be48d2587e enhancement: using internal types when applicable 2023-07-05 12:34:29 -04:00
Aaron Cox 57861c3b20 Added failing test 2023-06-23 11:42:09 -07:00
dafuga 4aac6a7a45 enhancement: using namebids to test handling of tables with large number of rows 2023-06-21 19:08:36 -04:00
dafuga 5c7e545960 enhancement: added the cursor() and all() table methods 2023-06-21 15:25:36 -04:00
dafuga 0e6d716261 fix: handling the case where an empty array is returned with a next_key value 2023-06-20 16:12:29 -04:00
dafuga d86ea9ab70 fix: getting tests passing again 2023-06-20 16:02:33 -04:00