Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spaceward): fix key creation on small resolutions #893

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading