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: 1 addition & 7 deletions apps/dashboard/src/@/api/universal-bridge/developer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ type Webhook = {
version?: number; // TODO (UB) make this mandatory after migration
};

export async function getWebhooks(props: {
clientId: string;
}) {
export async function getWebhooks() {
const authToken = await getAuthToken();
const res = await fetch(`${UB_BASE_URL}/v1/developer/webhooks`, {
method: "GET",
headers: {
"Content-Type": "application/json",
"x-client-id-override": props.clientId,
Authorization: `Bearer ${authToken}`,
},
});
Expand Down Expand Up @@ -54,7 +51,6 @@ export async function createWebhook(props: {
}),
headers: {
"Content-Type": "application/json",
"x-client-id-override": props.clientId,
Authorization: `Bearer ${authToken}`,
},
});
Expand Down Expand Up @@ -109,7 +105,6 @@ export async function getFees(props: {
headers: {
"Content-Type": "application/json",
"x-team-id": props.teamId,
"x-client-id-override": props.clientId,
Authorization: `Bearer ${authToken}`,
},
});
Expand All @@ -134,7 +129,6 @@ export async function updateFee(props: {
method: "PUT",
headers: {
"Content-Type": "application/json",
"x-client-id-override": props.clientId,
"x-team-id": props.teamId,
Authorization: `Bearer ${authToken}`,
},
Expand Down
7 changes: 2 additions & 5 deletions apps/dashboard/src/@/api/universal-bridge/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use server";
import { getAuthToken } from "app/(app)/api/lib/getAuthToken";
import { DASHBOARD_THIRDWEB_SECRET_KEY } from "@/constants/server-envs";
import { UB_BASE_URL } from "./constants";

export type TokenMetadata = {
Expand All @@ -12,10 +12,8 @@ export type TokenMetadata = {
};

export async function getUniversalBridgeTokens(props: {
clientId?: string;
chainId?: number;
}) {
const authToken = await getAuthToken();
const url = new URL(`${UB_BASE_URL}/v1/tokens`);

if (props.chainId) {
Expand All @@ -27,8 +25,7 @@ export async function getUniversalBridgeTokens(props: {
method: "GET",
headers: {
"Content-Type": "application/json",
"x-client-id-override": props.clientId,
Authorization: `Bearer ${authToken}`,
"x-secret-key": DASHBOARD_THIRDWEB_SECRET_KEY,
} as Record<string, string>,
});

Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/src/@/components/blocks/TokenSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function TokenSelector(props: {
enabled?: boolean;
}) {
const { tokens, isFetching } = useTokensData({
clientId: props.client.clientId,
chainId: props.chainId,
enabled: props.enabled,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ export function PayWebhooksPage(props: PayWebhooksPageProps) {
const webhooksQuery = useQuery({
queryKey: ["webhooks", props.clientId],
queryFn: async () => {
return await getWebhooks({
clientId: props.clientId,
});
return await getWebhooks();
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export function CheckoutLinkForm() {
<CreditCardIcon className="size-5 sm:size-6" />
</div>
<CardTitle className="text-center sm:text-left">
Create a Checkout Link
Create a Payment Link
</CardTitle>
</div>
</CardHeader>
Expand Down Expand Up @@ -300,6 +300,7 @@ export function CheckoutLinkForm() {
value={image || imageUri}
className="!rounded-md aspect-square h-24 w-full"
isDisabled={uploadingImage}
isDisabledText="Uploading..."
selectOrUpload="Upload"
helperText="image"
fileUrl={imageUri}
Expand Down
15 changes: 12 additions & 3 deletions apps/dashboard/src/app/checkout/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getAuthToken } from "app/(app)/api/lib/getAuthToken";
import { loginRedirect } from "app/(app)/login/loginRedirect";
import type { Metadata } from "next";
import { createThirdwebClient, defineChain, getContract } from "thirdweb";
import { getCurrencyMetadata } from "thirdweb/extensions/erc20";
Expand Down Expand Up @@ -26,11 +28,18 @@ export default async function RoutesPage({

// If no query parameters are provided, show the form
if (
!params.chainId ||
!params.recipientAddress ||
!params.tokenAddress ||
!params.chainId &&
!params.recipientAddress &&
!params.tokenAddress &&
!params.amount
) {
const authToken = await getAuthToken();

if (!authToken) {
const searchParams = new URLSearchParams(params);
return loginRedirect(`/checkout?${searchParams.toString()}`);
}

return <CheckoutLinkForm />;
}

Expand Down
5 changes: 2 additions & 3 deletions apps/dashboard/src/hooks/tokens/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,12 @@ const tokensStore = /* @__PURE__ */ createStore<TokenMetadata[]>([]);
const structuredTokensStore = /* @__PURE__ */ createStructuredTokensStore();

export function useTokensData({
clientId,
chainId,
enabled,
}: { clientId: string; chainId?: number; enabled?: boolean }) {
}: { chainId?: number; enabled?: boolean }) {
const tokensQuery = useQuery({
queryKey: ["universal-bridge-tokens", chainId],
queryFn: () => getUniversalBridgeTokens({ clientId, chainId }),
queryFn: () => getUniversalBridgeTokens({ chainId }),
enabled,
});

Expand Down
Loading