pwc-sdk-wallet 0.7.5 → 0.7.6

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 CHANGED
@@ -55,16 +55,295 @@ A comprehensive, secure, and user-friendly wallet SDK for React Native applicati
55
55
  - [Validate QR Code](#validate-qr-code)
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
- ### 🌐 DApp Browser Integration with Wagmi
59
- - [Key Benefits](#key-benefits)
60
- - [Quick Start (Wagmi Integration)](#quick-start-wagmi-integration)
61
- - [What This Achieves](#what-this-achieves)
62
- - [Components](#dapp-browser-components)
63
- - [Services](#dapp-browser-services)
64
- - [Wagmi Integration (Core Feature)](#wagmi-integration-core-feature)
65
- - [Hooks](#dapp-browser-hooks)
66
- - [Examples](#dapp-browser-examples)
67
- - [Summary: Universal dApp Compatibility](#summary-universal-dapp-compatibility)
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).
68
347
 
69
348
  ### 🖼️ NFT Functionality
70
349
  - [Get NFT Details](#get-nft-details)
@@ -704,14 +983,14 @@ console.log('Transaction History:', history);
704
983
  // Returns array of: { hash, from, to, blockNumber, timestamp, type }
705
984
  ```
706
985
 
707
- ## 🌐 DApp Browser Integration with Wagmi
986
+ ## 🌐 DApp Browser Integration
708
987
 
709
- The PWC Wallet SDK provides a complete DApp Browser integration with **Wagmi support**, ensuring that PWC Wallet appears as a connection option in **all dApps** that use Wagmi, ConnectKit, or RainbowKit. This integration follows the same patterns as popular wallets like MetaMask Mobile, Trust Wallet, and Rainbow Wallet.
988
+ 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.
710
989
 
711
- ### 🎯 Key Benefits
990
+ ### Key Benefits
712
991
 
713
- - **Universal dApp Compatibility** - PWC Wallet appears in ALL dApps using Wagmi
714
- - **One-Click Integration** - Simple setup with `createWagmiConfig`
992
+ - **Universal dApp Compatibility** - PWC Wallet appears in ALL dApps automatically
993
+ - **One-Click Integration** - Simple setup with `DAppBrowser` component
715
994
  - **Built-in WebView Browser** - Complete browser with navigation controls
716
995
  - **Automatic Provider Injection** - PWC Wallet provider automatically injected
717
996
  - **Transaction Approval UI** - Beautiful transaction approval modals
@@ -719,79 +998,58 @@ The PWC Wallet SDK provides a complete DApp Browser integration with **Wagmi sup
719
998
  - **Multi-chain Support** - Support for Ethereum and other EVM chains
720
999
  - **Security Features** - Transaction validation and user confirmation
721
1000
 
722
- ### 🚀 Quick Start (Wagmi Integration)
1001
+ ### Quick Start (Direct Provider Injection)
723
1002
 
724
1003
  ```typescript
725
1004
  import React from 'react';
726
- import { WagmiConfig } from 'wagmi';
727
- import { DAppBrowser, createWagmiConfig } from 'pwc-wallet-sdk';
1005
+ import { DAppBrowser } from 'pwc-wallet-sdk';
728
1006
 
729
1007
  const WalletApp = () => {
730
1008
  const vault = new Vault(); // Your vault instance
731
1009
 
732
- // Create Wagmi config with PWC Wallet connector
733
- const wagmiConfig = createWagmiConfig({
734
- vault: vault,
735
- pwcWalletName: 'PWC Wallet',
736
- pwcWalletIcon: 'https://pwc-wallet.com/icon.png'
737
- });
738
-
739
1010
  return (
740
- <WagmiConfig config={wagmiConfig}>
741
- <DAppBrowser
742
- vault={vault}
743
- initialUrl="https://paywithcrypto.io/"
744
- onTransaction={(transaction) => {
745
- console.log('Transaction requested:', transaction);
746
- }}
747
- onConnection={(dAppInfo) => {
748
- console.log('Connection requested:', dAppInfo);
749
- }}
750
- onError={(error) => {
751
- console.error('Browser error:', error);
752
- }}
753
- />
754
- </WagmiConfig>
1011
+ <DAppBrowser
1012
+ vault={vault}
1013
+ initialUrl="https://paywithcrypto.io/"
1014
+ onTransaction={(transaction) => {
1015
+ console.log('Transaction requested:', transaction);
1016
+ }}
1017
+ onConnection={(dAppInfo) => {
1018
+ console.log('Connection requested:', dAppInfo);
1019
+ }}
1020
+ onError={(error) => {
1021
+ console.error('Browser error:', error);
1022
+ }}
1023
+ />
755
1024
  );
756
1025
  };
757
1026
  ```
758
1027
 
759
- ### 🎯 What This Achieves
1028
+ ### What This Achieves
760
1029
 
761
1030
  With this setup, PWC Wallet will appear as a connection option in:
762
1031
 
763
1032
  - ✅ **PancakeSwap** - "Connect Wallet" → PWC Wallet option
764
1033
  - ✅ **Uniswap** - "Connect Wallet" → PWC Wallet option
765
1034
  - ✅ **OpenSea** - "Connect Wallet" → PWC Wallet option
766
- - ✅ **All dApps using Wagmi** - "Connect Wallet" → PWC Wallet option
767
- - ✅ **All dApps using ConnectKit** - "Connect Wallet" → PWC Wallet option
768
- - ✅ **All dApps using RainbowKit** - "Connect Wallet" → PWC Wallet option
1035
+ - ✅ **All dApps** - "Connect Wallet" → PWC Wallet option
769
1036
 
770
1037
  ### DApp Browser Components
771
1038
 
772
1039
  #### DAppBrowser
773
1040
 
774
- The main component that provides a complete WebView browser with PWC Wallet integration. **Must be wrapped with WagmiConfig for universal dApp compatibility.**
1041
+ The main component that provides a complete WebView browser with PWC Wallet integration.
775
1042
 
776
1043
  ```typescript
777
- import { WagmiConfig } from 'wagmi';
778
- import { DAppBrowser, createWagmiConfig } from 'pwc-wallet-sdk';
1044
+ import { DAppBrowser } from 'pwc-wallet-sdk';
779
1045
 
780
- // Create Wagmi config for universal dApp compatibility
781
- const wagmiConfig = createWagmiConfig({
782
- vault: vault,
783
- pwcWalletName: 'PWC Wallet'
784
- });
785
-
786
- <WagmiConfig config={wagmiConfig}>
787
- <DAppBrowser
788
- vault={vault}
789
- initialUrl="https://paywithcrypto.io/"
790
- onTransaction={handleTransaction}
791
- onConnection={handleConnection}
792
- onError={handleError}
793
- />
794
- </WagmiConfig>
1046
+ <DAppBrowser
1047
+ vault={vault}
1048
+ initialUrl="https://paywithcrypto.io/"
1049
+ onTransaction={handleTransaction}
1050
+ onConnection={handleConnection}
1051
+ onError={handleError}
1052
+ />
795
1053
  ```
796
1054
 
797
1055
  #### TransactionModal
@@ -859,37 +1117,27 @@ const transactionHandler = new TransactionHandler(vault);
859
1117
  const details = await transactionHandler.processTransaction(transaction);
860
1118
  ```
861
1119
 
862
- ### 🔌 Wagmi Integration (Core Feature)
1120
+ ### Provider Injection (Core Feature)
863
1121
 
864
- #### PWCWalletConnector
1122
+ #### How It Works
865
1123
 
866
- The **core component** that makes PWC Wallet appear in all dApps. This connector integrates PWC Wallet with the Wagmi ecosystem, ensuring universal compatibility.
1124
+ 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.
867
1125
 
868
1126
  ```typescript
869
- import { PWCWalletConnector, createWagmiConfig } from 'pwc-wallet-sdk';
870
-
871
- // Create PWC Wallet connector
872
- const connector = new PWCWalletConnector({
873
- vault: vault,
874
- name: 'PWC Wallet',
875
- icon: 'https://pwc-wallet.com/icon.png'
876
- });
877
-
878
- // Create complete Wagmi config
879
- const config = createWagmiConfig({
880
- vault: vault,
881
- appName: 'PWC Wallet',
882
- pwcWalletName: 'PWC Wallet',
883
- pwcWalletIcon: 'https://pwc-wallet.com/icon.png'
884
- });
1127
+ // Automatically injected into WebView
1128
+ window.ethereum = window.pwcWallet = {
1129
+ request: async (request) => { /* handle requests */ },
1130
+ on: (event, callback) => { /* event listeners */ },
1131
+ // ... other provider methods
1132
+ };
885
1133
  ```
886
1134
 
887
1135
  #### Why This Matters
888
1136
 
889
- - **Universal Compatibility** - PWC Wallet appears in ALL dApps using Wagmi
1137
+ - **Universal Compatibility** - PWC Wallet appears in ALL dApps automatically
890
1138
  - **No dApp Changes Required** - dApps don't need to add PWC Wallet manually
891
- - **Industry Standard** - Follows the same pattern as MetaMask, WalletConnect
892
- - **Future-Proof** - Works with any new dApp that uses Wagmi
1139
+ - **Industry Standard** - Follows the same pattern as MetaMask, Trust Wallet
1140
+ - **Future-Proof** - Works with any dApp that uses standard Web3 providers
893
1141
 
894
1142
  ### DApp Browser Hooks
895
1143
 
@@ -915,41 +1163,31 @@ const {
915
1163
 
916
1164
  ### DApp Browser Examples
917
1165
 
918
- #### Complete Wallet App with Wagmi Integration
1166
+ #### Complete Wallet App
919
1167
 
920
1168
  ```typescript
921
1169
  import React, { useState } from 'react';
922
1170
  import { View, Text, TouchableOpacity } from 'react-native';
923
- import { WagmiConfig } from 'wagmi';
924
- import { DAppBrowser, usePWCWallet, Vault, createWagmiConfig } from 'pwc-wallet-sdk';
1171
+ import { DAppBrowser, usePWCWallet, Vault } from 'pwc-wallet-sdk';
925
1172
 
926
1173
  const WalletApp = () => {
927
1174
  const [activeTab, setActiveTab] = useState<'wallet' | 'browser'>('wallet');
928
1175
  const vault = new Vault(); // Your vault instance
929
1176
 
930
- // Create Wagmi config for universal dApp compatibility
931
- const wagmiConfig = createWagmiConfig({
932
- vault: vault,
933
- pwcWalletName: 'PWC Wallet',
934
- pwcWalletIcon: 'https://pwc-wallet.com/icon.png'
935
- });
936
-
937
1177
  const { accounts, currentAccount, isConnected, connect, disconnect } = usePWCWallet({ vault });
938
1178
 
939
1179
  if (activeTab === 'browser') {
940
1180
  return (
941
- <WagmiConfig config={wagmiConfig}>
942
- <DAppBrowser
943
- vault={vault}
944
- initialUrl="https://paywithcrypto.io/"
945
- onTransaction={(transaction) => {
946
- console.log('Transaction:', transaction);
947
- }}
948
- onConnection={(dAppInfo) => {
949
- console.log('Connection:', dAppInfo);
950
- }}
951
- />
952
- </WagmiConfig>
1181
+ <DAppBrowser
1182
+ vault={vault}
1183
+ initialUrl="https://paywithcrypto.io/"
1184
+ onTransaction={(transaction) => {
1185
+ console.log('Transaction:', transaction);
1186
+ }}
1187
+ onConnection={(dAppInfo) => {
1188
+ console.log('Connection:', dAppInfo);
1189
+ }}
1190
+ />
953
1191
  );
954
1192
  }
955
1193
 
@@ -980,39 +1218,31 @@ const WalletApp = () => {
980
1218
 
981
1219
  ```typescript
982
1220
  import React from 'react';
983
- import { WagmiConfig } from 'wagmi';
984
- import { DAppBrowser, createWagmiConfig } from 'pwc-wallet-sdk';
1221
+ import { DAppBrowser } from 'pwc-wallet-sdk';
985
1222
 
986
1223
  const PancakeSwapExample = () => {
987
1224
  const vault = new Vault();
988
-
989
- const wagmiConfig = createWagmiConfig({
990
- vault: vault,
991
- pwcWalletName: 'PWC Wallet'
992
- });
993
1225
 
994
1226
  return (
995
- <WagmiConfig config={wagmiConfig}>
996
- <DAppBrowser
997
- vault={vault}
998
- initialUrl="https://pancakeswap.finance/"
999
- onTransaction={(transaction) => {
1000
- console.log('PancakeSwap transaction:', transaction);
1001
- }}
1002
- onConnection={(dAppInfo) => {
1003
- console.log('PancakeSwap connection:', dAppInfo);
1004
- }}
1005
- />
1006
- </WagmiConfig>
1227
+ <DAppBrowser
1228
+ vault={vault}
1229
+ initialUrl="https://pancakeswap.finance/"
1230
+ onTransaction={(transaction) => {
1231
+ console.log('PancakeSwap transaction:', transaction);
1232
+ }}
1233
+ onConnection={(dAppInfo) => {
1234
+ console.log('PancakeSwap connection:', dAppInfo);
1235
+ }}
1236
+ />
1007
1237
  );
1008
1238
  };
1009
1239
  ```
1010
1240
 
1011
1241
  **Result:** When user clicks "Connect Wallet" on PancakeSwap, they will see "PWC Wallet" as an option! 🎯
1012
1242
 
1013
- ### 🎯 Summary: Universal dApp Compatibility
1243
+ ### Summary: Universal dApp Compatibility
1014
1244
 
1015
- The PWC Wallet SDK with Wagmi integration provides **universal dApp compatibility**:
1245
+ The PWC Wallet SDK with direct provider injection provides **universal dApp compatibility**:
1016
1246
 
1017
1247
  #### ✅ **Works with ALL dApps:**
1018
1248
  - **PancakeSwap** - "Connect Wallet" → PWC Wallet option
@@ -1020,30 +1250,26 @@ The PWC Wallet SDK with Wagmi integration provides **universal dApp compatibilit
1020
1250
  - **OpenSea** - "Connect Wallet" → PWC Wallet option
1021
1251
  - **Aave** - "Connect Wallet" → PWC Wallet option
1022
1252
  - **Compound** - "Connect Wallet" → PWC Wallet option
1023
- - **Any dApp using Wagmi** - "Connect Wallet" → PWC Wallet option
1253
+ - **Any dApp** - "Connect Wallet" → PWC Wallet option
1024
1254
 
1025
1255
  #### ✅ **One Setup, Universal Access:**
1026
1256
  ```typescript
1027
1257
  // Mobile dev chỉ cần setup 1 lần
1028
- const wagmiConfig = createWagmiConfig({
1029
- vault: vault,
1030
- pwcWalletName: 'PWC Wallet'
1031
- });
1032
-
1033
- <WagmiConfig config={wagmiConfig}>
1034
- <DAppBrowser vault={vault} />
1035
- </WagmiConfig>
1258
+ <DAppBrowser
1259
+ vault={vault}
1260
+ initialUrl="https://pancakeswap.finance/"
1261
+ />
1036
1262
  ```
1037
1263
 
1038
1264
  #### ✅ **No dApp Changes Required:**
1039
1265
  - dApps don't need to add PWC Wallet manually
1040
1266
  - Works with existing dApp code
1041
- - Follows industry standards (MetaMask, WalletConnect)
1267
+ - Follows industry standards (MetaMask, Trust Wallet)
1042
1268
 
1043
- #### ✅ **No WalletConnect Required:**
1269
+ #### ✅ **No External Dependencies:**
1044
1270
  - PWC Wallet uses built-in browser (WebView)
1045
- - No need for `projectId` or WalletConnect bridge
1046
- - Direct connection without external services
1271
+ - No need for external services or bridges
1272
+ - Direct connection through provider injection
1047
1273
 
1048
1274
  For detailed documentation, see [DApp Browser Integration Guide](./docs/DAPP_BROWSER_INTEGRATION.md).
1049
1275
 
@@ -1435,15 +1661,13 @@ npm install pwc-wallet-sdk
1435
1661
  For DApp Browser functionality with universal dApp compatibility:
1436
1662
 
1437
1663
  ```bash
1438
- npm install pwc-wallet-sdk react-native-webview wagmi connectkit
1664
+ npm install pwc-wallet-sdk react-native-webview
1439
1665
  ```
1440
1666
 
1441
1667
  **Required Dependencies:**
1442
1668
  - `react-native-webview` - For WebView browser functionality
1443
- - `wagmi` - For universal dApp compatibility
1444
- - `connectkit` - For modern wallet connection UI
1445
1669
 
1446
- **Note:** These are peer dependencies. Mobile developers need to install them to use the DApp Browser features.
1670
+ **Note:** This is a peer dependency. Mobile developers need to install it to use the DApp Browser features.
1447
1671
 
1448
1672
  ## Quick Start
1449
1673
 
package/dist/index.d.ts CHANGED
@@ -26,6 +26,4 @@ export * from './services/nft/NFTService';
26
26
  export { DAppBrowser } from './components/DAppBrowser';
27
27
  export { TransactionModal } from './components/TransactionModal';
28
28
  export { ConnectionModal } from './components/ConnectionModal';
29
- export { PWCWalletConnector } from './connectors/PWCWalletConnector';
30
29
  export { usePWCWallet } from './hooks/usePWCWallet';
31
- export { createWagmiConfig } from './utils/wagmi-config';
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.TransactionModal = exports.DAppBrowser = exports.TransactionHandler = exports.MessageBridgeService = exports.BrowserProviderService = exports.QRCodeService = exports.BatchProcessor = exports.MultiTransferService = exports.EncryptionService = exports.SolanaChainService = exports.ChainService = exports.SolanaKeyring = exports.SimpleKeyring = exports.HDKeyring = exports.getEnvVarBoolean = exports.getEnvVarBigInt = exports.getEnvVarNumber = exports.getEnvVar = exports.validateEnvironmentConfig = exports.getEnvironmentConfig = exports.VALIDATION_CONFIG = exports.CACHE_CONFIG = exports.NETWORK_CONFIG = exports.SECURITY_CONFIG = exports.VANITY_WALLET_CONFIG = exports.clearGlobalGasConfigs = exports.getGasConfig = exports.setGlobalNetworkGasConfig = exports.setGlobalGasConfig = exports.calculateOptimalGasPrice = exports.getNetworkGasConfig = exports.NETWORK_GAS_CONFIG = exports.GAS_CONFIG = exports.clearGlobalConfigs = exports.setGlobalExplorerConfig = exports.setGlobalRPCConfig = exports.getOverrides = exports.getCustomChains = exports.clearOverride = exports.clearOverrides = exports.clearCustomChains = exports.getAllAvailableChains = exports.setupChainConfigs = exports.getChainConfig = exports.overrideChains = exports.overrideChain = exports.registerCustomChain = exports.DERIVATION_PATHS = exports.SUPPORTED_CHAINS = exports.Vault = void 0;
19
- exports.createWagmiConfig = exports.usePWCWallet = exports.PWCWalletConnector = exports.ConnectionModal = void 0;
19
+ exports.usePWCWallet = exports.ConnectionModal = void 0;
20
20
  // The primary `Vault` class is the main entry point for interacting with the SDK.
21
21
  var Vault_1 = require("./Vault");
22
22
  Object.defineProperty(exports, "Vault", { enumerable: true, get: function () { return Vault_1.Vault; } });
@@ -109,12 +109,6 @@ var TransactionModal_1 = require("./components/TransactionModal");
109
109
  Object.defineProperty(exports, "TransactionModal", { enumerable: true, get: function () { return TransactionModal_1.TransactionModal; } });
110
110
  var ConnectionModal_1 = require("./components/ConnectionModal");
111
111
  Object.defineProperty(exports, "ConnectionModal", { enumerable: true, get: function () { return ConnectionModal_1.ConnectionModal; } });
112
- // Wagmi connector
113
- var PWCWalletConnector_1 = require("./connectors/PWCWalletConnector");
114
- Object.defineProperty(exports, "PWCWalletConnector", { enumerable: true, get: function () { return PWCWalletConnector_1.PWCWalletConnector; } });
115
- // React Native hooks
112
+ // DApp Browser Hooks
116
113
  var usePWCWallet_1 = require("./hooks/usePWCWallet");
117
114
  Object.defineProperty(exports, "usePWCWallet", { enumerable: true, get: function () { return usePWCWallet_1.usePWCWallet; } });
118
- // Utilities
119
- var wagmi_config_1 = require("./utils/wagmi-config");
120
- Object.defineProperty(exports, "createWagmiConfig", { enumerable: true, get: function () { return wagmi_config_1.createWagmiConfig; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pwc-sdk-wallet",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
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",
@@ -56,9 +56,7 @@
56
56
  "react": "*",
57
57
  "react-native": "*",
58
58
  "react-native-get-random-values": "^1.9.0",
59
- "react-native-keychain": "^8.2.0",
60
- "wagmi": "^1.0.0",
61
- "connectkit": "^1.0.0"
59
+ "react-native-keychain": "^8.2.0"
62
60
  },
63
61
  "devDependencies": {
64
62
  "@types/crypto-js": "^4.2.2",
@@ -1,107 +0,0 @@
1
- import { EventEmitter } from 'events';
2
- import { Vault } from '../Vault';
3
- interface ConnectorData {
4
- account: string;
5
- chain: {
6
- id: number;
7
- unsupported: boolean;
8
- };
9
- }
10
- declare abstract class Connector extends EventEmitter {
11
- abstract readonly id: string;
12
- abstract readonly name: string;
13
- abstract readonly ready: boolean;
14
- abstract connect(): Promise<ConnectorData>;
15
- abstract disconnect(): Promise<void>;
16
- abstract getAccount(): Promise<string | undefined>;
17
- abstract getChainId(): Promise<number>;
18
- abstract getProvider(): Promise<any>;
19
- abstract getSigner(): Promise<any>;
20
- abstract isAuthorized(): Promise<boolean>;
21
- abstract switchChain(chainId: number): Promise<{
22
- id: number;
23
- unsupported: boolean;
24
- }>;
25
- }
26
- export interface PWCWalletConnectorOptions {
27
- vault: Vault;
28
- name?: string;
29
- icon?: string;
30
- }
31
- export declare class PWCWalletConnector extends Connector {
32
- readonly id = "pwc-wallet";
33
- readonly name: string;
34
- readonly ready = true;
35
- readonly icon?: string;
36
- private vault;
37
- private accounts;
38
- constructor({ vault, name, icon }: PWCWalletConnectorOptions);
39
- /**
40
- * Connect to PWC Wallet
41
- */
42
- connect(): Promise<ConnectorData>;
43
- /**
44
- * Disconnect from PWC Wallet
45
- */
46
- disconnect(): Promise<void>;
47
- /**
48
- * Get current account
49
- */
50
- getAccount(): Promise<string | undefined>;
51
- /**
52
- * Get current chain ID
53
- */
54
- getChainId(): Promise<number>;
55
- /**
56
- * Get provider
57
- */
58
- getProvider(): Promise<any>;
59
- /**
60
- * Get signer
61
- */
62
- getSigner(): Promise<any>;
63
- /**
64
- * Check if wallet is connected
65
- */
66
- isAuthorized(): Promise<boolean>;
67
- /**
68
- * Switch chain
69
- */
70
- switchChain(chainId: number): Promise<{
71
- id: number;
72
- unsupported: boolean;
73
- }>;
74
- /**
75
- * Watch account
76
- */
77
- protected onAccountsChanged(accounts: string[]): void;
78
- /**
79
- * Watch chain
80
- */
81
- protected onChainChanged(chainId: string | number): void;
82
- /**
83
- * Watch disconnect
84
- */
85
- protected onDisconnect(): void;
86
- /**
87
- * Handle provider requests
88
- */
89
- private handleProviderRequest;
90
- /**
91
- * Get account balance
92
- */
93
- private getBalance;
94
- /**
95
- * Send transaction
96
- */
97
- private sendTransaction;
98
- /**
99
- * Sign message
100
- */
101
- private signMessage;
102
- /**
103
- * Sign transaction
104
- */
105
- private signTransaction;
106
- }
107
- export {};
@@ -1,195 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PWCWalletConnector = void 0;
4
- const events_1 = require("events");
5
- class Connector extends events_1.EventEmitter {
6
- }
7
- class PWCWalletConnector extends Connector {
8
- constructor({ vault, name = 'PWC Wallet', icon }) {
9
- super();
10
- this.id = 'pwc-wallet';
11
- this.ready = true;
12
- this.accounts = [];
13
- this.vault = vault;
14
- this.name = name;
15
- this.icon = icon;
16
- }
17
- /**
18
- * Connect to PWC Wallet
19
- */
20
- async connect() {
21
- try {
22
- // Get accounts from vault
23
- const vaultAccounts = await this.vault.getAccounts();
24
- this.accounts = vaultAccounts.map(account => account.address);
25
- if (this.accounts.length === 0) {
26
- throw new Error('No accounts found in PWC Wallet');
27
- }
28
- // Get chain ID (default to Ethereum mainnet)
29
- const chainId = 1; // Ethereum mainnet
30
- return {
31
- account: this.accounts[0],
32
- chain: {
33
- id: chainId,
34
- unsupported: false,
35
- },
36
- };
37
- }
38
- catch (error) {
39
- throw new Error(`Failed to connect to PWC Wallet: ${error instanceof Error ? error.message : 'Unknown error'}`);
40
- }
41
- }
42
- /**
43
- * Disconnect from PWC Wallet
44
- */
45
- async disconnect() {
46
- this.accounts = [];
47
- this.emit('disconnect');
48
- }
49
- /**
50
- * Get current account
51
- */
52
- async getAccount() {
53
- return this.accounts[0];
54
- }
55
- /**
56
- * Get current chain ID
57
- */
58
- async getChainId() {
59
- return 1; // Default to Ethereum mainnet
60
- }
61
- /**
62
- * Get provider
63
- */
64
- async getProvider() {
65
- // Return a mock provider that delegates to PWC Wallet
66
- return {
67
- request: async (request) => {
68
- return this.handleProviderRequest(request);
69
- },
70
- };
71
- }
72
- /**
73
- * Get signer
74
- */
75
- async getSigner() {
76
- const provider = await this.getProvider();
77
- return {
78
- provider,
79
- getAddress: async () => this.accounts[0],
80
- signMessage: async (message) => {
81
- return this.signMessage(message);
82
- },
83
- signTransaction: async (transaction) => {
84
- return this.signTransaction(transaction);
85
- },
86
- };
87
- }
88
- /**
89
- * Check if wallet is connected
90
- */
91
- async isAuthorized() {
92
- return this.accounts.length > 0;
93
- }
94
- /**
95
- * Switch chain
96
- */
97
- async switchChain(chainId) {
98
- // For now, only support Ethereum mainnet
99
- if (chainId !== 1) {
100
- throw new Error('Chain not supported');
101
- }
102
- return {
103
- id: chainId,
104
- unsupported: false,
105
- };
106
- }
107
- /**
108
- * Watch account
109
- */
110
- onAccountsChanged(accounts) {
111
- if (accounts.length === 0) {
112
- this.emit('disconnect');
113
- }
114
- else {
115
- this.accounts = accounts;
116
- this.emit('change', { account: accounts[0] });
117
- }
118
- }
119
- /**
120
- * Watch chain
121
- */
122
- onChainChanged(chainId) {
123
- this.emit('change', { chain: { id: Number(chainId), unsupported: false } });
124
- }
125
- /**
126
- * Watch disconnect
127
- */
128
- onDisconnect() {
129
- this.emit('disconnect');
130
- }
131
- /**
132
- * Handle provider requests
133
- */
134
- async handleProviderRequest(request) {
135
- const { method, params = [] } = request;
136
- switch (method) {
137
- case 'eth_accounts':
138
- return this.accounts;
139
- case 'eth_chainId':
140
- return '0x1'; // Ethereum mainnet
141
- case 'eth_getBalance':
142
- const [address, blockTag] = params;
143
- return await this.getBalance(address, blockTag);
144
- case 'eth_sendTransaction':
145
- const [transaction] = params;
146
- return await this.sendTransaction(transaction);
147
- case 'personal_sign':
148
- const [message, account] = params;
149
- return await this.signMessage(message, account);
150
- case 'eth_signTransaction':
151
- const [txToSign] = params;
152
- return await this.signTransaction(txToSign);
153
- case 'wallet_requestAccounts':
154
- return this.accounts;
155
- case 'wallet_addEthereumChain':
156
- return null;
157
- case 'wallet_switchEthereumChain':
158
- return null;
159
- default:
160
- throw new Error(`Method ${method} not supported`);
161
- }
162
- }
163
- /**
164
- * Get account balance
165
- */
166
- async getBalance(address, blockTag = 'latest') {
167
- // This would integrate with actual blockchain RPC
168
- return '0x0';
169
- }
170
- /**
171
- * Send transaction
172
- */
173
- async sendTransaction(transaction) {
174
- // This will trigger transaction approval modal
175
- // For now, return a placeholder
176
- return '0x1234567890abcdef';
177
- }
178
- /**
179
- * Sign message
180
- */
181
- async signMessage(message, account) {
182
- // This will trigger message signing approval
183
- // For now, return a placeholder
184
- return '0x1234567890abcdef';
185
- }
186
- /**
187
- * Sign transaction
188
- */
189
- async signTransaction(transaction) {
190
- // This will trigger transaction signing approval
191
- // For now, return a placeholder
192
- return '0x1234567890abcdef';
193
- }
194
- }
195
- exports.PWCWalletConnector = PWCWalletConnector;
@@ -1,12 +0,0 @@
1
- import { PWCWalletConnector } from '../connectors/PWCWalletConnector';
2
- import { Vault } from '../Vault';
3
- export interface WagmiConfigOptions {
4
- vault: Vault;
5
- appName?: string;
6
- pwcWalletName?: string;
7
- pwcWalletIcon?: string;
8
- }
9
- export declare const createWagmiConfig: (options: WagmiConfigOptions) => {
10
- appName: string;
11
- connectors: PWCWalletConnector[];
12
- };
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createWagmiConfig = void 0;
4
- const PWCWalletConnector_1 = require("../connectors/PWCWalletConnector");
5
- const createWagmiConfig = (options) => {
6
- const { vault, appName = 'PWC Wallet', pwcWalletName = 'PWC Wallet', pwcWalletIcon, } = options;
7
- // Create PWC Wallet connector
8
- const pwcWalletConnector = new PWCWalletConnector_1.PWCWalletConnector({
9
- vault,
10
- name: pwcWalletName,
11
- icon: pwcWalletIcon,
12
- });
13
- // Return configuration object for PWC Wallet
14
- // Note: No projectId needed since PWC Wallet uses built-in browser, not WalletConnect
15
- return {
16
- appName,
17
- connectors: [pwcWalletConnector],
18
- // Add other Wagmi configuration options as needed
19
- };
20
- };
21
- exports.createWagmiConfig = createWagmiConfig;