-
Notifications
You must be signed in to change notification settings - Fork 804
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
base: develop
Are you sure you want to change the base?
CairoByteArray #1469
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just few comments.
src/utils/encode.ts
Outdated
} | ||
|
||
// Otherwise treat as UTF-8 text | ||
return utf8ToArray(str); |
There was a problem hiding this comment.
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.
src/utils/cairoDataTypes/uint32.ts
Outdated
return this.data; | ||
} | ||
|
||
toUnicode() { |
There was a problem hiding this comment.
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
src/utils/cairoDataTypes/felt.ts
Outdated
return uint8ArrayToBigInt(this.data); | ||
} | ||
|
||
toUnicode() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as uint32.
src/utils/cairoDataTypes/bytes31.ts
Outdated
return uint8ArrayToBigInt(this.data); | ||
} | ||
|
||
toUnicode() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as uint32
src/utils/cairoDataTypes/bytes31.ts
Outdated
/** | ||
* from String | ||
*/ | ||
constructor(data: string); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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(), | ||
]; | ||
} | ||
} |
There was a problem hiding this comment.
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.
Motivation and Resolution
Fix: #1455
RPC version (if applicable)
Usage related changes
TODO
Development related changes
TODO
Checklist: