Skip to content

Commit

Permalink
implement deploying to vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteAtATime committed Apr 17, 2024
1 parent 40c38ea commit 67c232f
Show file tree
Hide file tree
Showing 7 changed files with 1,476 additions and 91 deletions.
1 change: 1 addition & 0 deletions packages/svelte/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.vercel
7 changes: 5 additions & 2 deletions packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
"format": "prettier --write .",
"vercel": "vercel"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
Expand All @@ -35,6 +36,7 @@
"tslib": "^2.4.1",
"type-fest": "^4.14.0",
"typescript": "^5.0.0",
"vercel": "^34.0.0",
"vite": "^5.0.3"
},
"type": "module",
Expand All @@ -48,6 +50,7 @@
"@wagmi/core": "^2.6.13",
"@web3modal/wagmi": "^4.1.3",
"abitype": "^1.0.2",
"blo": "^1.1.1"
"blo": "^1.1.1",
"viem": "^2.9.20"
}
}
35 changes: 16 additions & 19 deletions packages/svelte/src/lib/runes/scaffoldReadContract.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,22 @@ export const createScaffoldReadContract = <
const targetNetwork = $derived.by(createTargetNetwork());

const result = $derived.by(
createReadContract(
() =>
({
chainId: targetNetwork.id,
functionName,
address: deployedContract?.address,
abi: deployedContract?.abi,
watch: true,
args: args,
value: value,
enabled: !Array.isArray(args) || !args.some(arg => arg === undefined),
...(readConfig as any),
}) as () => Omit<ReturnType<CreateReadContractReturnType>, "data" | "refetch"> & {
data: AbiFunctionReturnType<ContractAbi, TFunctionName> | undefined;
refetch: (
options?: RefetchOptions | undefined,
) => Promise<QueryObserverResult<AbiFunctionReturnType<ContractAbi, TFunctionName>, ReadContractErrorType>>;
},
),
createReadContract(() => ({
chainId: targetNetwork.id,
functionName,
address: deployedContract?.address,
abi: deployedContract?.abi,
watch: true,
args: args,
value: value,
enabled: !Array.isArray(args) || !args.some(arg => arg === undefined),
...(readConfig as any),
})) as () => Omit<ReturnType<CreateReadContractReturnType>, "data" | "refetch"> & {
data: AbiFunctionReturnType<ContractAbi, TFunctionName> | undefined;
refetch: (
options?: RefetchOptions | undefined,
) => Promise<QueryObserverResult<AbiFunctionReturnType<ContractAbi, TFunctionName>, ReadContractErrorType>>;
},
);

return () => result;
Expand Down
3 changes: 1 addition & 2 deletions packages/svelte/src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// @ts-expect-error - No types generated by vercel
import { VERCEL_URL, PORT } from "$env/static/private";
import { VERCEL_URL } from "$env/static/private";
import type { LayoutServerLoad } from "./$types";

export const load: LayoutServerLoad = () => {
return {
vercelUrl: VERCEL_URL,
port: PORT,
};
};
4 changes: 2 additions & 2 deletions packages/svelte/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import { wagmiConfig } from "$lib/wagmi";
import { Toaster } from "@leodog896/svelte-french-toast";
const { data }: { data: { vercelUrl?: string; port?: number } } = $props();
const { data }: { data: { vercelUrl?: string } } = $props();
const baseUrl = $derived(data.vercelUrl ? `https://${data.vercelUrl}` : `http://localhost:${data.port || 5173}`);
const baseUrl = $derived(data.vercelUrl ? `https://${data.vercelUrl}` : `http://localhost:5173`);
const metadata = $derived({
title: "Scaffold-ETH 2 App",
Expand Down
4 changes: 4 additions & 0 deletions packages/svelte/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"installCommand": "yarn install"
}

Loading

0 comments on commit 67c232f

Please sign in to comment.