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

Sunset NextJS dependency #1149

Merged
merged 24 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
15 changes: 12 additions & 3 deletions examples/next/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@
{
"name": "next"
}
]
],
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules", "tests"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules",
"tests"
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"e2e": "turbo build:deps dev e2e",
"e2e:ui": "turbo build:deps dev e2e:ui",
"lint": "turbo lint format:check",
"format": "turbo format",
"format": "turbo format lint:fix",
"clean": "git clean -xdf && pnpm store prune",
"release": "pnpm build && pnpm changeset publish",
"prerelease": "pnpm build && pnpm changeset publish --tag prerelease",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import config from "./index.js";
export default [...config];
28 changes: 28 additions & 0 deletions packages/eslint/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";

export default tseslint.config(
{ ignores: ["dist", "storybook-static/"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
},
);
26 changes: 26 additions & 0 deletions packages/eslint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@cartridge/eslint",
"private": true,
"version": "0.5.5",
"type": "module",
"exports": {
".": "./index.js"
},
"files": [
"index.js",
"eslint.config.js"
],
"scripts": {
"lint": "eslint ."
},
"peerDependencies": {
"eslint": ">= 9"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.13.0",
"typescript-eslint": "^8.18.0"
}
}
22 changes: 11 additions & 11 deletions packages/keychain/.env.development
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
NEXT_PUBLIC_ORIGIN="http://localhost:3001"
NEXT_PUBLIC_RP_ID="localhost"
NEXT_PUBLIC_ADMIN_URL="http://localhost:3002"
NEXT_PUBLIC_CARTRIDGE_API_URL="http://localhost:8000"
# NEXT_PUBLIC_ETH_RPC_MAINNET="https://eth-mainnet.g.alchemy.com/v2/OGPRMquXP3K7oTkLrmVZpjCd1DswtYz3"
# NEXT_PUBLIC_ETH_RPC_SEPOLIA="https://eth-sepolia.g.alchemy.com/v2/mURnclB5pn5elDfyzgTN4W2GR-rOYevI"
NEXT_PUBLIC_RPC_MAINNET="http://localhost:8001/x/starknet/mainnet"
NEXT_PUBLIC_RPC_SEPOLIA="http://localhost:8001/x/starknet/sepolia"
NEXT_PUBLIC_STRIPE_PAYMENT="http://localhost:8000/stripe/payment-intent"
NEXT_PUBLIC_POSTHOG_KEY=phc_UWaJajNQ00PjHhveZ81SJ2zVtBicKrzewdZHGiyavQQ
NEXT_PUBLIC_POSTHOG_HOST=https://x.cartridge.gg/ingest
VITE_ORIGIN="http://localhost:3001"
VITE_RP_ID="localhost"
VITE_ADMIN_URL="http://localhost:3002"
VITE_CARTRIDGE_API_URL="http://localhost:8000"
# VITE_ETH_RPC_MAINNET="https://eth-mainnet.g.alchemy.com/v2/OGPRMquXP3K7oTkLrmVZpjCd1DswtYz3"
# VITE_ETH_RPC_SEPOLIA="https://eth-sepolia.g.alchemy.com/v2/mURnclB5pn5elDfyzgTN4W2GR-rOYevI"
VITE_RPC_MAINNET="http://localhost:8001/x/starknet/mainnet"
VITE_RPC_SEPOLIA="http://localhost:8001/x/starknet/sepolia"
VITE_STRIPE_PAYMENT="http://localhost:8000/stripe/payment-intent"
VITE_POSTHOG_KEY=phc_UWaJajNQ00PjHhveZ81SJ2zVtBicKrzewdZHGiyavQQ
VITE_POSTHOG_HOST=https://x.cartridge.gg/ingest
22 changes: 11 additions & 11 deletions packages/keychain/.env.production
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
NEXT_PUBLIC_ORIGIN="https://x.cartridge.gg"
NEXT_PUBLIC_RP_ID="cartridge.gg"
NEXT_PUBLIC_ADMIN_URL="https://cartridge.gg"
NEXT_PUBLIC_CARTRIDGE_API_URL="https://api.cartridge.gg"
# NEXT_PUBLIC_ETH_RPC_MAINNET="https://eth-mainnet.g.alchemy.com/v2/OGPRMquXP3K7oTkLrmVZpjCd1DswtYz3"
# NEXT_PUBLIC_ETH_RPC_SEPOLIA="https://eth-sepolia.g.alchemy.com/v2/mURnclB5pn5elDfyzgTN4W2GR-rOYevI"
NEXT_PUBLIC_RPC_MAINNET="https://api.cartridge.gg/x/starknet/mainnet"
NEXT_PUBLIC_RPC_SEPOLIA="https://api.cartridge.gg/x/starknet/sepolia"
NEXT_PUBLIC_STRIPE_PAYMENT="https://api.cartridge.gg/stripe/payment-intent"
NEXT_PUBLIC_POSTHOG_KEY=phc_UWaJajNQ00PjHhveZ81SJ2zVtBicKrzewdZHGiyavQQ
NEXT_PUBLIC_POSTHOG_HOST=https://x.cartridge.gg/ingest
VITE_ORIGIN="https://x.cartridge.gg"
VITE_RP_ID="cartridge.gg"
VITE_ADMIN_URL="https://cartridge.gg"
VITE_CARTRIDGE_API_URL="https://api.cartridge.gg"
# VITE_ETH_RPC_MAINNET="https://eth-mainnet.g.alchemy.com/v2/OGPRMquXP3K7oTkLrmVZpjCd1DswtYz3"
# VITE_ETH_RPC_SEPOLIA="https://eth-sepolia.g.alchemy.com/v2/mURnclB5pn5elDfyzgTN4W2GR-rOYevI"
VITE_RPC_MAINNET="https://api.cartridge.gg/x/starknet/mainnet"
VITE_RPC_SEPOLIA="https://api.cartridge.gg/x/starknet/sepolia"
VITE_STRIPE_PAYMENT="https://api.cartridge.gg/stripe/payment-intent"
VITE_POSTHOG_KEY=phc_UWaJajNQ00PjHhveZ81SJ2zVtBicKrzewdZHGiyavQQ
VITE_POSTHOG_HOST=https://x.cartridge.gg/ingest
11 changes: 0 additions & 11 deletions packages/keychain/.eslintrc.json

