Skip to content

siwa updates and new article #7197

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

Merged
merged 1 commit into from
May 30, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function CustomChatContentLoggedIn(props: {
message:
messageToSend.content.find((x) => x.type === "text")?.text ?? "",
conversationId: sessionId,
source: "dashboard-support",
};
const apiUrl = process.env.NEXT_PUBLIC_SIWA_URL;
const response = await fetch(`${apiUrl}/v1/chat`, {
Expand Down
7 changes: 3 additions & 4 deletions apps/portal/src/app/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
} from "@/components/ui/dropdown-menu";
import clsx from "clsx";
import {
BotIcon,
ChevronDownIcon,
MenuIcon,
MessageCircleIcon,
TableOfContentsIcon,
} from "lucide-react";
import Link from "next/link";
Expand Down Expand Up @@ -222,12 +222,11 @@

<div className="hidden xl:block">
<Button
variant="primary"
onClick={() => {
router.push("/chat");
}}
>
<BotIcon className="mr-2 size-4" />
<MessageCircleIcon className="mr-2 size-4" />
Ask AI
</Button>
</div>
Expand All @@ -254,7 +253,7 @@
className="p-2"
onClick={() => router.push("/chat")}
>
<BotIcon className="size-7" />
<MessageCircleIcon className="size-7" />
</Button>
<Button
variant="ghost"
Expand Down Expand Up @@ -334,7 +333,7 @@

{/* Mobile menu */}
{showBurgerMenu && (
<div className="fixed inset-0 top-sticky-top-height z-50 overflow-auto bg-card p-6 xl:hidden">

Check warning on line 336 in apps/portal/src/app/Header.tsx

View workflow job for this annotation

GitHub Actions / Lint Packages

Classname 'z-50' is not a Tailwind CSS class!

Check warning on line 336 in apps/portal/src/app/Header.tsx

View workflow job for this annotation

GitHub Actions / Lint Packages

Classname 'z-50' is not a Tailwind CSS class!
<div className="flex flex-col gap-6">
<div className="flex flex-col gap-4">
<h3 className="font-semibold text-lg">Products</h3>
Expand Down
4 changes: 4 additions & 0 deletions apps/portal/src/app/knowledge-base/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export const sidebar: SideBar = {
name: "Batch Upload",
href: "/knowledge-base/troubleshoot/contracts/batch-upload",
},
{
name: "Transfer Amount Exceeds Allowance",
href: "/knowledge-base/troubleshoot/contracts/erc20-transfer-allowance",
},
],
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ERC20 - Transfer Amount Exceeds Allowance

## What it means

The "ERC20: transfer amount exceeds allowance" error occurs when trying to transfer ERC20 tokens beyond the allowed limit set by the token owner. ERC20 tokens use an allowance system that grants specific addresses permission to transfer a certain amount of tokens on behalf of the owner.

## How to fix it

1. Check allowance: Use the thirdweb Dashboard to verify the current allowance for the sender’s address.
2. Increase allowance: If the allowance is too low, the token owner should call the approve function to increase it.
3. Transfer tokens: Once the allowance is updated, retry the transfer using transferFrom or transfer.

Following these steps should resolve the error. Ensure the allowance covers the transfer amount before initiating.

Can't get this working? [**Contact our support team**](https://thirdweb.com/support) for help.
9 changes: 9 additions & 0 deletions apps/portal/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Grid, Heading, SDKCard } from "@/components/Document";
import { Button } from "@/components/ui/button";
import { MessageCircleIcon } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { UnityIcon } from "../icons";
Expand Down Expand Up @@ -40,6 +42,13 @@ function Hero() {
<p className="mb-8 max-w-md text-lg text-muted-foreground leading-normal">
Development framework for building onchain apps, games, and agents.
</p>

<Link href="/chat">
<Button className="flex items-center gap-2">
<MessageCircleIcon className="size-4" />
Ask AI
</Button>
</Link>
</div>
</div>

Expand Down
29 changes: 29 additions & 0 deletions apps/portal/src/components/AI/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const getChatResponse = async (
const payload = {
message: userMessage,
conversationId: sessionId,
source: "portal",
};
const response = await fetch(`${apiUrl}/v1/chat`, {
method: "POST",
Expand Down Expand Up @@ -41,3 +42,31 @@ export const getChatResponse = async (
return null;
}
};

export const sendFeedback = async (
conversationId: string,
feedbackRating: 1 | -1,
) => {
try {
const response = await fetch(`${apiUrl}/v1/chat/feedback`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-service-api-key": serviceKey,
},
body: JSON.stringify({ conversationId, feedbackRating }),
});

if (!response.ok) {
const error = await response.text();
throw new Error(`Failed to send feedback: ${response.status} - ${error}`);
}
return true;
} catch (error) {
console.error(
"Feedback API error:",
error instanceof Error ? error.message : "Unknown error",
);
return false;
}
};
59 changes: 51 additions & 8 deletions apps/portal/src/components/AI/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { LoadingDots } from "@/components/ui/LoadingDots";
import { Button } from "@/components/ui/button";
import { AutoResizeTextarea } from "@/components/ui/textarea";
import { cn } from "@/lib/utils";
import { ArrowUpIcon, BotIcon } from "lucide-react";
import { MessageCircleIcon } from "lucide-react";
import { ArrowUpIcon, ThumbsDownIcon, ThumbsUpIcon } from "lucide-react";
import { usePostHog } from "posthog-js/react";
import {
type ChangeEvent,
Expand All @@ -15,13 +16,14 @@ import {
useRef,
useState,
} from "react";
import { getChatResponse } from "./api";
import { getChatResponse, sendFeedback } from "./api";

interface Message {
id: string;
role: "user" | "assistant";
content: string;
isLoading?: boolean;
feedback?: 1 | -1;
}

const predefinedPrompts = [
Expand All @@ -36,7 +38,7 @@ function ChatEmptyState({
}: { onPromptClick: (prompt: string) => void }) {
return (
<div className="flex flex-col items-center justify-center space-y-8 py-16 text-center">
<BotIcon className="size-16" />
<MessageCircleIcon className="size-16" />

<h2 className="font-semibold text-3xl text-foreground">
How can I help you <br />
Expand Down Expand Up @@ -153,6 +155,21 @@ export function Chat() {
}
};

const handleFeedback = async (messageId: string, feedback: 1 | -1) => {
if (!conversationId) return; // Don't send feedback if no conversation

try {
await sendFeedback(conversationId, feedback);
setMessages((prevMessages) =>
prevMessages.map((msg) =>
msg.id === messageId ? { ...msg, feedback } : msg,
),
);
} catch (_e) {
// Optionally handle error
}
};

return (
<div
className="mx-auto flex size-full flex-col overflow-hidden lg:min-w-[800px] lg:max-w-5xl"
Expand Down Expand Up @@ -183,11 +200,37 @@ export function Chat() {
{message.role === "assistant" && message.isLoading ? (
<LoadingDots />
) : (
<StyledMarkdownRenderer
text={message.content}
isMessagePending={false}
type={message.role}
/>
<>
<StyledMarkdownRenderer
text={message.content}
isMessagePending={false}
type={message.role}
/>
{message.role === "assistant" && !message.isLoading && (
<div className="mt-2 flex gap-2">
{!message.feedback && (
<>
<button
type="button"
aria-label="Thumbs up"
className="text-muted-foreground transition-colors hover:text-green-500"
onClick={() => handleFeedback(message.id, 1)}
>
<ThumbsUpIcon className="size-5" />
</button>
<button
type="button"
aria-label="Thumbs down"
className="text-muted-foreground transition-colors hover:text-red-500"
onClick={() => handleFeedback(message.id, -1)}
>
<ThumbsDownIcon className="size-5" />
</button>
</>
)}
</div>
)}
</>
)}
</div>
</div>
Expand Down
Binary file added apps/portal/src/icons/siwa-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading