Skip to content

Commit

Permalink
feat: specified_id is optional
Browse files Browse the repository at this point in the history
Signed-off-by: David Dal Busco <[email protected]>
  • Loading branch information
peterpeterparker committed Dec 20, 2024
1 parent e2a1543 commit 0d0b55c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/ic-management/src/utils/transform.utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ActorConfig, CallConfig } from "@dfinity/agent";
import { Principal } from "@dfinity/principal";
import { nonNullish } from "@dfinity/utils";
import { fromNullable, nonNullish } from "@dfinity/utils";

type CallTransform = Required<ActorConfig>["callTransform"];

Expand All @@ -22,7 +22,7 @@ export const transform: CallTransform | QueryTransform = (
args: (Record<string, unknown> & {
canister_id?: unknown;
target_canister?: unknown;
specified_id?: unknown;
specified_id?: [] | [unknown];
})[],
_callConfig: CallConfig,
): { effectiveCanisterId: Principal } => {
Expand All @@ -36,9 +36,12 @@ export const transform: CallTransform | QueryTransform = (
return { effectiveCanisterId: Principal.from(first.target_canister) };
} else if (
methodName === "provisional_create_canister_with_cycles" &&
nonNullish(first.specified_id)
nonNullish(first.specified_id) &&
nonNullish(fromNullable(first.specified_id))
) {
return { effectiveCanisterId: Principal.from(first.specified_id) };
return {
effectiveCanisterId: Principal.from(fromNullable(first.specified_id)),
};
} else if (nonNullish(first.canister_id)) {
return { effectiveCanisterId: Principal.from(first.canister_id) };
}
Expand Down

0 comments on commit 0d0b55c

Please sign in to comment.