Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/JustaName-id/JustaName-sdk
Browse files Browse the repository at this point in the history
… into anthony/poap-plugin
  • Loading branch information
anthony23991 committed Nov 18, 2024
2 parents 2fbebdf + 1f43ec3 commit 45a2ac3
Show file tree
Hide file tree
Showing 76 changed files with 1,630 additions and 362 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ jobs:
release:
runs-on: ubuntu-latest
if: >
${{!contains(github.event.head_commit.message, format('chore(release){0} publish', ':'))
&& !contains(github.event.head_commit.message, format('CI{0} Update yarn.lock files', ':'))}}
${{
!contains(github.event.head_commit.message, '[skip ci]') &&
!contains(github.event.head_commit.message, format('chore(release){0} publish', ':')) &&
!contains(github.event.head_commit.message, format('CI{0} Update yarn.lock files', ':'))
}}
permissions:
contents: write
packages: write
Expand Down Expand Up @@ -69,7 +72,7 @@ jobs:
- run: rm -rf node_modules/.cache/rollup-plugin-typescript2
- name: Release
run: |
npx nx release --specifier=patch --yes
npx nx release --specifier=patch --yes
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
34 changes: 21 additions & 13 deletions apps/console/lib/justaname.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { JustaName } from '@justaname.id/sdk';

export const justaname = JustaName.init({
dev: process.env.DEV === 'true',
networks: [
{
chainId: 1,
providerUrl: process.env.MAINNET_PROVIDER_URL as string,
},
{
chainId: 11155111,
providerUrl: process.env.SEPOLIA_PROVIDER_URL as string,
},
],
});
let justaname: JustaName | undefined;

export const getJustaname = () => {
if (!justaname) {
justaname = JustaName.init({
dev: process.env.DEV === 'true',
networks: [
{
chainId: 1,
providerUrl: process.env.MAINNET_PROVIDER_URL as string,
},
{
chainId: 11155111,
providerUrl: process.env.SEPOLIA_PROVIDER_URL as string,
},
],
});
}

return justaname;
};
10 changes: 5 additions & 5 deletions apps/console/src/app/api/signin/nonce/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { NextRequest, NextResponse } from 'next/server';
import { justaname, Session, tap } from '../../../../../lib';
import { getJustaname, Session, tap } from '../../../../../lib';

export const GET = async (req: NextRequest): Promise<NextResponse> => {
const session = await Session.fromRequest(req)
if (!session?.nonce) session.nonce = justaname.signIn.generateNonce()
const session = await Session.fromRequest(req);
if (!session?.nonce) session.nonce = getJustaname().signIn.generateNonce();

return tap(new NextResponse(session.nonce), res => session.persist(res))
}
return tap(new NextResponse(session.nonce), (res) => session.persist(res));
};
4 changes: 2 additions & 2 deletions apps/console/src/app/api/signin/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { justaname, Session, tap } from '../../../../lib';
import { getJustaname, Session, tap } from '../../../../lib';
import { SignInResponse } from '@justaname.id/sdk';

