Skip to content

Conversation

tabaktoni
Copy link
Member

Motivation and Resolution

Goal:
OO "self-contained composable" - CairoType
AR "accurate representation" - Byte representation
DD "Data-driven configurability" - Strategy Map

  • Convert all implemented parsing types to CairoTypes
  • Eventually remove request and response parsers
  • Programmable request/response using Strategy map
  • Remove formatter (replaced by Strategy map)
  • refactor higher-order types to contain appropriate CairoTypes
  • substitute lower-order types to contain CairoFelt instead of JS types like BigInt (Felt should be the only one having value represented as non CairoType "ByteArray").

Usage related changes

  • At the end, for the Contract Class users, none ( parsing should be abstracted), and an addition should be an option to define a response type based on the cairo type using a strategy map.
  • For the tooling devs, they should now have access to all Cairo representation types. "self-contained composable units".

Development related changes

Instead of functional parsing and utils for api, have self-contained CairoTypes similar to the native JS types (Number, String, BigInt....)

Checklist:

  • Performed a self-review of the code
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Linked the issues which this PR resolves
  • Documented the changes in code (API docs will be generated automatically)
  • Updated the tests
  • All tests are passing

tabaktoni and others added 30 commits August 4, 2025 23:48
* feat: reduce TX wait time, and provide known failed reasons based on TX flow

* test: eventless write bytearray xtest

* feat: uint static factory methods

* refactor: cleanup

* feat: missing primitive integers implemented as cairo types

* chore: cleanup
Copy link
Collaborator

@penovicp penovicp left a comment

Choose a reason for hiding this comment

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

General approach lgtm

Several tests are not passing, left a change suggestion for utils/typedData.ts that should address some of them.

A set of less important changes that could be made is that several typeof usages could be replaced with corresponding utils/typed.ts methods.

Comment on lines 407 to 412
const elements = [
byteArray.data.length,
...byteArray.data,
byteArray.pending_word,
byteArray.pending_word_len,
];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const elements = [
byteArray.data.length,
...byteArray.data,
byteArray.pending_word,
byteArray.pending_word_len,
];
const elements = byteArray.toApiRequest();

This change should make the related tests pass. The as BigNumberish[] cast on the following line can then also be removed.

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.

2 participants