Skip to content

Commit

Permalink
fix: various bug fixes (#30)
Browse files Browse the repository at this point in the history
* fix: boolean attributes not showing in entity views

* fix: cql not in sidebar if there is no registered queries

* fix: remove success field from receipt.result as it doesn't belong there

* style: formatting

---------

Co-authored-by: Ryan Martin <rmrt1n@users.noreply.github.com>
  • Loading branch information
rmrt1n and rmrt1n authored Apr 22, 2024
1 parent bf05998 commit 679e8b1
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/entity-views.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const formatAttribute = (attr: any): React.ReactNode => {
case 'number':
return <span className="text-orange-500">{attr}</span>
case 'boolean':
return <span className="text-blue-500">{attr}</span>
return <span className="text-blue-500">{attr ? 'true' : 'false'}</span>
default:
return <span>{JSON.stringify(attr)}</span>
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/sidebar/persona.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function CreatePersona() {
}

const result = receipt.receipts[0]
if (!result.result || !result.result.success) {
if (!result.result) {
const errors = result.errors?.join('\n')
toast({
title: 'Error creating persona',
Expand Down
6 changes: 3 additions & 3 deletions src/components/sidebar/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
FormMessage,
} from '@/components/ui/form'
import { useCardinal } from '@/lib/cardinal-provider'
import { gameQueryQueryOptions } from '@/lib/query-options'
import { gameQueryQueryOptions, routeCql } from '@/lib/query-options'
import { ComponentProperty, WorldField } from '@/lib/types'

import { defaultValues, formSchema, formatName, goTypeToInputComponent } from './utils'
Expand All @@ -34,8 +34,9 @@ export function SidebarQueries({ queries }: SidebarQueriesProps) {
fields: {
CQL: 'string',
},
url: '/cql',
url: routeCql,
}
queries = [...queries, cql]

return (
<Accordion collapsible type="single" defaultValue="default">
Expand All @@ -56,7 +57,6 @@ export function SidebarQueries({ queries }: SidebarQueriesProps) {
</div>
) : (
<Accordion collapsible type="single" className="space-y-2">
<Query query={cql} />
{queries.map((q, i) => (
<Query key={i} query={q} />
))}
Expand Down
1 change: 1 addition & 0 deletions src/lib/query-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { sleep } from '@/lib/utils'
export const routeDebugState = '/debug/state'
export const routeHealth = '/health'
export const routeWorld = '/world'
export const routeCql = '/cql'
export const routeMsgCreatePersona = '/tx/persona/create-persona'
export const routeMsgAuthorizePersonaAddress = '/tx/game/authorize-persona-address'
export const routeQryPersonaSigner = '/query/persona/signer'
Expand Down
4 changes: 1 addition & 3 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export interface Receipt {
| {
txHash: string
tick: number
result: {
success: boolean
} | null
result: object | null
errors: string[] | null
}[]
| null
Expand Down
2 changes: 1 addition & 1 deletion src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function Root() {

if (!receipt.receipts) return
const result = receipt.receipts[0]
if (result.result && result.result.success) {
if (result.result) {
const newPersona = { personaTag, privateKey, address, nonce: nonce + 1 }
setPersonas([...personas, newPersona])
}
Expand Down

0 comments on commit 679e8b1

Please sign in to comment.