-
Notifications
You must be signed in to change notification settings - Fork 9
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
fabiorigam
wants to merge
39
commits into
main
Choose a base branch
from
add-privy-provider
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add Privy Provider #313
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 f2e74cb
fix: continue the privy provider
fabiorigam c0f9ad9
fix: fix build issue
fabiorigam a89d4e8
fix: add sample privy next app
fabiorigam f60cdc9
fix: fix issue
fabiorigam e75f5ec
feat: add ConnectModal
fabiorigam c233309
fix: fix linter issue
fabiorigam a852dbe
Merge branch 'main' into add-privy-provider
fabiorigam 436f098
fix: fix merge conflicts
fabiorigam 06c49d8
fix: improve modal
fabiorigam 7f8a302
fix: refactor
fabiorigam 8c1234b
fix: refactor
fabiorigam 8b4bd58
fix: improve example UI
fabiorigam cd8d0e2
Merge branch 'main' into add-privy-provider
fabiorigam 64c3711
fix: improve modal
fabiorigam 4145d48
feat: add new hooks
fabiorigam 6e5cfc4
fix: add readme files and a small explanation
fabiorigam e3158b2
fix: update package
fabiorigam de72ec5
fi: update readme
fabiorigam 8dc3ce2
feat: move config in separate object + solve compilation issues
Agilulfo1820 20c6328
fix: typos
Agilulfo1820 fdf8df9
feat: refactor return types
Agilulfo1820 45d5d9c
feat: fixed issues
Agilulfo1820 5375d3c
Merge branch 'feat/dan' into add-privy-provider
Agilulfo1820 3e42858
feat: update twitter logo
Agilulfo1820 c11a323
feat: handle cross accounts
Agilulfo1820 a9e11da
feat: use chakra
Agilulfo1820 4d9e31a
feat: cross app login
Agilulfo1820 2392826
Merge branch 'feat/cross-accounts' into add-privy-provider
Agilulfo1820 5539028
fix: transactions
Agilulfo1820 9788ef0
feat: connect button
Agilulfo1820 3f947ff
fix: dependency
Agilulfo1820 246c618
feat: display connected account
Agilulfo1820 009bfb8
feat: fetch app info
Agilulfo1820 12caab0
feat: go back to main modal
Agilulfo1820 27d6e9f
fix: apps info loop
Agilulfo1820 61d1dba
feat: update params structure
Agilulfo1820 ae24e1d
feat: copy address
Agilulfo1820 31e3c49
feat: transaction modal
Agilulfo1820 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '^_' }, | ||
], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
packages/dapp-kit-react-privy/src/DAppKitPrivyProvider/DAppKitPrivyProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: { | ||
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.
1 change: 1 addition & 0 deletions
1
packages/dapp-kit-react-privy/src/DAppKitPrivyProvider/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './DAppKitPrivyProvider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './DAppKitPrivyProvider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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