pwc-sdk-wallet 0.7.6 β†’ 0.7.7

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.
Files changed (2) hide show
  1. package/README.md +9 -288
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -56,294 +56,15 @@ A comprehensive, secure, and user-friendly wallet SDK for React Native applicati
56
56
  - [Generate EIP-681 Compatible Address QR (for Metamask, Binance, Trust Wallet)](#generate-eip-681-compatible-address-qr-for-metamask-binance-trust-wallet)
57
57
 
58
58
  ### 🌐 DApp Browser Integration
59
-
60
- The PWC Wallet SDK provides a complete DApp Browser integration with **direct provider injection**, ensuring that PWC Wallet appears as a connection option in **all dApps**. This integration follows the same patterns as popular wallets like MetaMask Mobile, Trust Wallet, and Rainbow Wallet.
61
-
62
- ### Key Benefits
63
-
64
- - **Universal dApp Compatibility** - PWC Wallet appears in ALL dApps automatically
65
- - **One-Click Integration** - Simple setup with `DAppBrowser` component
66
- - **Built-in WebView Browser** - Complete browser with navigation controls
67
- - **Automatic Provider Injection** - PWC Wallet provider automatically injected
68
- - **Transaction Approval UI** - Beautiful transaction approval modals
69
- - **Connection Approval UI** - dApp connection approval modals
70
- - **Multi-chain Support** - Support for Ethereum and other EVM chains
71
- - **Security Features** - Transaction validation and user confirmation
72
-
73
- ### Quick Start (Direct Provider Injection)
74
-
75
- ```typescript
76
- import React from 'react';
77
- import { DAppBrowser } from 'pwc-wallet-sdk';
78
-
79
- const WalletApp = () => {
80
- const vault = new Vault(); // Your vault instance
81
-
82
- return (
83
- <DAppBrowser
84
- vault={vault}
85
- initialUrl="https://web3.paywithcrypto.today/"
86
- onTransaction={(transaction) => {
87
- console.log('Transaction requested:', transaction);
88
- }}
89
- onConnection={(dAppInfo) => {
90
- console.log('Connection requested:', dAppInfo);
91
- }}
92
- onError={(error) => {
93
- console.error('Browser error:', error);
94
- }}
95
- />
96
- );
97
- };
98
- ```
99
-
100
- ### What This Achieves
101
-
102
- With this setup, PWC Wallet will appear as a connection option in:
103
-
104
- - βœ… **PancakeSwap** - "Connect Wallet" β†’ PWC Wallet option
105
- - βœ… **Uniswap** - "Connect Wallet" β†’ PWC Wallet option
106
- - βœ… **OpenSea** - "Connect Wallet" β†’ PWC Wallet option
107
- - βœ… **All dApps** - "Connect Wallet" β†’ PWC Wallet option
108
-
109
- ### DApp Browser Components
110
-
111
- #### DAppBrowser
112
-
113
- The main component that provides a complete WebView browser with PWC Wallet integration.
114
-
115
- ```typescript
116
- import { DAppBrowser } from 'pwc-wallet-sdk';
117
-
118
- <DAppBrowser
119
- vault={vault}
120
- initialUrl="https://paywithcrypto.io/"
121
- onTransaction={handleTransaction}
122
- onConnection={handleConnection}
123
- onError={handleError}
124
- />
125
- ```
126
-
127
- #### TransactionModal
128
-
129
- A modal component for approving/rejecting transactions.
130
-
131
- ```typescript
132
- import { TransactionModal } from 'pwc-wallet-sdk';
133
-
134
- <TransactionModal
135
- visible={showTransactionModal}
136
- transaction={pendingTransaction}
137
- onApprove={handleApprove}
138
- onReject={handleReject}
139
- />
140
- ```
141
-
142
- #### ConnectionModal
143
-
144
- A modal component for approving/rejecting dApp connections.
145
-
146
- ```typescript
147
- import { ConnectionModal } from 'pwc-wallet-sdk';
148
-
149
- <ConnectionModal
150
- visible={showConnectionModal}
151
- dAppInfo={pendingConnection}
152
- onApprove={handleApprove}
153
- onReject={handleReject}
154
- />
155
- ```
156
-
157
- ### DApp Browser Services
158
-
159
- #### BrowserProviderService
160
-
161
- Handles the injection of PWC Wallet provider into WebView and processes dApp requests.
162
-
163
- ```typescript
164
- import { BrowserProviderService } from 'pwc-wallet-sdk';
165
-
166
- const browserProviderService = new BrowserProviderService(vault);
167
- const providerScript = browserProviderService.injectPWCWalletProvider();
168
- ```
169
-
170
- #### MessageBridgeService
171
-
172
- Manages communication between WebView and React Native.
173
-
174
- ```typescript
175
- import { MessageBridgeService } from 'pwc-wallet-sdk';
176
-
177
- const messageBridgeService = new MessageBridgeService();
178
- messageBridgeService.setWebViewRef(webViewRef.current);
179
- ```
180
-
181
- #### TransactionHandler
182
-
183
- Processes and validates transactions.
184
-
185
- ```typescript
186
- import { TransactionHandler } from 'pwc-wallet-sdk';
187
-
188
- const transactionHandler = new TransactionHandler(vault);
189
- const details = await transactionHandler.processTransaction(transaction);
190
- ```
191
-
192
- ### Provider Injection (Core Feature)
193
-
194
- #### How It Works
195
-
196
- The **core mechanism** that makes PWC Wallet appear in all dApps. The SDK automatically injects the PWC Wallet provider into the WebView, making it available to all dApps.
197
-
198
- ```typescript
199
- // Automatically injected into WebView
200
- window.ethereum = window.pwcWallet = {
201
- request: async (request) => { /* handle requests */ },
202
- on: (event, callback) => { /* event listeners */ },
203
- // ... other provider methods
204
- };
205
- ```
206
-
207
- #### Why This Matters
208
-
209
- - **Universal Compatibility** - PWC Wallet appears in ALL dApps automatically
210
- - **No dApp Changes Required** - dApps don't need to add PWC Wallet manually
211
- - **Industry Standard** - Follows the same pattern as MetaMask, Trust Wallet
212
- - **Future-Proof** - Works with any dApp that uses standard Web3 providers
213
-
214
- ### DApp Browser Hooks
215
-
216
- #### usePWCWallet
217
-
218
- A React hook that provides easy access to PWC Wallet functionality.
219
-
220
- ```typescript
221
- import { usePWCWallet } from 'pwc-wallet-sdk';
222
-
223
- const {
224
- accounts,
225
- currentAccount,
226
- isConnected,
227
- connect,
228
- disconnect,
229
- sendTransaction,
230
- signMessage,
231
- isLoading,
232
- error
233
- } = usePWCWallet({ vault });
234
- ```
235
-
236
- ### DApp Browser Examples
237
-
238
- #### Complete Wallet App
239
-
240
- ```typescript
241
- import React, { useState } from 'react';
242
- import { View, Text, TouchableOpacity } from 'react-native';
243
- import { DAppBrowser, usePWCWallet, Vault } from 'pwc-wallet-sdk';
244
-
245
- const WalletApp = () => {
246
- const [activeTab, setActiveTab] = useState<'wallet' | 'browser'>('wallet');
247
- const vault = new Vault(); // Your vault instance
248
-
249
- const { accounts, currentAccount, isConnected, connect, disconnect } = usePWCWallet({ vault });
250
-
251
- if (activeTab === 'browser') {
252
- return (
253
- <DAppBrowser
254
- vault={vault}
255
- initialUrl="https://paywithcrypto.io/"
256
- onTransaction={(transaction) => {
257
- console.log('Transaction:', transaction);
258
- }}
259
- onConnection={(dAppInfo) => {
260
- console.log('Connection:', dAppInfo);
261
- }}
262
- />
263
- );
264
- }
265
-
266
- return (
267
- <View>
268
- <Text>PWC Wallet</Text>
269
- {isConnected ? (
270
- <View>
271
- <Text>Connected: {currentAccount}</Text>
272
- <TouchableOpacity onPress={() => setActiveTab('browser')}>
273
- <Text>Open Browser</Text>
274
- </TouchableOpacity>
275
- <TouchableOpacity onPress={disconnect}>
276
- <Text>Disconnect</Text>
277
- </TouchableOpacity>
278
- </View>
279
- ) : (
280
- <TouchableOpacity onPress={connect}>
281
- <Text>Connect Wallet</Text>
282
- </TouchableOpacity>
283
- )}
284
- </View>
285
- );
286
- };
287
- ```
288
-
289
- #### Real-World Example: PancakeSwap Integration
290
-
291
- ```typescript
292
- import React from 'react';
293
- import { DAppBrowser } from 'pwc-wallet-sdk';
294
-
295
- const PancakeSwapExample = () => {
296
- const vault = new Vault();
297
-
298
- return (
299
- <DAppBrowser
300
- vault={vault}
301
- initialUrl="https://pancakeswap.finance/"
302
- onTransaction={(transaction) => {
303
- console.log('PancakeSwap transaction:', transaction);
304
- }}
305
- onConnection={(dAppInfo) => {
306
- console.log('PancakeSwap connection:', dAppInfo);
307
- }}
308
- />
309
- );
310
- };
311
- ```
312
-
313
- **Result:** When user clicks "Connect Wallet" on PancakeSwap, they will see "PWC Wallet" as an option! 🎯
314
-
315
- ### Summary: Universal dApp Compatibility
316
-
317
- The PWC Wallet SDK with direct provider injection provides **universal dApp compatibility**:
318
-
319
- #### βœ… **Works with ALL dApps:**
320
- - **PancakeSwap** - "Connect Wallet" β†’ PWC Wallet option
321
- - **Uniswap** - "Connect Wallet" β†’ PWC Wallet option
322
- - **OpenSea** - "Connect Wallet" β†’ PWC Wallet option
323
- - **Aave** - "Connect Wallet" β†’ PWC Wallet option
324
- - **Compound** - "Connect Wallet" β†’ PWC Wallet option
325
- - **Any dApp** - "Connect Wallet" β†’ PWC Wallet option
326
-
327
- #### βœ… **One Setup, Universal Access:**
328
- ```typescript
329
- // Mobile dev chỉ cαΊ§n setup 1 lαΊ§n
330
- <DAppBrowser
331
- vault={vault}
332
- initialUrl="https://pancakeswap.finance/"
333
- />
334
- ```
335
-
336
- #### βœ… **No dApp Changes Required:**
337
- - dApps don't need to add PWC Wallet manually
338
- - Works with existing dApp code
339
- - Follows industry standards (MetaMask, Trust Wallet)
340
-
341
- #### βœ… **No External Dependencies:**
342
- - PWC Wallet uses built-in browser (WebView)
343
- - No need for external services or bridges
344
- - Direct connection through provider injection
345
-
346
- For detailed documentation, see [DApp Browser Integration Guide](./docs/DAPP_BROWSER_INTEGRATION.md).
59
+ - [Key Benefits](#key-benefits)
60
+ - [Quick Start (Direct Provider Injection)](#quick-start-direct-provider-injection)
61
+ - [What This Achieves](#what-this-achieves)
62
+ - [DApp Browser Components](#dapp-browser-components)
63
+ - [DApp Browser Services](#dapp-browser-services)
64
+ - [Provider Injection (Core Feature)](#provider-injection-core-feature)
65
+ - [DApp Browser Hooks](#dapp-browser-hooks)
66
+ - [DApp Browser Examples](#dapp-browser-examples)
67
+ - [Summary: Universal dApp Compatibility](#summary-universal-dapp-compatibility)
347
68
 
348
69
  ### πŸ–ΌοΈ NFT Functionality
349
70
  - [Get NFT Details](#get-nft-details)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pwc-sdk-wallet",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "A comprehensive wallet SDK for React Native (pwc), supporting multi-chain and multi-account features.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",