Skip to content

Commit

Permalink
fix: use deserializer from options if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
denbite committed Jul 20, 2024
1 parent 4de0560 commit 227aa73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions packages/near-sdk-js/lib/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/near-sdk-js/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ export type Mutable<T> = { -readonly [P in keyof T]: T[P] };
export function getValueWithOptions<DataType>(
subDatatype: unknown,
value: Uint8Array | null,
options: Omit<GetOptions<DataType>, "serializer"> = {
deserializer: deserialize,
}
options: Omit<GetOptions<DataType>, "serializer"> = {}
): DataType | null {
if (value === null) {
return options?.defaultValue ?? null;
}

const deserializer = options.deserializer || deserialize;

// here is an obj
let deserialized = deserialize(value);
let deserialized = deserializer(value);

if (deserialized === undefined || deserialized === null) {
return options?.defaultValue ?? null;
Expand Down

0 comments on commit 227aa73

Please sign in to comment.