Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend transform for provisional_create_canister_with_cycles #796

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
11 changes: 10 additions & 1 deletion 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,6 +22,7 @@ export const transform: CallTransform | QueryTransform = (
args: (Record<string, unknown> & {
canister_id?: unknown;
target_canister?: unknown;
specified_id?: [] | [unknown];
})[],
_callConfig: CallConfig,
): { effectiveCanisterId: Principal } => {
Expand All @@ -33,6 +34,14 @@ export const transform: CallTransform | QueryTransform = (
nonNullish(first.target_canister)
) {
return { effectiveCanisterId: Principal.from(first.target_canister) };
} else if (
methodName === "provisional_create_canister_with_cycles" &&
nonNullish(first.specified_id) &&
nonNullish(fromNullable(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
Loading