Skip to content

Commit

Permalink
feat: rainbow and privy examples
Browse files Browse the repository at this point in the history
  • Loading branch information
HadiKhai committed Nov 7, 2024
1 parent 98e8b8b commit fb2aa7d
Show file tree
Hide file tree
Showing 40 changed files with 238 additions and 242 deletions.
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,
};
18 changes: 9 additions & 9 deletions demo/express-trial/project.json → demo/server/project.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "justaname-express-trial",
"name": "server",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "demo/express-trial/src",
"sourceRoot": "demo/server/src",
"projectType": "application",
"targets": {
"serve": {
"executor": "@nx/js:node",
"defaultConfiguration": "development",
"options": {
"buildTarget": "justaname-express-trial:build"
"buildTarget": "server:build"
},
"configurations": {
"development": {
"buildTarget": "justaname-express-trial:build:development"
"buildTarget": "server:build:development"
},
"production": {
"buildTarget": "justaname-express-trial:build:production"
"buildTarget": "server:build:production"
}
}
},
Expand All @@ -26,10 +26,10 @@
"options": {
"target": "node",
"compiler": "tsc",
"outputPath": "dist/demo/express-trial",
"main": "demo/express-trial/src/main.ts",
"tsConfig": "demo/express-trial/tsconfig.app.json",
"webpackConfig": "demo/express-trial/webpack.config.js",
"outputPath": "dist/demo/server",
"main": "demo/server/src/main.ts",
"tsConfig": "demo/server/tsconfig.app.json",
"webpackConfig": "demo/server/webpack.config.js",
"generatePackageJson": true
},
"configurations": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions demo/with-privy/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
VITE_APP_BACKEND_URL=<backend-url>
VITE_APP_ORIGIN=<origin>
VITE_APP_DOMAIN=<domain>
VITE_APP_MAINNET_PROVIDER_URL=<mainnet-provider-url>
VITE_APP_SEPOLIA_PROVIDER_URL=<sepolia-provider-url>
VITE_APP_PRIVY_APP_ID=<privy-app-id>
62 changes: 25 additions & 37 deletions demo/with-privy/src/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { JustWeb3Provider, JustWeb3ProviderConfig } from '@justweb3/widget';
import {
JustWeb3Button,
JustWeb3Provider,
JustWeb3ProviderConfig,
} from '@justweb3/widget';
import '@rainbow-me/rainbowkit/styles.css';
import { http } from 'wagmi';
import { mainnet, sepolia } from 'wagmi/chains';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ChainId } from '@justaname.id/sdk';
import { PrivyProvider, usePrivy } from '@privy-io/react-auth';
import { createConfig, WagmiProvider } from '@privy-io/wagmi';
import { useEnsAuth } from '@justaname.id/react';
Expand All @@ -18,14 +21,12 @@ const JustaNameConfig: JustWeb3ProviderConfig = {
backendUrl: import.meta.env.VITE_APP_BACKEND_URL,
networks: [
{
chainId: parseInt(import.meta.env.VITE_APP_CHAIN_ID) as ChainId,
providerUrl: import.meta.env.VITE_APP_PROVIDER_URL,
chainId: 1,
providerUrl: import.meta.env.VITE_APP_MAINNET_PROVIDER_URL,
},
],
ensDomains: [
{
ensDomain: import.meta.env.VITE_APP_ENS_DOMAIN,
chainId: parseInt(import.meta.env.VITE_APP_CHAIN_ID) as ChainId,
chainId: 11155111,
providerUrl: import.meta.env.VITE_APP_SEPOLIA_PROVIDER_URL,
},
],
openOnWalletConnect: true,
Expand All @@ -42,33 +43,17 @@ const Connect = () => {
return (
<div className="App">
<header className="App-header">
{/* If the user is not authenticated, show a login button */}
{/* If the user is authenticated, show the user object and a logout button */}
{ready && authenticated ? (
<div>
<textarea
readOnly
value={JSON.stringify(user, null, 2)}
style={{ width: '600px', height: '250px', borderRadius: '6px' }}
/>
<br />
<button
onClick={logout}
style={{
marginTop: '20px',
padding: '12px',
backgroundColor: '#069478',
color: '#FFF',
border: 'none',
borderRadius: '6px',
}}
>
Log Out
</button>
</div>
) : (
<JustWeb3Button logout={logout}>
<button
onClick={login}
onClick={() => {
if (!authenticated) {
login();
} else {
logout().then(() => {
login();
});
}
}}
style={{
padding: '12px',
backgroundColor: '#069478',
Expand All @@ -79,14 +64,19 @@ const Connect = () => {
>
Log In
</button>
)}
</JustWeb3Button>
{connectedEns && (
<div>
<textarea
readOnly
value={JSON.stringify(connectedEns, null, 2)}
style={{ width: '600px', height: '250px', borderRadius: '6px' }}
/>
<textarea
readOnly
value={JSON.stringify(user, null, 2)}
style={{ width: '600px', height: '250px', borderRadius: '6px' }}
/>
</div>
)}
</header>
Expand All @@ -100,8 +90,6 @@ export function App() {
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
// For each of your required chains, add an entry to `transports` with
// a key of the chain's `id` and a value of `http()`
},
});

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

<meta name="viewport" content="width=device-width, initial-scale=1" />
Expand Down
10 changes: 5 additions & 5 deletions demo/react-trial/project.json → demo/with-rainbow/project.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "react-trial",
"name": "with-rainbow",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/react-trial/src",
"sourceRoot": "apps/with-rainbow/src",
"projectType": "application",
"targets": {
"serve": {
"executor": "@nx/vite:dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "react-trial:build"
"buildTarget": "with-rainbow:build"
},
"configurations": {
"production": {
"buildTarget": "react-trial:build:production"
"buildTarget": "with-rainbow:build:production"
}
},
"dependsOn": [
Expand All @@ -31,7 +31,7 @@
"executor": "nx:run-commands",
"options": {
"command": "yarn tsc --noEmit",
"cwd": "apps/react-trial"
"cwd": "apps/with-rainbow"
}
}
},
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
JustWeb3ProviderConfig,
JustWeb3Provider,
JustWeb3Button,
JustWeb3Provider,
JustWeb3ProviderConfig,
} from '@justweb3/widget';
import '@rainbow-me/rainbowkit/styles.css';
import {
Expand All @@ -11,8 +11,7 @@ import {
} from '@rainbow-me/rainbowkit';
import { WagmiProvider } from 'wagmi';
import { mainnet, sepolia } from 'wagmi/chains';
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
import { ChainId } from '@justaname.id/sdk';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

const queryClient = new QueryClient();

Expand All @@ -24,25 +23,24 @@ const JustaNameConfig: JustWeb3ProviderConfig = {
backendUrl: import.meta.env.VITE_APP_BACKEND_URL,
networks: [
{
chainId: parseInt(import.meta.env.VITE_APP_CHAIN_ID) as ChainId,
providerUrl: import.meta.env.VITE_APP_PROVIDER_URL,
chainId: 1,
providerUrl: import.meta.env.VITE_APP_MAINNET_PROVIDER_URL,
},
],
ensDomains: [
{
ensDomain: import.meta.env.VITE_APP_ENS_DOMAIN,
chainId: parseInt(import.meta.env.VITE_APP_CHAIN_ID) as ChainId,
chainId: 11155111,
providerUrl: import.meta.env.VITE_APP_SEPOLIA_PROVIDER_URL,
},
],
openOnWalletConnect: true,
allowedEns: 'all',
};

export function App() {
console.log('rainbow', import.meta.env.VITE_APP_CHAIN_ID);
const config = getDefaultConfig({
appName: 'My RainbowKit App',
projectId: 'YOUR_PROJECT_ID',
chains: import.meta.env.VITE_APP_CHAIN_ID === 1 ? [mainnet] : [sepolia],
chains: import.meta.env.VITE_APP_CHAIN_ID === '1' ? [mainnet] : [sepolia],
});

return (
Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit fb2aa7d

Please sign in to comment.