wharfkit / contract

Access table data, create actions, and retrieve types for Antelope-based Smart Contracts
https://wharfkit.com
Other
1 stars 1 forks source link

Generated vs mocked #43

Closed aaroncox closed 11 months ago

aaroncox commented 11 months ago

Gotta say... this codegen stuff is pretty damn neat.

So what this pull request does is a few things:

  1. It pulls the ABI and Blob out of the Contract and places them in the root namespace and exposes them.
  2. The Contract now uses the abi value from the root namespace during construction.
  3. The Contract is moved into the namespace.
  4. The _ in front of the namespace is removed (we can discuss this, but I thought it wasn't needed?)
  5. Creates a new "mock generated contract" (test/data/contracts/mock-rewards.ts) that we can manually craft to get the desired syntax we want.
  6. Reworks the unit tests for code generation to ensure the generated and mock contracts are identical, as well as runs an entire suite against both of them to ensure they both function exactly the same.
  7. Implemented PartialBy as described in https://github.com/wharfkit/contract/issues/44
  8. Renamed types to Types in the namespace, since everything else is camel cased
  9. Moved some Contract tests into a function called runGenericContractTests so we can run identical tests against static contracts, generated contracts, and mock contracts https://github.com/wharfkit/contract/pull/43/commits/66bf96042009d126cd8ba0462e19af32060c4621

Most of the changes I made were to make it so we could run tests against both a generated and mock contract at the same time. This was so we could work on adding/changing things in the mock contract, ensuring the tests pass, and then modify the code generator to output something that was identical to the mock contract.

aaroncox commented 11 months ago

I didn't want to merge this and lose the conversation, but I did publish this branch as 0.3.2/0.3.3/0.3.4. I figure since we're not publicly pushing for people to use the kit, and this was codegen only changes, I could get away with it 😉

Reason was that I needed to update the dependencies and get a release out, but didn't want to conflict with dev.