Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/utils/src/libraries/pack/binaryMarshal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export const encodePackType = (type: PackTypeDefinition): number => {
// KindBytes65 is the kind of all 65-byte arrays.
case PackPrimitive.Bytes65:
return 13;
// KindBytes64 is the kind of all 64-byte arrays.
case PackPrimitive.Bytes64:
return 14;
}

// Complex types.
Expand Down Expand Up @@ -219,6 +222,7 @@ export const encodePackPrimitive = (
}
case PackPrimitive.Bytes32:
case PackPrimitive.Bytes65:
case PackPrimitive.Bytes64:
return value instanceof Uint8Array
? value
: // Supports base64 url format
Expand Down
5 changes: 5 additions & 0 deletions packages/utils/src/libraries/pack/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export enum PackPrimitive {
Bytes = "bytes",
Bytes32 = "bytes32",
Bytes65 = "bytes65",
Bytes64 = "bytes64",
}

export interface PackStructType<
Expand Down Expand Up @@ -68,6 +69,8 @@ export type Marshalled<
? string
: Type extends PackPrimitive.Bytes65
? string
: Type extends PackPrimitive.Bytes64
? string
: Type extends PackNilType
? string
: Type extends { list: InnerType }
Expand Down Expand Up @@ -101,6 +104,8 @@ export type Unmarshalled<
? Uint8Array
: Type extends PackPrimitive.Bytes65
? Uint8Array
: Type extends PackPrimitive.Bytes64
? Uint8Array
: Type extends PackNilType
? null
: Type extends { list: InnerType }
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/libraries/pack/unmarshal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const unmarshalPackPrimitive = <T extends PackPrimitive = PackPrimitive>(
case PackPrimitive.Bytes:
case PackPrimitive.Bytes32:
case PackPrimitive.Bytes65:
case PackPrimitive.Bytes64:
return utils.fromBase64(value) as Unmarshalled<T>;
}
throw new Error(`Unknown pack type '${type}'.`);
Expand Down