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

Add Privy Provider #313

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 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
21 changes: 21 additions & 0 deletions packages/dapp-kit-react-privy/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Vechain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions packages/dapp-kit-react-privy/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import tseslint from 'typescript-eslint';

export default tseslint.config({
ignores: ['**/*.config.ts', 'dist/**'],
extends: [...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'no-console': ['error', { allow: ['error'] }],
'eslint-comments/no-unused-disable': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' },
],
},
});
37 changes: 37 additions & 0 deletions packages/dapp-kit-react-privy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@vechain/dapp-kit-react-privy",
"version": "1.1.1",
"private": false,
"homepage": "https://github.com/vechain/vechain-dapp-kit",
"repository": "github:vechain/vechain-dapp-kit",
"license": "MIT",
"sideEffects": false,
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist",
"package.json",
"README.md",
"LICENSE"
],
"scripts": {
"build": "tsup",
"clean": "rm -rf dist .turbo",
"lint": "eslint",
"purge": "yarn clean && rm -rf node_modules"
},
"dependencies": {
"@vechain/dapp-kit-react": "*",
"@privy-io/react-auth": "1.83.1"
},
"devDependencies": {
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"eslint": "^9.12.0",
"react": "^18.2.0",
"tsup": "*",
"typescript": "*",
"vite": "^4.5.5"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { ReactNode } from "react";
import { PrivyProvider as BasePrivyProvider } from "@privy-io/react-auth";
import { DAppKitProvider } from "@vechain/dapp-kit-react";

type Props = {
children: ReactNode;
appId: string;
clientId: string;
appearance: {
theme: "dark" | "light";
accentColor: `#${string}`;
loginMessage: string;
logo: string;
};
embeddedWallets: {
createOnLogin: "all-users";
};
loginMethods: (
| "wallet"
| "email"
| "sms"
| "google"
| "twitter"
| "discord"
| "github"
| "linkedin"
| "spotify"
| "instagram"
| "tiktok"
| "apple"
| "farcaster"
| "telegram"
)[];
smartAccountConfig: {
nodeUrl: string;
delegatorUrl: string;
accountFactoryAddress: string;
};
dappKitConfig: {
Copy link
Member

@darrenvechain darrenvechain Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we import the dapp kit config type directly, instead of creating a new version of it?

The genesis is a different type for example

nodeUrl: string;
genesis: Connex.Thor.Block;
projectId: string;
colorMode: "DARK" | "LIGHT";
walletConnectOptions: {
projectId: string;
metadata: {
name: string;
description: string;
url: string;
icons: string[];
};
};
};
};

export const DAppKitPrivyProvider = ({
children,
appId,
clientId,
loginMethods,
appearance,
embeddedWallets,
dappKitConfig
}: Props) => {
return (
<BasePrivyProvider
appId={appId}
clientId={clientId}
config={{
loginMethods: loginMethods,
appearance: appearance,
embeddedWallets: {
createOnLogin: embeddedWallets.createOnLogin,
},
}}
>
<DAppKitProvider
nodeUrl={dappKitConfig.nodeUrl}
genesis={dappKitConfig.genesis}
usePersistence
walletConnectOptions={dappKitConfig.walletConnectOptions}
themeMode={dappKitConfig.colorMode}
themeVariables={{}}>
{children}
</DAppKitProvider>
</BasePrivyProvider>
);
};
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './DAppKitPrivyProvider';
1 change: 1 addition & 0 deletions packages/dapp-kit-react-privy/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './DAppKitPrivyProvider';
23 changes: 23 additions & 0 deletions packages/dapp-kit-react-privy/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "node",
"target": "es2021",
"experimentalDecorators": true,
"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true,
// React
"jsx": "react-jsx"
},
"include": ["src/**/*.ts", "test/**/*.test.ts", "eslint.config.mjs"]
}
13 changes: 13 additions & 0 deletions packages/dapp-kit-react-privy/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'tsup';

// eslint-disable-next-line import/no-default-export
export default defineConfig({
entry: ['src/index.ts'],
outDir: 'dist',
format: 'esm',
minify: true,
sourcemap: true,
dts: true,
clean: true,
external: ['react'],
});
33 changes: 33 additions & 0 deletions packages/dapp-kit-react-privy/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/// <reference types="vitest" />
import { resolve } from 'node:path';
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
include: [
'src/**/*.test.ts',
'src/**/*.test.tsx',
'test/**/*.test.ts',
'test/**/*.test.tsx',
],
environment: 'happy-dom',
reporters: 'dot',
setupFiles: [resolve(__dirname, 'test/setup/setup.ts')],
coverage: {
reporter: [
'text',
'json',
'html',
'lcov',
'json-summary',
'text-summary',
'text',
],
statements: 99,
branches: 100,
functions: 100,
lines: 99,
},
globals: true,
},
});
Loading
Loading