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

feat(dapp): prepare for v2 Staking #93

Open
wants to merge 15 commits into
base: trunk
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion components/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dynamic from 'next/dynamic';
import { Account } from './web3';
import OverflowMenu from './overflowMenu';
import MobileMenu from './mobileMenu';
import useWalletModal from '@/hooks/useWalletModal';

function NavigationItem({ text, href }: { text: string; href: string }) {
const { asPath } = useRouter();
Expand Down Expand Up @@ -105,7 +106,7 @@ export default function Navigation() {
</div>
</li>
</ul>

{/* @ts-ignore */}
<WalletModal />
</nav>
);
Expand Down
5 changes: 5 additions & 0 deletions custom-media.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@custom-media --small (max-width: 767px);
@custom-media --small-up (min-width: 0px);
@custom-media --medium (min-width: 768px) and (max-width: 1119px);
@custom-media --medium-up (min-width: 768px);
@custom-media --large (min-width: 1120px);
13 changes: 13 additions & 0 deletions hooks/useWalletModal.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { invariant } from './useWalletModal';

test('should throw on failed condition', () => {
expect(() => {
return invariant(false, 'fail');
}).toThrow('Invariant failed: fail');
});

test('should not throw on passed condition', () => {
expect(() => {
invariant(true, 'pass');
}).not.toThrow();
});
14 changes: 14 additions & 0 deletions hooks/useWalletModal.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
import create from 'zustand';

const prefix: string = 'Invariant failed';

export function invariant(condition: boolean, message?: string): void {
if (condition) {
return;
}

throw new Error(`${prefix}: ${message || ''}`);
}

export type EmptyObject = Record<string, never>; // or {[k: string]: never}

export type State = {
EmptyObject: Record<string, never>;
isOpen: boolean;
open: () => void;
close: () => void;
toggle: () => void;
};

const useWalletModal = create<State>((set, get) => ({
EmptyObject: {},
isOpen: false,
open: () => set({ isOpen: true }),
close: () => set({ isOpen: false }),
Expand Down
73 changes: 50 additions & 23 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,57 @@
/** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: true,
// next.config.js

const withPWA = require('next-pwa')
const runtimeCaching = require('next-pwa/cache')
const packageJson = require('./package.json');
const date = new Date();
const GIT_COMMIT_SHA_SHORT = typeof process.env.GIT_COMMIT_SHA === 'string' && process.env.GIT_COMMIT_SHA.substring(0, 8);

// @ts-check
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
env: {
/**
* @summary API Key Env Variables
*/
// GITHUB_DISPATCH_TOKEN: process.env.GITHUB_DISPATCH_TOKEN,
SENTRY_DSN: process.env.SENTRY_DSN,
NEXT_PUBLIC_SENTRY_DSN: process.env.SENTRY_DSN, // Sentry DSN must be provided to the browser for error reporting to work there
/**
* @const VERCEL_
* @see {@link https://vercel.com/docs/environment-variables#system-environment-variables}
*/
VERCEL: process.env.VERCEL,
VERCEL_ENV: process.env.VERCEL_ENV,
VERCEL_URL: process.env.VERCEL_URL,
CI: process.env.CI,
},
productionBrowserSourceMaps: false,
poweredByHeader: false,
optimizeImages: true,
optimizeCss: true,
// experimental: {
// esmExternals: true,
// outputFileTracing: true
// },
images: {
domains: [
'raw.githubusercontent.com',
'assets.coingecko.com',
'logos.covalenthq.com',
'www.covalenthq.com',
's2.coinmarketcap.com',
],
reactStrictMode: true,
experimental: {
optimizeCss: true,
forceSwcTransforms: true,
},
pwa: {
dest: 'public',
runtimeCaching,
disable: process.env.NODE_ENV === 'development',
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback.fs = false
}
return config
async headers() {
return [
{
source: '/*',
headers: [{ key: 'Web-Build', value: process.env.VERCEL_GIT_COMMIT_SHA }]
}
];
},
}

module.exports = withPWA(nextConfig);

console.log('process.env.VERCEL_GIT_COMMIT_SHA: ', process.env.VERCEL_GIT_COMMIT_SHA);
console.log('process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA: ', process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA);
// Don't delete this console log, useful to see the config in Vercel deployments
console.log('next.config.js', JSON.stringify(module.exports, null, 2))
console.log('next.config.js', JSON.stringify(module.exports, null, 2))
Loading