Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into console
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/@justaname.id/siwens/package.json
#	packages/@justverified/plugin/package.json
#	packages/@justweb3/efp-plugin/package.json
#	yarn.lock
  • Loading branch information
HadiKhai committed Nov 7, 2024
2 parents 838bd9b + b0ce97f commit ce1d06a
Show file tree
Hide file tree
Showing 63 changed files with 856 additions and 637 deletions.
19 changes: 13 additions & 6 deletions apps/console/src/app/api/signin/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { NextRequest, NextResponse } from 'next/server';
import { tap, justaname, Session } from '../../../../lib';
import { justaname, Session, tap } from '../../../../lib';
import { SignInResponse } from '@justaname.id/sdk';

export const POST = async (req: NextRequest) => {
const { message, signature } = await req.json();

console.log(message, signature);
const session = await Session.fromRequest(req);

let signInMessage: SignInResponse;
Expand All @@ -13,21 +15,26 @@ export const POST = async (req: NextRequest) => {
message,
signature,
nonce: session.nonce,
domain: process.env.DOMAIN
domain: process.env.DOMAIN,
});
} catch (error) {
return tap(new NextResponse(error.message, { status: 422 }), res => session.clear(res));
return tap(new NextResponse(error.message, { status: 422 }), (res) =>
session.clear(res)
);
}

const { data: fields, ens, success, error } = signInMessage;

if(!success) {
return tap(new NextResponse(error?.type || "something went wrong", { status: 422 }), res => session.clear(res));
if (!success) {
return tap(
new NextResponse(error?.type || 'something went wrong', { status: 422 }),
(res) => session.clear(res)
);
}

session.address = fields.address;
session.chainId = fields.chainId;
session.ens = ens;

return tap(new NextResponse(''), res => session.persist(res));
return tap(new NextResponse(''), (res) => session.persist(res));
};
98 changes: 67 additions & 31 deletions apps/console/src/components/sections/code/CodeSection/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { a11yLight, CopyBlock } from 'react-code-blocks';
import { JustWeb3Context } from '@justweb3/widget';
import { useContext, useMemo } from 'react';
import React, { useContext, useMemo } from 'react';
import { useJustWeb3Theme } from '@justweb3/ui';
import { useConsole } from '../../../../providers/ConsoleProvider';
import { Highlight, themes } from 'prism-react-renderer';

