Skip to content
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

Values for collections #30

Merged
merged 4 commits into from
Apr 18, 2024
Merged

Values for collections #30

merged 4 commits into from
Apr 18, 2024

Conversation

Kukovec
Copy link
Collaborator

@Kukovec Kukovec commented Apr 18, 2024

closes #23

Introduces types and constructors for all remaining Values (byte arrays, vectors and maps).

Note the following additional refactoring:

  • fixed bounded uint range inclusion (was: [0, 2^n], should have been [0, 2^n))
  • u32T has its own type declaration (to work with byte array type restrictions)
  • Added comments

Copy link
Contributor

@konnov konnov left a comment

Choose a reason for hiding this comment

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

Nice! I've left some comments

solarkraft/src/state/value.ts Outdated Show resolved Hide resolved
// Additionally, fixed-length byte arrays are valid only if their declared length matches their actual length
case "arr": {
const cast = (v as ArrValue)
const lenMismatch = ((typeof (cast.len)) !== 'undefined') && (cast.val.length !== cast.len)
Copy link
Contributor

Choose a reason for hiding this comment

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

I missed that: Why do we need explicit array length, if we can compute it from the value length?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you look at the bytesN constructor, that's exactly what it does. For now, I just want to keep parity with the Soroban types, where Bytes and BytesN are distinct, and if it turns out we don't need it we can axe it later.

solarkraft/src/state/value.ts Outdated Show resolved Hide resolved
solarkraft/src/state/value.ts Outdated Show resolved Hide resolved
solarkraft/src/state/value.ts Outdated Show resolved Hide resolved
solarkraft/src/state/value.ts Show resolved Hide resolved
solarkraft/src/state/value.ts Outdated Show resolved Hide resolved
solarkraft/src/state/value.ts Show resolved Hide resolved
@Kukovec Kukovec requested a review from konnov April 18, 2024 14:52
Copy link
Contributor

@konnov konnov left a comment

Choose a reason for hiding this comment

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

Looks great!

@Kukovec Kukovec merged commit 3da2db2 into main Apr 18, 2024
2 checks passed
@Kukovec Kukovec deleted the jk/values2 branch April 18, 2024 15:21
@konnov konnov added this to the M1: Transaction extractor milestone May 10, 2024
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.

Create a basic representation of smart contract builtin types
2 participants