@vleap/warps-wallet-privy 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # @vleap/warps-wallet-privy
2
+
3
+ Privy wallet provider for Warps SDK. This package enables you to use Privy wallets with the Warps SDK across multiple blockchain networks. **Designed for Node.js environments** - no React dependencies required.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @vleap/warps-wallet-privy
9
+ ```
10
+
11
+ ## Prerequisites
12
+
13
+ - `@vleap/warps` core package installed
14
+ - Privy SDK installed and configured (`@privy-io/server-sdk` for Node.js)
15
+
16
+ ## Usage
17
+
18
+ ### Node.js Usage
19
+
20
+ Use Privy's server SDK to create a client:
21
+
22
+ ```typescript
23
+ import { PrivyClient } from '@privy-io/server-sdk'
24
+ import { PrivyWalletProvider } from '@vleap/warps-wallet-privy'
25
+ import { WarpClient } from '@vleap/warps'
26
+ import { getEvmAdapter } from '@vleap/warps-adapter-evm'
27
+
28
+ const privyServerClient = new PrivyClient(process.env.PRIVY_APP_ID, process.env.PRIVY_APP_SECRET)
29
+
30
+ const privyClient = {
31
+ getAddress: async () => {
32
+ const user = await privyServerClient.getUser(userId)
33
+ return user.wallet?.address || null
34
+ },
35
+ signTransaction: async (tx: any) => {
36
+ return await privyServerClient.signTransaction(userId, tx)
37
+ },
38
+ signMessage: async (message: string) => {
39
+ return await privyServerClient.signMessage(userId, message)
40
+ },
41
+ }
42
+
43
+ const config = {
44
+ env: 'mainnet',
45
+ walletProviders: {
46
+ ethereum: () => new PrivyWalletProvider({ privyClient }),
47
+ },
48
+ }
49
+
50
+ const client = new WarpClient(config, [getEvmAdapter(config)])
51
+
52
+ // Use the client as normal
53
+ const wallet = client.getWallet('ethereum')
54
+ const address = await wallet.getAddress()
55
+ ```
56
+
57
+ ### Browser/React Usage (Optional)
58
+
59
+ If you're using Privy in a React application, you can create a client adapter:
60
+
61
+ ```typescript
62
+ import { PrivyWalletProvider } from '@vleap/warps-wallet-privy'
63
+ import { WarpClient } from '@vleap/warps'
64
+ import { getEvmAdapter } from '@vleap/warps-adapter-evm'
65
+
66
+ // Create a Privy client adapter from your React Privy instance
67
+ const privyClient = {
68
+ getAddress: async () => {
69
+ // Get address from your Privy instance
70
+ return privyInstance.user?.wallet?.address || null
71
+ },
72
+ signTransaction: async (tx: any) => {
73
+ // Sign transaction using your Privy instance
74
+ return await privyInstance.user?.wallet?.signTransaction(tx)
75
+ },
76
+ signMessage: async (message: string) => {
77
+ // Sign message using your Privy instance
78
+ return await privyInstance.user?.wallet?.signMessage(message)
79
+ },
80
+ }
81
+
82
+ const config = {
83
+ env: 'mainnet',
84
+ walletProviders: {
85
+ ethereum: () => new PrivyWalletProvider({ privyClient }),
86
+ },
87
+ }
88
+
89
+ const client = new WarpClient(config, [getEvmAdapter(config)])
90
+ ```
91
+
92
+ ### With Multiple Chains
93
+
94
+ The Privy wallet provider supports multiple chains. You can configure it for different chains:
95
+
96
+ ```typescript
97
+ const privyClient = {
98
+ getAddress: async () => /* ... */,
99
+ signTransaction: async (tx: any) => /* ... */,
100
+ signMessage: async (message: string) => /* ... */,
101
+ }
102
+
103
+ const config = {
104
+ env: 'mainnet',
105
+ walletProviders: {
106
+ ethereum: () => new PrivyWalletProvider({ privyClient }),
107
+ solana: () => new PrivyWalletProvider({ privyClient }),
108
+ },
109
+ }
110
+
111
+ const client = new WarpClient(config, [
112
+ getEvmAdapter(config),
113
+ getSolanaAdapter(config),
114
+ ])
115
+ ```
116
+
117
+ ## API
118
+
119
+ Implements the `WalletProvider` interface from `@vleap/warps`.
120
+
121
+ **Constructor:**
122
+ ```typescript
123
+ new PrivyWalletProvider(config: PrivyWalletProviderConfig)
124
+ ```
125
+
126
+ **Parameters:**
127
+ - `config.privyClient`: The Privy client interface
128
+ - `getAddress(): Promise<string | null>` - Get the wallet address
129
+ - `signTransaction(tx: any): Promise<string>` - Sign a transaction
130
+ - `signMessage(message: string): Promise<string>` - Sign a message
131
+ - `config.address` (optional): Fallback address if client doesn't provide one
132
+
133
+ **Methods:**
134
+ - `getAddress(): Promise<string | null>` - Get the wallet address
135
+ - `getPublicKey(): Promise<string | null>` - Get the public key (returns null for Privy)
136
+ - `signTransaction(tx: any): Promise<any>` - Sign a transaction
137
+ - `signMessage(message: string): Promise<string>` - Sign a message
138
+
139
+ ## Supported Chains
140
+
141
+ The Privy wallet provider works with any chain that Privy supports, including:
142
+ - Ethereum and EVM-compatible chains
143
+ - Solana
144
+ - And other chains supported by Privy
145
+
146
+ ## Notes
147
+
148
+ - **Node.js-first design**: This package has no React dependencies and is designed to work in Node.js environments
149
+ - You need to provide a Privy client adapter that implements the `PrivyClient` interface
150
+ - Public key is not available through Privy, so `getPublicKey()` always returns `null`
151
+ - The client adapter should handle authentication and wallet availability checks
152
+ - For React applications, create a client adapter that wraps your Privy React hooks
@@ -0,0 +1,21 @@
1
+ import { WalletProvider } from '@vleap/warps';
2
+
3
+ interface PrivyClient {
4
+ getAddress(): Promise<string | null>;
5
+ signTransaction(tx: any): Promise<string>;
6
+ signMessage(message: string): Promise<string>;
7
+ }
8
+ interface PrivyWalletProviderConfig {
9
+ privyClient: PrivyClient;
10
+ address?: string;
11
+ }
12
+ declare class PrivyWalletProvider implements WalletProvider {
13
+ private config;
14
+ constructor(config: PrivyWalletProviderConfig);
15
+ getAddress(): Promise<string | null>;
16
+ getPublicKey(): Promise<string | null>;
17
+ signTransaction(tx: any): Promise<any>;
18
+ signMessage(message: string): Promise<string>;
19
+ }
20
+
21
+ export { type PrivyClient, PrivyWalletProvider, type PrivyWalletProviderConfig };
@@ -0,0 +1,21 @@
1
+ import { WalletProvider } from '@vleap/warps';
2
+
3
+ interface PrivyClient {
4
+ getAddress(): Promise<string | null>;
5
+ signTransaction(tx: any): Promise<string>;
6
+ signMessage(message: string): Promise<string>;
7
+ }
8
+ interface PrivyWalletProviderConfig {
9
+ privyClient: PrivyClient;
10
+ address?: string;
11
+ }
12
+ declare class PrivyWalletProvider implements WalletProvider {
13
+ private config;
14
+ constructor(config: PrivyWalletProviderConfig);
15
+ getAddress(): Promise<string | null>;
16
+ getPublicKey(): Promise<string | null>;
17
+ signTransaction(tx: any): Promise<any>;
18
+ signMessage(message: string): Promise<string>;
19
+ }
20
+
21
+ export { type PrivyClient, PrivyWalletProvider, type PrivyWalletProviderConfig };
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ PrivyWalletProvider: () => PrivyWalletProvider
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/PrivyWalletProvider.ts
28
+ var PrivyWalletProvider = class {
29
+ constructor(config) {
30
+ this.config = config;
31
+ }
32
+ async getAddress() {
33
+ try {
34
+ const address = await this.config.privyClient.getAddress();
35
+ return address || this.config.address || null;
36
+ } catch {
37
+ return this.config.address || null;
38
+ }
39
+ }
40
+ async getPublicKey() {
41
+ return null;
42
+ }
43
+ async signTransaction(tx) {
44
+ try {
45
+ const signature = await this.config.privyClient.signTransaction(tx);
46
+ return { ...tx, signature };
47
+ } catch (error) {
48
+ throw new Error(`Failed to sign transaction: ${error}`);
49
+ }
50
+ }
51
+ async signMessage(message) {
52
+ try {
53
+ return await this.config.privyClient.signMessage(message);
54
+ } catch (error) {
55
+ throw new Error(`Failed to sign message: ${error}`);
56
+ }
57
+ }
58
+ };
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ PrivyWalletProvider
62
+ });
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/PrivyWalletProvider.ts"],"sourcesContent":["export * from './PrivyWalletProvider'\n","import { WalletProvider } from '@vleap/warps'\n\nexport interface PrivyClient {\n getAddress(): Promise<string | null>\n signTransaction(tx: any): Promise<string>\n signMessage(message: string): Promise<string>\n}\n\nexport interface PrivyWalletProviderConfig {\n privyClient: PrivyClient\n address?: string\n}\n\nexport class PrivyWalletProvider implements WalletProvider {\n constructor(\n private config: PrivyWalletProviderConfig\n ) {}\n\n async getAddress(): Promise<string | null> {\n try {\n const address = await this.config.privyClient.getAddress()\n return address || this.config.address || null\n } catch {\n return this.config.address || null\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n // Privy doesn't expose public key directly\n return null\n }\n\n async signTransaction(tx: any): Promise<any> {\n try {\n const signature = await this.config.privyClient.signTransaction(tx)\n return { ...tx, signature }\n } catch (error) {\n throw new Error(`Failed to sign transaction: ${error}`)\n }\n }\n\n async signMessage(message: string): Promise<string> {\n try {\n return await this.config.privyClient.signMessage(message)\n } catch (error) {\n throw new Error(`Failed to sign message: ${error}`)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,IAAM,sBAAN,MAAoD;AAAA,EACzD,YACU,QACR;AADQ;AAAA,EACP;AAAA,EAEH,MAAM,aAAqC;AACzC,QAAI;AACF,YAAM,UAAU,MAAM,KAAK,OAAO,YAAY,WAAW;AACzD,aAAO,WAAW,KAAK,OAAO,WAAW;AAAA,IAC3C,QAAQ;AACN,aAAO,KAAK,OAAO,WAAW;AAAA,IAChC;AAAA,EACF;AAAA,EAEA,MAAM,eAAuC;AAE3C,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,gBAAgB,IAAuB;AAC3C,QAAI;AACF,YAAM,YAAY,MAAM,KAAK,OAAO,YAAY,gBAAgB,EAAE;AAClE,aAAO,EAAE,GAAG,IAAI,UAAU;AAAA,IAC5B,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,+BAA+B,KAAK,EAAE;AAAA,IACxD;AAAA,EACF;AAAA,EAEA,MAAM,YAAY,SAAkC;AAClD,QAAI;AACF,aAAO,MAAM,KAAK,OAAO,YAAY,YAAY,OAAO;AAAA,IAC1D,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,2BAA2B,KAAK,EAAE;AAAA,IACpD;AAAA,EACF;AACF;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,36 @@
1
+ // src/PrivyWalletProvider.ts
2
+ var PrivyWalletProvider = class {
3
+ constructor(config) {
4
+ this.config = config;
5
+ }
6
+ async getAddress() {
7
+ try {
8
+ const address = await this.config.privyClient.getAddress();
9
+ return address || this.config.address || null;
10
+ } catch {
11
+ return this.config.address || null;
12
+ }
13
+ }
14
+ async getPublicKey() {
15
+ return null;
16
+ }
17
+ async signTransaction(tx) {
18
+ try {
19
+ const signature = await this.config.privyClient.signTransaction(tx);
20
+ return { ...tx, signature };
21
+ } catch (error) {
22
+ throw new Error(`Failed to sign transaction: ${error}`);
23
+ }
24
+ }
25
+ async signMessage(message) {
26
+ try {
27
+ return await this.config.privyClient.signMessage(message);
28
+ } catch (error) {
29
+ throw new Error(`Failed to sign message: ${error}`);
30
+ }
31
+ }
32
+ };
33
+ export {
34
+ PrivyWalletProvider
35
+ };
36
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/PrivyWalletProvider.ts"],"sourcesContent":["import { WalletProvider } from '@vleap/warps'\n\nexport interface PrivyClient {\n getAddress(): Promise<string | null>\n signTransaction(tx: any): Promise<string>\n signMessage(message: string): Promise<string>\n}\n\nexport interface PrivyWalletProviderConfig {\n privyClient: PrivyClient\n address?: string\n}\n\nexport class PrivyWalletProvider implements WalletProvider {\n constructor(\n private config: PrivyWalletProviderConfig\n ) {}\n\n async getAddress(): Promise<string | null> {\n try {\n const address = await this.config.privyClient.getAddress()\n return address || this.config.address || null\n } catch {\n return this.config.address || null\n }\n }\n\n async getPublicKey(): Promise<string | null> {\n // Privy doesn't expose public key directly\n return null\n }\n\n async signTransaction(tx: any): Promise<any> {\n try {\n const signature = await this.config.privyClient.signTransaction(tx)\n return { ...tx, signature }\n } catch (error) {\n throw new Error(`Failed to sign transaction: ${error}`)\n }\n }\n\n async signMessage(message: string): Promise<string> {\n try {\n return await this.config.privyClient.signMessage(message)\n } catch (error) {\n throw new Error(`Failed to sign message: ${error}`)\n }\n }\n}\n"],"mappings":";AAaO,IAAM,sBAAN,MAAoD;AAAA,EACzD,YACU,QACR;AADQ;AAAA,EACP;AAAA,EAEH,MAAM,aAAqC;AACzC,QAAI;AACF,YAAM,UAAU,MAAM,KAAK,OAAO,YAAY,WAAW;AACzD,aAAO,WAAW,KAAK,OAAO,WAAW;AAAA,IAC3C,QAAQ;AACN,aAAO,KAAK,OAAO,WAAW;AAAA,IAChC;AAAA,EACF;AAAA,EAEA,MAAM,eAAuC;AAE3C,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,gBAAgB,IAAuB;AAC3C,QAAI;AACF,YAAM,YAAY,MAAM,KAAK,OAAO,YAAY,gBAAgB,EAAE;AAClE,aAAO,EAAE,GAAG,IAAI,UAAU;AAAA,IAC5B,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,+BAA+B,KAAK,EAAE;AAAA,IACxD;AAAA,EACF;AAAA,EAEA,MAAM,YAAY,SAAkC;AAClD,QAAI;AACF,aAAO,MAAM,KAAK,OAAO,YAAY,YAAY,OAAO;AAAA,IAC1D,SAAS,OAAO;AACd,YAAM,IAAI,MAAM,2BAA2B,KAAK,EAAE;AAAA,IACpD;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@vleap/warps-wallet-privy",
3
+ "version": "1.0.0-beta.0",
4
+ "description": "Privy wallet provider for multiple chains - Node.js compatible, no React dependencies",
5
+ "type": "module",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "default": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsup",
17
+ "test": "jest --config jest.config.mjs",
18
+ "lint": "tsc --noEmit",
19
+ "prepare": "npm run build",
20
+ "preversion": "npm run lint && npm run build"
21
+ },
22
+ "author": "",
23
+ "license": "MIT",
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "devDependencies": {
28
+ "@types/jest": "^30.0.0",
29
+ "jest": "^30.2.0",
30
+ "ts-jest": "^29.4.6",
31
+ "tsup": "^8.5.1",
32
+ "typescript": "^5.9.3"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "dependencies": {
38
+ "@vleap/warps": "workspace:*"
39
+ },
40
+ "peerDependencies": {
41
+ "@vleap/warps": "^3.0.0-beta.174"
42
+ }
43
+ }