From 64be779a97715c635183b09614779813374bbc87 Mon Sep 17 00:00:00 2001 From: Matt Grogan Date: Mon, 9 Oct 2023 10:00:32 -0500 Subject: [PATCH] Fix submitProposal (#4535) --- frontend/app/src/components/home/MakeProposalModal.svelte | 4 ++-- frontend/openchat-agent/src/services/openchatAgent.ts | 2 +- frontend/openchat-agent/src/services/user/mappers.ts | 1 - frontend/openchat-agent/src/services/user/user.client.ts | 4 ++-- frontend/openchat-client/src/openchat.ts | 3 +-- frontend/openchat-shared/src/domain/worker.ts | 3 +-- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/frontend/app/src/components/home/MakeProposalModal.svelte b/frontend/app/src/components/home/MakeProposalModal.svelte index a6a286f9db..0f04e12575 100644 --- a/frontend/app/src/components/home/MakeProposalModal.svelte +++ b/frontend/app/src/components/home/MakeProposalModal.svelte @@ -106,10 +106,10 @@ function onClickPrimary() { if (step === 0) { balanceWithRefresh.refresh(); + } else if (canSubmit) { + onSubmit(); } else if (step === 1) { step = 2; - } else if (step === 2) { - onSubmit(); } } diff --git a/frontend/openchat-agent/src/services/openchatAgent.ts b/frontend/openchat-agent/src/services/openchatAgent.ts index 708aa8aaca..1b5db52920 100644 --- a/frontend/openchat-agent/src/services/openchatAgent.ts +++ b/frontend/openchat-agent/src/services/openchatAgent.ts @@ -2548,7 +2548,7 @@ export class OpenChatAgent extends EventTarget { } } - submitProposal(governanceCanisterId: Principal, proposal: CandidateProposal): Promise { + submitProposal(governanceCanisterId: string, proposal: CandidateProposal): Promise { return this.userClient.submitProposal(governanceCanisterId, proposal); } } diff --git a/frontend/openchat-agent/src/services/user/mappers.ts b/frontend/openchat-agent/src/services/user/mappers.ts index 8e3ae864c3..cc47882a3a 100644 --- a/frontend/openchat-agent/src/services/user/mappers.ts +++ b/frontend/openchat-agent/src/services/user/mappers.ts @@ -1079,7 +1079,6 @@ function proposalAction(action: CandidateProposalAction): ProposalToSubmitAction treasury: action.treasury === "ICP" ? { ICP: null } : { SNS: null } }}; } - throw new Error("Unexpected proposal action"); } export function submitProposalResponse(candid: ApiSubmitProposalResponse): SubmitProposalResponse { diff --git a/frontend/openchat-agent/src/services/user/user.client.ts b/frontend/openchat-agent/src/services/user/user.client.ts index 2272a45fc7..cd8fb5d4cb 100644 --- a/frontend/openchat-agent/src/services/user/user.client.ts +++ b/frontend/openchat-agent/src/services/user/user.client.ts @@ -1121,10 +1121,10 @@ export class UserClient extends CandidService { ); } - submitProposal(governanceCanisterId: Principal, proposal: CandidateProposal): Promise { + submitProposal(governanceCanisterId: string, proposal: CandidateProposal): Promise { return this.handleResponse( this.userService.submit_proposal({ - governance_canister_id : governanceCanisterId, + governance_canister_id : Principal.fromText(governanceCanisterId), proposal : proposalToSubmit(proposal), }), submitProposalResponse, diff --git a/frontend/openchat-client/src/openchat.ts b/frontend/openchat-client/src/openchat.ts index b0b49d2440..0992182c66 100644 --- a/frontend/openchat-client/src/openchat.ts +++ b/frontend/openchat-client/src/openchat.ts @@ -1,5 +1,4 @@ /* eslint-disable no-case-declarations */ -import { Principal } from "@dfinity/principal"; import type { Identity } from "@dfinity/agent"; import { AuthClient } from "@dfinity/auth-client"; import { get, writable } from "svelte/store"; @@ -4998,7 +4997,7 @@ export class OpenChat extends OpenChatAgentWorker { submitProposal(governanceCanisterId: string, proposal: CandidateProposal): Promise { return this.sendRequest({ kind: "submitProposal", - governanceCanisterId: Principal.fromText(governanceCanisterId), + governanceCanisterId, proposal, }) .then((resp) => { diff --git a/frontend/openchat-shared/src/domain/worker.ts b/frontend/openchat-shared/src/domain/worker.ts index d56fbe543f..e120a98c29 100644 --- a/frontend/openchat-shared/src/domain/worker.ts +++ b/frontend/openchat-shared/src/domain/worker.ts @@ -139,7 +139,6 @@ import type { import type { ChatPermissions } from "./permission"; import type { RegistryValue } from "./registry"; import type { StakeNeuronForSubmittingProposalsResponse } from "./proposalsBot"; -import type { Principal } from "@dfinity/principal"; import type { CandidateProposal } from "./proposals"; /** * Worker request types @@ -1326,7 +1325,7 @@ type FollowThread = { }; type SubmitProposal = { - governanceCanisterId: Principal; + governanceCanisterId: string; proposal: CandidateProposal; kind: "submitProposal"; };