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 39 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cee39e9
feat: add dapp-kit-react-privy package
fabiorigam Nov 21, 2024
f2e74cb
fix: continue the privy provider
fabiorigam Nov 21, 2024
c0f9ad9
fix: fix build issue
fabiorigam Nov 21, 2024
a89d4e8
fix: add sample privy next app
fabiorigam Nov 22, 2024
f60cdc9
fix: fix issue
fabiorigam Nov 22, 2024
e75f5ec
feat: add ConnectModal
fabiorigam Nov 22, 2024
c233309
fix: fix linter issue
fabiorigam Nov 22, 2024
a852dbe
Merge branch 'main' into add-privy-provider
fabiorigam Nov 25, 2024
436f098
fix: fix merge conflicts
fabiorigam Nov 25, 2024
06c49d8
fix: improve modal
fabiorigam Nov 25, 2024
7f8a302
fix: refactor
fabiorigam Nov 25, 2024
8c1234b
fix: refactor
fabiorigam Nov 25, 2024
8b4bd58
fix: improve example UI
fabiorigam Nov 25, 2024
cd8d0e2
Merge branch 'main' into add-privy-provider
fabiorigam Nov 25, 2024
64c3711
fix: improve modal
fabiorigam Nov 26, 2024
4145d48
feat: add new hooks
fabiorigam Nov 26, 2024
6e5cfc4
fix: add readme files and a small explanation
fabiorigam Nov 28, 2024
e3158b2
fix: update package
fabiorigam Nov 28, 2024
de72ec5
fi: update readme
fabiorigam Nov 28, 2024
8dc3ce2
feat: move config in separate object + solve compilation issues
Agilulfo1820 Dec 6, 2024
20c6328
fix: typos
Agilulfo1820 Dec 6, 2024
fdf8df9
feat: refactor return types
Agilulfo1820 Dec 9, 2024
45d5d9c
feat: fixed issues
Agilulfo1820 Dec 10, 2024
5375d3c
Merge branch 'feat/dan' into add-privy-provider
Agilulfo1820 Dec 10, 2024
3e42858
feat: update twitter logo
Agilulfo1820 Dec 11, 2024
c11a323
feat: handle cross accounts
Agilulfo1820 Dec 11, 2024
a9e11da
feat: use chakra
Agilulfo1820 Dec 11, 2024
4d9e31a
feat: cross app login
Agilulfo1820 Dec 13, 2024
2392826
Merge branch 'feat/cross-accounts' into add-privy-provider
Agilulfo1820 Dec 13, 2024
5539028
fix: transactions
Agilulfo1820 Dec 17, 2024
9788ef0
feat: connect button
Agilulfo1820 Dec 17, 2024
3f947ff
fix: dependency
Agilulfo1820 Dec 17, 2024
246c618
feat: display connected account
Agilulfo1820 Dec 17, 2024
009bfb8
feat: fetch app info
Agilulfo1820 Dec 17, 2024
12caab0
feat: go back to main modal
Agilulfo1820 Dec 17, 2024
27d6e9f
fix: apps info loop
Agilulfo1820 Dec 17, 2024
61d1dba
feat: update params structure
Agilulfo1820 Dec 17, 2024
ae24e1d
feat: copy address
Agilulfo1820 Dec 17, 2024
31e3c49
feat: transaction modal
Agilulfo1820 Dec 17, 2024
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