Skip to content
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
8 changes: 4 additions & 4 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Create Release PR
on:
push:
branches: [ main ]
branches: [ dev ]

permissions:
contents: write
Expand All @@ -28,8 +28,8 @@ jobs:
GH_TOKEN: ${{ secrets.GHA_CREATE_PR }}
run: |
gh pr create \
--base release \
--head main \
--base main \
--head dev \
--title "chore: new release" \
--body "Automated PR from main to release" \
--body "Automated PR from dev to main (release)" \
--label "automated pr"
23 changes: 21 additions & 2 deletions components/collections/collection-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import request from "graphql-request";
import { isValidHypercertId } from "@/lib/utils";
import { useQuery } from "@tanstack/react-query";
import { parseClaimOrFractionId } from "@hypercerts-org/sdk";
import React, { ReactNode } from "react";
import React, { ReactNode, useEffect } from "react";
import { ExternalLink, InfoIcon, LoaderCircle, Trash2Icon } from "lucide-react";
import Link from "next/link";
import { useCreateHyperboard, useUpdateHyperboard } from "@/collections/hooks";
Expand All @@ -34,6 +34,7 @@ import { BlueprintFragment } from "@/blueprints/blueprint.fragment";
import { isParseableNumber } from "@/lib/isParseableInteger";
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
import { ImageUploader, readAsBase64 } from "../image-uploader";
import { useAccountStore } from "@/lib/account-store";

const idSchema = z
.string()
Expand Down Expand Up @@ -229,6 +230,13 @@ export const CollectionForm = ({
});
const { mutateAsync: createHyperboard } = useCreateHyperboard();
const { mutateAsync: updateHyperboard } = useUpdateHyperboard();
const { selectedAccount } = useAccountStore();
const isSafeAccount = selectedAccount?.type === "safe";

// Force form validation when account type changes
useEffect(() => {
form.trigger();
}, [isSafeAccount, form]);

const { fields, append, remove } = useFieldArray({
control: form.control,
Expand Down Expand Up @@ -276,7 +284,10 @@ export const CollectionForm = ({
form.formState.errors["newFactor"] === undefined;

const canCreateCollection =
form.formState.isValid && !isFetching && (!newId || newId === "");
form.formState.isValid &&
!isFetching &&
(!newId || newId === "") &&
!isSafeAccount;

const buttonText = form.watch("id")
? "Update collection"
Expand All @@ -285,6 +296,14 @@ export const CollectionForm = ({
return (
<section className="flex flex-col-reverse md:flex-row space-x-4 items-stretch md:justify-start">
<section className="flex flex-col space-y-4 flex-1 md:pr-5 md:border-r-[1.5px] md:border-slate-200">
{isSafeAccount && (
<div className="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-4">
<div className="text-sm text-yellow-700">
The feature to create collections isn&rsquo;t yet released for
multi-sigs. Please switch to your normal wallet...
</div>
</div>
)}
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<section className="space-y-8">
Expand Down
16 changes: 12 additions & 4 deletions lib/account-store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { create } from "zustand";
import { persist } from "zustand/middleware";

export type AccountType = "eoa" | "safe";

Expand All @@ -12,10 +13,17 @@ interface AccountState {
setSelectedAccount: (account: Account | null) => void;
}

export const useAccountStore = create<AccountState>((set) => ({
selectedAccount: null,
setSelectedAccount: (account) => set({ selectedAccount: account }),
}));
export const useAccountStore = create<AccountState>()(
persist(
(set) => ({
selectedAccount: null,
setSelectedAccount: (account) => set({ selectedAccount: account }),
}),
{
name: "selected-account-storage",
},
),
);

export function selectWalletAccount(address: string) {
useAccountStore.setState({
Expand Down