Skip to content

CairoByteArray #1469

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

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft

CairoByteArray #1469

wants to merge 8 commits into from

Conversation

tabaktoni
Copy link
Member

@tabaktoni tabaktoni commented Aug 6, 2025

Motivation and Resolution

Fix: #1455

  • Extend parser so that the user can define parsing classes for types and response type (extend parser to configurable response parsing)
  • Integrate New ByteArray to parser
  • Docs
  • Integration tests
  • Events emitted tests
  • Unit tests
  • ByteArray integration tests without parser
  • Extend Contract Class to set up a custom parser map config

RPC version (if applicable)

Usage related changes

TODO

Development related changes

TODO

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

Copy link
Collaborator

@PhilippeR26 PhilippeR26 left a comment

Choose a reason for hiding this comment

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

Just few comments.

}

// Otherwise treat as UTF-8 text
return utf8ToArray(str);
Copy link
Collaborator

Choose a reason for hiding this comment

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

As utf8ToArray is now deprecated, utf8ToUint8Array should be used.

return this.data;
}

toUnicode() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a doubt about the name of this method.
As it's working only if the number is the result of a utf-8 encoding, I propose something like .decodeUtf8 or .decodeFromUtf8

return uint8ArrayToBigInt(this.data);
}

toUnicode() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as uint32.

return uint8ArrayToBigInt(this.data);
}

toUnicode() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as uint32

/**
* from String
*/
constructor(data: string);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we be able to create a Bytes31 by aBigNumberish?

/**
* byteArray from String
*/
public constructor(data: String);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comments than bytes31.

...this.pending_word_len.toApiRequest(),
];
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Compare to other Cairo types, are missing . toBigInt, .toHexString, .is, .isAbiType and something to decode from utf-8.
.is seems unnecessary, but the others have a sense to be there too.

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.

Incorrect ByteArray encoding/decoding
2 participants