Skip to content

Commit

Permalink
Transform all u8 arrays by default (#362)
Browse files Browse the repository at this point in the history
* Transform all u8 arrays by default

The current behaviour confuses devs because some `u8` arrays are being turned into `BytesTypeNode` but not others based on their size. This PR fixes this by transforming all fixed-size arrays of `u8` numbers into a `FixedSizeTypeNode` of `BytesTypeNode`.

* Update changesets
  • Loading branch information
lorisleiva authored Dec 27, 2024
1 parent e255d74 commit d956af2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/serious-fireants-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@codama/visitors': minor
'@codama/nodes-from-anchor': minor
---

Transform all u8 arrays by default in `transformU8ArraysToBytesVisitor`
2 changes: 1 addition & 1 deletion packages/visitors/src/transformU8ArraysToBytesVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@codama/nodes';
import { extendVisitor, nonNullableIdentityVisitor, pipe, visit } from '@codama/visitors-core';

export function transformU8ArraysToBytesVisitor(sizes: number[] | '*' = [32, 64]) {
export function transformU8ArraysToBytesVisitor(sizes: number[] | '*' = '*') {
const hasRequiredSize = (count: ArrayTypeNode['count']): boolean => {
if (!isNode(count, 'fixedCountNode')) return false;
return sizes === '*' || sizes.includes(count.value);
Expand Down

0 comments on commit d956af2

Please sign in to comment.