From dad0e76ef5dc994baf12a45b6a8b3cbb5fe06099 Mon Sep 17 00:00:00 2001 From: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com> Date: Mon, 31 Jul 2023 09:57:31 -0700 Subject: [PATCH] chore: clean up todos throughout repo (#129) * chore: clean up todos throughout repo * Update src/components/organisms/proposal-send-form.tsx Co-authored-by: Marie Gauthier * Update src/components/organisms/proposal-send-form.tsx Co-authored-by: Marie Gauthier --------- Co-authored-by: Marie Gauthier --- src/api/group.amino.ts | 4 ++-- src/api/proposal.messages.ts | 8 ++++++-- src/api/proposal.utils.ts | 6 +++--- src/components/molecules/group-members-fields.tsx | 2 +- src/components/organisms/error-fallback.tsx | 2 +- src/components/organisms/proposal-form.tsx | 2 -- src/components/organisms/proposal-send-form.tsx | 4 +++- src/components/organisms/stake-redelegate-form.tsx | 4 ++-- src/components/organisms/stake-undelegate-form.tsx | 4 ++-- .../organisms/stories/group-form.stories.tsx | 2 +- src/pages/group-details-page.tsx | 2 +- src/pages/group-edit-page.tsx | 2 +- src/pages/proposal-create-page.tsx | 1 - src/store/wallet.store.ts | 10 +++++----- src/tests/api.utils.test.ts | 4 ++-- src/types/policy.types.ts | 2 -- src/types/proposal.types.ts | 10 +++++----- src/util/enums.ts | 4 ++-- src/util/errors.ts | 2 +- src/util/validation/metadata.ts | 2 +- src/util/validation/zod.ts | 4 ++-- 21 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/api/group.amino.ts b/src/api/group.amino.ts index 7de6dab..d87463a 100644 --- a/src/api/group.amino.ts +++ b/src/api/group.amino.ts @@ -36,7 +36,7 @@ import { MemberRequestAmino } from '@regen-network/api/types/codegen/cosmos/grou import { AnyAmino } from '@regen-network/api/types/codegen/google/protobuf/any' import Long from 'long' -// TODO: remove amino converter workaround #105 +// TODO(#105): remove amino converter workaround export const MemberRequestToAmino = (message: MemberRequest): MemberRequestAmino => { const output = { address: message.address, @@ -46,7 +46,7 @@ export const MemberRequestToAmino = (message: MemberRequest): MemberRequestAmino return output } -// TODO: remove amino converter workaround #105 +// TODO(#105): remove amino converter workaround export const groupAminoConverters = { '/cosmos.group.v1.MsgCreateGroupPolicy': { aminoType: 'cosmos-sdk/MsgCreateGroupPolicy', diff --git a/src/api/proposal.messages.ts b/src/api/proposal.messages.ts index f5145b5..929e604 100644 --- a/src/api/proposal.messages.ts +++ b/src/api/proposal.messages.ts @@ -1,4 +1,8 @@ -// import { Exec } from '@regen-network/api/types/codegen/cosmos/group/v1/tx' +// NOTE: importing from src rather than types resolves an import issue +// with types most likely related to typescript errors upstream. +// TODO: https://github.com/regen-network/regen-js/issues/84 +import { Exec } from '@regen-network/api/src/codegen/cosmos/group/v1/tx' + import type { Any } from 'types' import { GroupMsgWithTypeUrl } from './cosmosgroups' @@ -8,7 +12,7 @@ export function msgSubmitProposal({ messages, metadata, proposers, - exec = 0, // Exec.EXEC_UNSPECIFIED, TODO - TS doesn't import `Exec` correctly + exec = Exec.EXEC_UNSPECIFIED, }: { exec?: number // Exec groupPolicyAddress: string diff --git a/src/api/proposal.utils.ts b/src/api/proposal.utils.ts index 544a5ad..78b5380 100644 --- a/src/api/proposal.utils.ts +++ b/src/api/proposal.utils.ts @@ -51,13 +51,13 @@ export function proposalActionsToMsgs( ): Any[] { return actions.map(({ values }) => { if (isSendProposal(values)) { - return sendValuesToMsg(values, data) as unknown as Any // TODO + return sendValuesToMsg(values, data) } if (isStakeProposal(values)) { - return stakeValuesToMsg(values, data) as unknown as Any // TODO + return stakeValuesToMsg(values, data) } if (isGroupUpdateProposal(values)) { - return groupUpdateValuesToMsg(values, data) as unknown as Any // TODO + return groupUpdateValuesToMsg(values, data) } throwError(`Unknown proposal action: ${JSON.stringify(values, null, 2)}`) }) diff --git a/src/components/molecules/group-members-fields.tsx b/src/components/molecules/group-members-fields.tsx index b2b4b1d..0c954f5 100644 --- a/src/components/molecules/group-members-fields.tsx +++ b/src/components/molecules/group-members-fields.tsx @@ -80,7 +80,7 @@ export const GroupMembersFields = () => { directly add to it */} { const error = useRouteError() - // TODO: `toErrorWithMessage` was added before react-router 6.4 upgrade - + // TODO(#125): `toErrorWithMessage` was added before react-router 6.4 upgrade - // there's probably a more graceful solution. See: // https://reactrouter.com/en/main/route/error-element // const error = toErrorWithMessage(routeErr) diff --git a/src/components/organisms/proposal-form.tsx b/src/components/organisms/proposal-form.tsx index c09f05f..d638477 100644 --- a/src/components/organisms/proposal-form.tsx +++ b/src/components/organisms/proposal-form.tsx @@ -103,7 +103,6 @@ export const ProposalForm = (props: { }, ]) break - // TODO add other actions here default: break } @@ -188,7 +187,6 @@ export const ProposalForm = (props: { /> ) return null - // TODO add other message types default: return null } diff --git a/src/components/organisms/proposal-send-form.tsx b/src/components/organisms/proposal-send-form.tsx index 347e6ad..f120140 100644 --- a/src/components/organisms/proposal-send-form.tsx +++ b/src/components/organisms/proposal-send-form.tsx @@ -10,9 +10,10 @@ import { FormCard } from '@/molecules/form-card' // import { RadioGroupOptions } from '@/molecules/radio-group-options' import { SingleForm, type SingleFormValues } from './send-single-form' +// TODO(#47): add "multi" send to send action create flow // const sendOptions: { label: string; value: ProposalSendType }[] = [ // { label: 'Single', value: 'single' }, -// // { label: 'Multiple', value: 'multi' }, // TODO +// // { label: 'Multiple', value: 'multi' }, // ] export const ProposalSendForm = ({ @@ -51,6 +52,7 @@ export const ProposalSendForm = ({ return ( + {/*TODO(#47): add "multi" send to send action create flow*/} {/**/} {/* Type*/} {/* diff --git a/src/components/organisms/stake-undelegate-form.tsx b/src/components/organisms/stake-undelegate-form.tsx index bc19b6a..a843bc5 100644 --- a/src/components/organisms/stake-undelegate-form.tsx +++ b/src/components/organisms/stake-undelegate-form.tsx @@ -60,14 +60,14 @@ export const UndelegateForm = (props: { required name="amount" label="Amount" - balances={[]} // TODO: use amount staked on validator + balances={[]} // TODO(#127): use amount staked on validator /> diff --git a/src/components/organisms/stories/group-form.stories.tsx b/src/components/organisms/stories/group-form.stories.tsx index 3159351..d7147c7 100644 --- a/src/components/organisms/stories/group-form.stories.tsx +++ b/src/components/organisms/stories/group-form.stories.tsx @@ -4,7 +4,7 @@ import { defaultGroupFormValues } from 'util/form.defaults' import { GroupForm } from '../group-form' -// TODO: need to mock Wallet store for this to render +// TODO(#7): need to mock Wallet store for this to render export default { title: 'Organisms/Group Form', component: GroupForm, diff --git a/src/pages/group-details-page.tsx b/src/pages/group-details-page.tsx index a151c33..0dd6a7b 100644 --- a/src/pages/group-details-page.tsx +++ b/src/pages/group-details-page.tsx @@ -31,7 +31,7 @@ export default function GroupDetailsPage() { const handleUpdateMembers: GroupMembersTableProps['onSave'] = async (values) => { const msg = msgUpdateGroupMembers({ - groupId: group.id, // TODO: change to groupId? + groupId: group.id, admin: group.admin, members: values, }) diff --git a/src/pages/group-edit-page.tsx b/src/pages/group-edit-page.tsx index 10dc3db..02b3d50 100644 --- a/src/pages/group-edit-page.tsx +++ b/src/pages/group-edit-page.tsx @@ -71,7 +71,7 @@ export default function GroupEdit() { } if (prop === 'admin') { // disabled for now - // TODO: check if current admin, block in UI otherwise? maybe give disclosure + // TODO(#115): check if current admin, block in UI otherwise? maybe give disclosure // msg/updateGroupAdmin } if (prop === 'members') { diff --git a/src/pages/proposal-create-page.tsx b/src/pages/proposal-create-page.tsx index 37ece83..e861dad 100644 --- a/src/pages/proposal-create-page.tsx +++ b/src/pages/proposal-create-page.tsx @@ -109,7 +109,6 @@ export default function ProposalCreate() { if (!account?.address) { throwError('Error submitting proposal: No group policy found') } - // TODO: should this be a react-query mutation? const data = await createProposal({ actions, title, diff --git a/src/store/wallet.store.ts b/src/store/wallet.store.ts index a7ffeb6..283a732 100644 --- a/src/store/wallet.store.ts +++ b/src/store/wallet.store.ts @@ -8,7 +8,7 @@ import { logError, throwError } from 'util/errors' import { fetchValidators } from 'api/staking.actions' -// TODO: remove amino converter workaround #105 +// TODO(#105): remove amino converter workaround import { groupAminoConverters } from '../api/group.amino' import { Chain } from './chain.store' @@ -46,7 +46,7 @@ export async function bootstrapKeplr() { const [account] = await offlineSigner.getAccounts() - // TODO: remove amino converter workaround #105 + // TODO(#105): remove amino converter workaround // NOTE: We use the cosmos signing client that includes protobuf and amino // encoding for all cosmos modules included within @regen-network/api // const signingClient = await getSigningCosmosClient({ @@ -54,10 +54,10 @@ export async function bootstrapKeplr() { // signer: offlineSigner, // }) - // TODO: remove amino converter workaround #105 + // TODO(#105): remove amino converter workaround const aminoConverters = { ...cosmosAminoConverters, ...groupAminoConverters } - // TODO: remove amino converter workaround #105 + // TODO(#105): remove amino converter workaround // NOTE: We use signing stargate client so that we can set amino types const registry = new Registry(cosmosProtoRegistry) const signingClient = await SigningStargateClient.connectWithSigner( @@ -81,7 +81,7 @@ export async function bootstrapKeplr() { Chain.stakeDenom = Chain.active.stakeCurrency.coinMinimalDenom Chain.fee = { amount: coins(10, Chain.active.feeCurrencies[0].coinDenom), - gas: '2000000', // TODO how do I calculate this? + gas: '2000000', } Wallet.keplrStatus = 'ready' fetchValidators() diff --git a/src/tests/api.utils.test.ts b/src/tests/api.utils.test.ts index 55cd5cb..560e8ca 100644 --- a/src/tests/api.utils.test.ts +++ b/src/tests/api.utils.test.ts @@ -5,7 +5,7 @@ import { GroupInfoSDKType, UIGroup, UIGroupMetadata } from 'types' import { toUIGroup } from 'api/group.utils' -// TODO: move these to reusable stubs +// TODO(#128): move these to reusable stubs const date = new Date(2022, 1, 1) const dateTime = date.getTime() @@ -33,7 +33,7 @@ const stubUIGroup: UIGroup = { version: Long.fromString('1'), } -// TODO - valtio messes this up +// TODO(#128): valtio messes this up describe.skip('Group Transforms', () => { it.skip('works on normal chain group', () => { expect(toUIGroup(stubGroup)).toEqual(stubUIGroup) diff --git a/src/types/policy.types.ts b/src/types/policy.types.ts index e33e3fe..f68b0a3 100644 --- a/src/types/policy.types.ts +++ b/src/types/policy.types.ts @@ -28,8 +28,6 @@ export type UIGroupPolicyInfo = Omit & { } type UIDecisionPolicyWindows = { - // TODO: should this be a string? number seems better for UI, but conversion - // might have more side-effects [K in keyof DecisionPolicyWindows]: string } diff --git a/src/types/proposal.types.ts b/src/types/proposal.types.ts index d3cf2d5..1572006 100644 --- a/src/types/proposal.types.ts +++ b/src/types/proposal.types.ts @@ -29,13 +29,13 @@ export interface UIProposal export type ProposalAction = { /** for handling add / remove behavior + passing to nested forms for submit handler */ id: string - type: 'send' | 'stake' | 'text' | 'update-group' // TODO: add other event types - values: ProposalSendFormValues | ProposalStakeFormValues | ProposalUpdateGroupFormValues // TODO: types for other form actions + type: 'send' | 'stake' | 'text' | 'update-group' + values: ProposalSendFormValues | ProposalStakeFormValues | ProposalUpdateGroupFormValues } -export type ProposalSendType = 'single' // TODO: "multi" send +export type ProposalSendType = 'single' -export type ProposalSendFormValues = SingleFormValues // TODO: "multi" send +export type ProposalSendFormValues = SingleFormValues export type ProposalStakeType = 'delegate' | 'redelegate' | 'undelegate' | 'claim' @@ -60,6 +60,6 @@ export type { UndelegateFormValues, } -/** TODO: in v0.47, this data will live directly on a proposal */ +/** TODO(#72): in v0.47, this data will live directly on a proposal */ export type { UIProposalMetadata } export type { ProposalFormValues } from '@/organisms/proposal-form' diff --git a/src/util/enums.ts b/src/util/enums.ts index 3f83560..4d27c4c 100644 --- a/src/util/enums.ts +++ b/src/util/enums.ts @@ -1,7 +1,7 @@ import type { ProposalStatusType, VoteOptionType } from 'types' /** - * TODO: the generated `ProposalStatus` enum returns number values, but the + * TODO(#124): the generated `ProposalStatus` enum returns number values, but the * actual API response is the keys of those values. We also can't import that * enum directly because of a combo of vite and the generated code - this is a * copy-pasted version of the enum from the SDK, converted to a normal object, @@ -35,7 +35,7 @@ const GeneratedProposalStatus: typeof ProposalStatusType = { UNRECOGNIZED: -1, } -/** TODO: VoteOption won't properly import into vite as an export directly from +/** TODO(#124): VoteOption won't properly import into vite as an export directly from * the generated lib - this is copy-pasted */ export const VoteOption: typeof VoteOptionType = { /** diff --git a/src/util/errors.ts b/src/util/errors.ts index 3a00e6d..b40bf43 100644 --- a/src/util/errors.ts +++ b/src/util/errors.ts @@ -12,7 +12,7 @@ export function isErrorWithMessage(error: unknown): error is ErrorWithMessage { } function reportError({ message }: { message: string }): void { - // TODO - set up logging? + // TODO(#125): set up logging console.error(message) } diff --git a/src/util/validation/metadata.ts b/src/util/validation/metadata.ts index 6484ffe..f3ef40f 100644 --- a/src/util/validation/metadata.ts +++ b/src/util/validation/metadata.ts @@ -44,7 +44,7 @@ export async function getGroupMetadata( if (isIpfsProtocol(metadata)) { try { const ipfsData = await fetchIpfsData(getIpfsCID(metadata)) - // TODO: we aren't handling IPFS metadata that's outside the shape of our + // TODO(#126): we aren't handling IPFS metadata that's outside the shape of our // expected data - could possibly add to the `other` field, or something // similar if we want to support in the future (add else block here) if (isGroupMetadata(ipfsData)) return ipfsData diff --git a/src/util/validation/zod.ts b/src/util/validation/zod.ts index 427a79d..cd0ac6e 100644 --- a/src/util/validation/zod.ts +++ b/src/util/validation/zod.ts @@ -6,7 +6,7 @@ const bech32Address = z.string().refine(isBech32Address, 'Must be a Bech32 addr const member = z.object({ address: bech32Address, weight: z.number().min(0, 'Must be 0 or a positive number'), - // metadata: z.string().optional() // TODO: ? + // metadata: z.string().optional() // TODO(#97): support for group member metadata }) const members = member.array().min(1, 'Must have at least one member') const json = z.string().refine(isJson, 'Must be a valid JSON string') @@ -17,7 +17,7 @@ const name = z const description = z .string() .min(4, 'Description is too short') - .max(320, 'Description is too long') // TODO is this too short? + .max(320, 'Description is too long') const percent = z .number() .min(1, 'Must be greater than zero')