export const POST = async (req: NextRequest) => {
Expand All @@ -10,7 +10,7 @@ export const POST = async (req: NextRequest) => {
let signInMessage: SignInResponse;

try {
signInMessage = await justaname.signIn.signIn({
signInMessage = await getJustaname().signIn.signIn({
message,
signature,
nonce: session.nonce,
Expand Down
26 changes: 16 additions & 10 deletions apps/console/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@ export default function Page() {
return (
<div className="flex flex-row justify-between max-mobile:max-w-[100vw] max-mobile:overflow-x-hidden w-full h-full relative">
<ConsoleProvider>
<div className='hidden mobile:block'>
<div className="hidden mobile:block">
<Customizer />
</div>
<div className='mobile:hidden'>
<div className="mobile:hidden">
<SectionSlider
trigger={
<div className='py-[7px] px-2.5 bg-[#3280F4] font-xs font-black text-white border border-black rounded-[8px_8px_0px_0px] rotate-90'>
<div className="py-[7px] px-2.5 bg-[#3280F4] font-xs font-black text-white border border-black rounded-[8px_8px_0px_0px] rotate-90">
Customise
</div>
}
side='left' title='Customizer'>
side="left"
title="Customizer"
>
<Customizer mobile />
</SectionSlider>
</div>

<div className='max-mobile:hidden flex flex-1'>
<Split style={{ maxWidth: '100%', overflow: 'hidden', width: '100%' }}>
<div className="max-mobile:hidden flex flex-1">
<Split
style={{ maxWidth: '100%', overflow: 'hidden', width: '100%' }}
>
<div
className={`flex-1 h-full gap-3 flex-col relative bg-[url('/bg/widget-bg.png')] bg-repeat-x bg-cover flex justify-center items-center`}
>
Expand All @@ -45,20 +49,22 @@ export default function Page() {
<CodeSection />
</Split>
</div>
<div className='mobile:hidden overflow-hidden w-full'>
<div className="mobile:hidden overflow-hidden w-full">
<SectionSlider
trigger={
<div className='py-[7px] px-2.5 bg-[#FEA801] font-xs font-black text-white border border-black rounded-[8px_8px_0px_0px] translate-y-[10px] -rotate-90'>
<div className="py-[7px] px-2.5 bg-[#FEA801] font-xs font-black text-white border border-black rounded-[8px_8px_0px_0px] translate-y-[10px] -rotate-90">
Code Output
</div>
}
side='right' title='Code'>
side="right"
title="Code"
>
<CodeSection mobile />
</SectionSlider>
<div
className={`flex-1 h-full gap-3 w-full flex-col relative bg-[url('/bg/widget-bg.png')] bg-repeat-x bg-cover flex justify-center items-center`}
>
<div className='mb-10'>
<div className="mb-10">
<JustWeb3Button>
<ConnectButton />
</JustWeb3Button>
Expand Down
10 changes: 9 additions & 1 deletion apps/console/src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
trustWallet,
} from '@rainbow-me/rainbowkit/wallets';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { WagmiProvider } from 'wagmi';
import { http, WagmiProvider } from 'wagmi';
import { mainnet, sepolia } from 'wagmi/chains';
import { JustWeb3Provider, JustWeb3ProviderConfig } from '@justweb3/widget';
import { useState } from 'react';
Expand All @@ -37,6 +37,14 @@ export const Providers: React.FC<ProviderProps> = (props) => {
],
chains: [mainnet, sepolia],
ssr: true,
transports: {
[mainnet.id]: http(
process.env.NEXT_PUBLIC_MAINNET_PROVIDER_URL as string
),
[sepolia.id]: http(
process.env.NEXT_PUBLIC_SEPOLIA_PROVIDER_URL as string
),
},
});

const justweb3Config: JustWeb3ProviderConfig = {
Expand Down
7 changes: 6 additions & 1 deletion demo/server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import { ChainId, JustaNameConfig } from '@justaname.id/sdk';
const chainId = parseInt(process.env.JUSTANAME_CHAIN_ID as string) as ChainId;
const apiKey = process.env.JUSTANAME_API_KEY as string;
const providerUrl = process.env.JUSTANAME_PROVIDER_URL as string;
const sepoliaProviderUrl = process.env.JUSTANAME_SEPOLIA_PROVIDER_URL as string;
const ensDomain = process.env.JUSTANAME_ENS_DOMAIN as string;
const dev = process.env.JUSTANAME_DEV === 'true';
export const config: JustaNameConfig = {
networks: [
{
chainId,
chainId: 1,
providerUrl,
},
{
chainId: 11155111,
providerUrl: sepoliaProviderUrl,
},
],
defaultChainId: chainId,
ensDomains: [
Expand Down
9 changes: 9 additions & 0 deletions demo/with-usecapsule/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
VITE_APP_BACKEND_URL=http://localhost:3333
VITE_APP_ENS_DOMAIN=your_ens_domain
VITE_APP_CHAIN_ID=your_chain_id
VITE_APP_ORIGIN=yourwebsite.com
VITE_APP_DOMAIN=yourwebsite
VITE_APP_PROVIDER_URL=https://rpc.yourprovider.com
VITE_CAPSULE_API_KEY=<your_capsule_api_key>
VITE_JUSTANAME_API_KEY=<your_justaname_api_key>
VITE_JUSTANAME_ENS_DOMAIN=<your_justaname_ens_domain>
18 changes: 18 additions & 0 deletions demo/with-usecapsule/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nx/react", "../../.eslintrc.base.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
26 changes: 26 additions & 0 deletions demo/with-usecapsule/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
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?

.env
19 changes: 19 additions & 0 deletions demo/with-usecapsule/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>WithUseCapsule</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" href="/src/styles.css" />
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
39 changes: 39 additions & 0 deletions demo/with-usecapsule/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "with-usecapsule",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/with-usecapsule/src",
"projectType": "application",
"targets": {
"serve": {
"executor": "@nx/vite:dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "with-usecapsule:build"
},
"configurations": {
"production": {
"buildTarget": "with-usecapsule:build:production"
}
},
"dependsOn": [
{
"projects": [
"@justweb3/widget",
"@justweb3/ui",
"@justaname.id/react",
"@justaname.id/sdk"
],
"target": "build"
}
]
},
"typecheck": {
"executor": "nx:run-commands",
"options": {
"command": "yarn tsc --noEmit",
"cwd": "apps/with-usecapsule"
}
}
},
"tags": []
}
Binary file added demo/with-usecapsule/public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions demo/with-usecapsule/src/app/app.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Your styles goes here. */
Loading

0 comments on commit 45a2ac3

Please sign in to comment.