Skip to content

Commit

Permalink
chore: clean up todos throughout repo (#129)
Browse files Browse the repository at this point in the history
* chore: clean up todos throughout repo

* Update src/components/organisms/proposal-send-form.tsx

Co-authored-by: Marie Gauthier <[email protected]>

* Update src/components/organisms/proposal-send-form.tsx

Co-authored-by: Marie Gauthier <[email protected]>

---------

Co-authored-by: Marie Gauthier <[email protected]>
  • Loading branch information
ryanchristo and blushi authored Jul 31, 2023
1 parent 7525b56 commit dad0e76
Show file tree
Hide file tree
Showing 21 changed files with 41 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/api/group.amino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
Expand Down
8 changes: 6 additions & 2 deletions src/api/proposal.messages.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/api/proposal.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`)
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/group-members-fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const GroupMembersFields = () => {
directly add to it */}
<FieldControl
required
error={errors.members as FieldError} // TODO fix type cast
error={errors.members as FieldError}
name="memberAddr"
label="Add member accounts"
helperText="Input the addresses of the members of this group."
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/error-fallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getErrorText(error: unknown): { text: string; message?: string } {

export const ErrorFallback = () => {
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)
Expand Down
2 changes: 0 additions & 2 deletions src/components/organisms/proposal-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export const ProposalForm = (props: {
},
])
break
// TODO add other actions here
default:
break
}
Expand Down Expand Up @@ -188,7 +187,6 @@ export const ProposalForm = (props: {
/>
)
return null
// TODO add other message types
default:
return null
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/organisms/proposal-send-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand Down Expand Up @@ -51,6 +52,7 @@ export const ProposalSendForm = ({
return (
<FormCard title="Send">
<Stack spacing={SPACING.formStack}>
{/*TODO(#47): add "multi" send to send action create flow*/}
{/*<FormControl>*/}
{/* <FormLabel>Type</FormLabel>*/}
{/* <RadioGroup*/}
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/stake-redelegate-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ export const RedelegateForm = (props: {
required
name="amount"
label="Amount"
balances={[]} // TODO: use amount staked on validator
balances={[]} // TODO(#127): use amount staked on validator
/>
</GridItem>
<GridItem>
<DenomField
required
name="denom"
balances={[]} // TODO: use amount staked on validator
balances={[]} // TODO(#127): use amount staked on validator
/>
</GridItem>
</Grid>
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/stake-undelegate-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
/>
</GridItem>
<GridItem>
<DenomField
required
name="denom"
balances={[]} // TODO: use amount staked on validator
balances={[]} // TODO(#127): use amount staked on validator
/>
</GridItem>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/stories/group-form.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/group-details-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down
2 changes: 1 addition & 1 deletion src/pages/group-edit-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
1 change: 0 additions & 1 deletion src/pages/proposal-create-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/store/wallet.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -46,18 +46,18 @@ 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({
// rpcEndpoint: Chain.active.rpc,
// 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(
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/tests/api.utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/types/policy.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export type UIGroupPolicyInfo = Omit<GroupPolicyInfo, 'decisionPolicy'> & {
}

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
}

Expand Down
10 changes: 5 additions & 5 deletions src/types/proposal.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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'
4 changes: 2 additions & 2 deletions src/util/enums.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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 = {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/util/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/validation/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/util/validation/zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down

0 comments on commit dad0e76

Please sign in to comment.