This file was deleted.

59 changes: 23 additions & 36 deletions packages/keychain/.gitignore
Original file line number Diff line number Diff line change
@@ -1,37 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
# Logs
logs
*.log
npm-debug.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

*storybook.log
/storybook-static
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
26 changes: 5 additions & 21 deletions packages/keychain/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { StorybookConfig } from "@storybook/nextjs";
import { join, dirname, resolve } from "path";
import type { StorybookConfig } from "@storybook/react-vite";
import { join, dirname } from "path";

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value: string): any {
function getAbsolutePath(value: string) {
return dirname(require.resolve(join(value, "package.json")));
}
const config: StorybookConfig = {
Expand All @@ -15,28 +15,12 @@ const config: StorybookConfig = {
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@chromatic-com/storybook"),
getAbsolutePath("@storybook/addon-interactions"),
getAbsolutePath("@storybook/addon-themes"),
],
framework: {
name: getAbsolutePath("@storybook/nextjs"),
name: getAbsolutePath("@storybook/react-vite"),
options: {},
},
webpackFinal: (config) => {
// config.output = {
// ...config.output,
// webassemblyModuleFilename: "../static/wasm/webauthn.wasm",
// };
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
};
config.resolve = {
...config.resolve,
alias: {
react: resolve("node_modules/react"),
},
};
return config;
},
staticDirs: ["../public"],
};
export default config;
56 changes: 56 additions & 0 deletions packages/keychain/.storybook/mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { constants } from "starknet";
import { getChainName } from "@cartridge/utils";
import Controller from "@cartridge/controller";
import { SessionPolicies } from "@cartridge/presets";
import { Parameters } from "@storybook/react";
import { ConnectionContextValue } from "../src/components/Provider/connection";
import { UpgradeInterface } from "../src/hooks/upgrade";
import { ConnectCtx, ConnectionCtx } from "../src/utils/connection/types";
import { defaultTheme } from "@cartridge/presets";

export interface StoryParameters extends Parameters {
connection?: {
context?: ConnectionCtx;
controller?: Controller;
chainId?: string;
upgrade?: UpgradeInterface;
};
preset?: string;
policies?: SessionPolicies;
}

export function useMockedConnection({
chainId = constants.StarknetChainId.SN_SEPOLIA,
context = {
type: "connect",
origin: "http://localhost:3002",
policies: [],
resolve: () => {},
reject: () => {},
} as ConnectCtx,
...rest
}: StoryParameters["connection"] = {}): ConnectionContextValue {
const chainName = getChainName(chainId);

return {
context,
origin: "http://localhost:3002",
rpcUrl: "http://api.cartridge.gg/x/sepolia",
chainId,
chainName,
policies: {},
theme: defaultTheme,
prefunds: [],
hasPrefundRequest: false,
error: undefined,
setContext: () => {},
setController: () => {},
closeModal: () => {},
openModal: () => {},
logout: () => {},
openSettings: () => {},
controller: {},
upgrade: {},
...rest,
};
}
Loading
Loading