export const CodeSection: React.FC = () => {
const { config } = useContext(JustWeb3Context);
Expand All @@ -14,16 +14,17 @@ export const CodeSection: React.FC = () => {

if (config.plugins?.find((p) => p.name === 'JustVerifiedPlugin')) {
plugins.push(
`JustVerifiedPlugin([${justVerified.map((v) => `'${v}'`).join(', ')}])`
`JustVerifiedPlugin([${justVerified.map((v) => `${v}`).join(', ')}])`
);
}

if (config.plugins?.find((p) => p.name === 'EFPPlugin')) {
plugins.push('EFPPlugin');
}

return `import '@rainbow-me/rainbowkit/styles.css'
import '@justweb3/widget/styles.css'
return `
import '@rainbow-me/rainbowkit/styles.css';
import '@justweb3/widget/styles.css';
import React from 'react';
import {
getDefaultConfig,
Expand All @@ -39,21 +40,14 @@ import {
QueryClient,
QueryClientProvider
} from '@tanstack/react-query';
import {
WagmiProvider
} from 'wagmi';
import {
mainnet,
sepolia
} from 'wagmi/chains';
import { WagmiProvider } from 'wagmi';
import { mainnet, sepolia } from 'wagmi/chains';
import {
JustWeb3Provider,
JustWeb3ProviderConfig,
JustWeb3Button
} from '@justweb3/widget';
import {
ConnectButton
} from '@rainbow-me/rainbowkit';
import { ConnectButton } from '@rainbow-me/rainbowkit';
${
config.plugins?.find((p) => p.name === 'JustVerifiedPlugin')
? "import { JustVerifiedPlugin } from '@justverified/plugin';"
Expand All @@ -64,7 +58,7 @@ ${
? "import { EFPPlugin } from '@justweb3/efp-plugin';"
: ''
}
export const App: React.FC = () => {
const { wallets } = getDefaultWallets();
Expand All @@ -85,6 +79,16 @@ export const App: React.FC = () => {
const justweb3Config: JustWeb3ProviderConfig = ${JSON.stringify(
{
...config,
networks: [
{
chainId: 1,
providerUrl: `<MAINNET_PROVIDER_URL>`,
},
{
chainId: 11155111,
providerUrl: `<SEPOLIA_PROVIDER_URL>`,
},
],
dev: undefined,
disableOverlay: undefined,
plugins: plugins.length > 0 ? plugins : undefined,
Expand All @@ -111,25 +115,57 @@ export const App: React.FC = () => {
);
};
export default App;
`;
export default App;`.trim();
}, [color, config, justVerified]);

const handleCopy = () => {
navigator.clipboard.writeText(code);
};

return (
<div className="h-full w-[30%] min-w-[300px] border-l-[1px] pointer-events-auto flex flex-col max-h-[calc(100vh-60px)] overflow-y-auto py-5 px-2.5 gap-5 justify-between">
<p className="text-sm font-medium leading-[140%]">Code</p>
<CopyBlock
text={code
.replace(`"JustVerified`, `JustVerified`)
.replace('])"', '])')
.replace(`"EFPPlugin"`, `EFPPlugin`)}
language={'tsx'}
customStyle={{
fontSize: '12px',
}}
showLineNumbers={true}
theme={a11yLight}
/>
<div className="flex justify-between items-center">
<p className="text-sm font-medium leading-[140%]">Code</p>
<button
onClick={handleCopy}
className="text-sm font-medium leading-[140%] text-blue-500 hover:text-blue-700"
>
Copy
</button>
</div>
<Highlight code={code} language="tsx" theme={themes.vsLight}>
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre
className={`${className} relative`}
style={{ ...style, fontSize: '12px' }}
>
{tokens.map((line, i) => (
<div
key={i}
{...getLineProps({ line })}
style={{ display: 'table-row' }}
>
<span
style={{
display: 'table-cell',
textAlign: 'right',
paddingRight: '1em',
userSelect: 'none',
opacity: 0.5,
}}
>
{i + 1}
</span>
<span style={{ display: 'table-cell' }}>
{line.map((token, key) => (
<span key={key} {...getTokenProps({ token })} />
))}
</span>
</div>
))}
</pre>
)}
</Highlight>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,35 @@ export const Verified = () => {
}, [justVerified]);

return (
<AccordionItem value="justverified">
<AccordionItem
value="justverified"
style={{
position: 'relative',
}}
>
<Switch
checked={
!!config?.plugins?.find(
(plugin) => plugin.name === 'JustVerifiedPlugin'
)
}
onClick={(e) => {
e.stopPropagation();
}}
onCheckedChange={(checked) => {
handleJustVerifiedConfig(checked);
}}
style={{
position: 'absolute',
right: 0,
top: '24px',
}}
/>
<AccordionTrigger>
<div className="flex flex-row items-center justify-between w-full py-[5px]">
<p className="text-base text-black font-bold leading-[125%] my-[5px]">
JustVerified
</p>
<Switch
checked={
!!config?.plugins?.find(
(plugin) => plugin.name === 'JustVerifiedPlugin'
)
}
onClick={(e) => {
e.stopPropagation();
}}
onCheckedChange={(checked) => {
handleJustVerifiedConfig(checked);
}}
/>
</div>
</AccordionTrigger>
<AccordionContent>
Expand Down
6 changes: 0 additions & 6 deletions demo/express-trial/.env.example

This file was deleted.

37 changes: 0 additions & 37 deletions demo/react-trial/src/app/components/ClaimSubname.tsx

This file was deleted.

75 changes: 0 additions & 75 deletions demo/react-trial/src/app/components/Subname.tsx

This file was deleted.

6 changes: 6 additions & 0 deletions demo/server/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
JUSTANAME_API_KEY=<your_api_key>
JUSTANAME_PROVIDER_URL=<your_provider_url>
JUSTANAME_CHAIN_ID=<your_chain_id>
JUSTANAME_DOMAIN=<your_domain>
JUSTANAME_ORIGIN=<your_origin>
JUSTANAME_ENS_DOMAIN=<your_ens_domain>
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable */
export default {
displayName: 'justaname-express-trial',
displayName: 'server',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/express-trial',
coverageDirectory: '../../coverage/apps/server',
passWithNoTests: true,
};
Loading

0 comments on commit ce1d06a

Please sign in to comment.