Skip to content

Commit

Permalink
feat(spaceward): fix key creation on small resolutions (#893)
Browse files Browse the repository at this point in the history
* fix #884

* fix #875
  • Loading branch information
alex-nax authored Sep 25, 2024
1 parent 15314d2 commit 08286fa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
5 changes: 3 additions & 2 deletions spaceward/src/components/TxMsgDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
wardenProtoRegistry,
} from "@wardenprotocol/wardenjs";
import { useQueryHooks } from "@/hooks/useClient";
import { extReplacer } from "@/utils/formatting";

export function TxMsgDetails({ msg }: { msg: DecodeObject }) {
try {
Expand Down Expand Up @@ -325,8 +326,8 @@ function MsgFallbackDetails({ type, msg }: { type: string; msg: any }) {
</CardHeader>
<CardContent>
{Object.entries(msg).map(([key, value]) => (
<CardRow label={key} key={key}>
{String(value)}
<CardRow labelClassName="!w-52" label={key} key={key}>
{JSON.stringify(value, extReplacer, 2)}
</CardRow>
))}
</CardContent>
Expand Down
2 changes: 1 addition & 1 deletion spaceward/src/features/keys/Keys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ const KeyCard = ({ data: { addresses, key } }: { data: QueryKeyResponse }) => {
) : (
<div className="flex justify-between items-center w-full">
<input
className="font-display text-xl font-bold tracking-[0.1px] focus-visible:!ring-0 focus-visible:!ring-offset-0 !ring-0 border-0 outline-0"
className="font-display text-xl font-bold tracking-[0.1px] focus-visible:!ring-0 focus-visible:!ring-offset-0 !ring-0 border-0 outline-0 max-w-[80%]"
value={nameInput}
onChange={(e) =>
setNameInput(e.target.value)
Expand Down
15 changes: 2 additions & 13 deletions spaceward/src/hooks/state.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { extReplacer } from "@/utils/formatting";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useCallback, useEffect, useRef } from "react";

Expand Down Expand Up @@ -114,19 +115,7 @@ export function createPersistantState<T>(

window.localStorage.setItem(
lsKey,
JSON.stringify(_data, (_, v) =>
typeof v === "bigint"
? {
type: "bigint",
value: v.toString(),
}
: v instanceof Uint8Array
? {
type: "Uint8Array",
value: Array.from(v)
}
: v,
),
JSON.stringify(_data, extReplacer),
);
queryClient.setQueryData([prefix, queryKey], _data);
},
Expand Down
15 changes: 14 additions & 1 deletion spaceward/src/utils/formatting.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { KeyType } from "@wardenprotocol/wardenjs/codegen/warden/warden/v1beta3/key";
import { ActionStatus } from "@wardenprotocol/wardenjs/codegen/warden/act/v1beta1/action"
import { ActionStatus } from "@wardenprotocol/wardenjs/codegen/warden/act/v1beta1/action";

export function prettyKeyType(type: KeyType | string) {
switch (type) {
Expand Down Expand Up @@ -28,3 +28,16 @@ export function prettyActionStatus(s: ActionStatus | string) {
export function prettyBytes(b: Uint8Array) {
return b.reduce((s, v) => s + v.toString(16).padStart(2, "0"), "");
}

export const extReplacer = (_: any, v: any) =>
typeof v === "bigint"
? {
type: "bigint",
value: v.toString(),
}
: v instanceof Uint8Array
? {
type: "Uint8Array",
value: Array.from(v),
}
: v;

0 comments on commit 08286fa

Please sign in to comment.