-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aaa02dd
commit 52a3581
Showing
10 changed files
with
641 additions
and
728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.1.29 | ||
1.1.37 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v20.18.0 | ||
v22.11.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { IDL, JsonValue } from '@dfinity/candid'; | ||
import { IDL } from '@dfinity/candid'; | ||
import { isNil } from './is-nil'; | ||
|
||
export function optional<T>(value: T | undefined | null): [] | [T] { | ||
return isNil(value) ? [] : [value]; | ||
} | ||
|
||
export function decodeCandid( | ||
export function decodeCandid<T>( | ||
types: IDL.Type[], | ||
data: ArrayBufferLike, | ||
): JsonValue | null { | ||
): T | null { | ||
const returnValues = IDL.decode(types, data); | ||
|
||
switch (returnValues.length) { | ||
case 0: | ||
return null; | ||
case 1: | ||
return returnValues[0]; | ||
return returnValues[0] as T; | ||
default: | ||
return returnValues; | ||
return returnValues as T; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.