pwc-sdk-wallet 0.7.6 โ 0.7.8
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 +200 -294
- package/dist/Vault.d.ts +91 -1
- package/dist/Vault.js +216 -3
- package/dist/chain/SolanaChainService.d.ts +68 -4
- package/dist/chain/SolanaChainService.js +166 -34
- package/dist/services/BatchProcessor.js +5 -1
- package/dist/services/nft/NFTService.d.ts +29 -2
- package/dist/services/nft/NFTService.js +249 -24
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -37,14 +37,20 @@ A comprehensive, secure, and user-friendly wallet SDK for React Native applicati
|
|
|
37
37
|
- [Get Native Balance](#get-native-balance)
|
|
38
38
|
- [Get Token Balance](#get-token-balance)
|
|
39
39
|
- [Get Token Info](#get-token-info)
|
|
40
|
+
- [Get SPL Token Balance (Solana)](#get-spl-token-balance)
|
|
41
|
+
- [Get SPL Token Info (Solana)](#get-spl-token-info)
|
|
42
|
+
- [Estimate SPL Token Transfer Fee](#estimate-spl-token-transfer-fee)
|
|
43
|
+
- [Popular Solana SPL Tokens](#popular-solana-spl-tokens)
|
|
40
44
|
- [Transaction Functions](#transaction-functions)
|
|
41
45
|
- [Send Native Token](#send-native-token)
|
|
42
46
|
- [Send Token](#send-token)
|
|
47
|
+
- [Send SPL Token (Solana)](#send-spl-token-solana)
|
|
43
48
|
- [Export Mnemonic](#export-mnemonic)
|
|
44
49
|
|
|
45
50
|
### ๐ Multi-Transfer Operations
|
|
46
51
|
- [Batch Send Native Tokens](#batch-send-native-tokens)
|
|
47
52
|
- [Batch Send ERC-20 Tokens](#batch-send-erc-20-tokens)
|
|
53
|
+
- [Multi-Transfer (Batch Send) - Simple Usage](#multi-transfer-batch-send---simple-usage)
|
|
48
54
|
|
|
49
55
|
### ๐ฑ QR Code Functionality
|
|
50
56
|
- [Generate Address QR](#generate-address-qr)
|
|
@@ -56,294 +62,15 @@ A comprehensive, secure, and user-friendly wallet SDK for React Native applicati
|
|
|
56
62
|
- [Generate EIP-681 Compatible Address QR (for Metamask, Binance, Trust Wallet)](#generate-eip-681-compatible-address-qr-for-metamask-binance-trust-wallet)
|
|
57
63
|
|
|
58
64
|
### ๐ DApp Browser Integration
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
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).
|
|
65
|
+
- [Key Benefits](#key-benefits)
|
|
66
|
+
- [Quick Start (Direct Provider Injection)](#quick-start-direct-provider-injection)
|
|
67
|
+
- [What This Achieves](#what-this-achieves)
|
|
68
|
+
- [DApp Browser Components](#dapp-browser-components)
|
|
69
|
+
- [DApp Browser Services](#dapp-browser-services)
|
|
70
|
+
- [Provider Injection (Core Feature)](#provider-injection-core-feature)
|
|
71
|
+
- [DApp Browser Hooks](#dapp-browser-hooks)
|
|
72
|
+
- [DApp Browser Examples](#dapp-browser-examples)
|
|
73
|
+
- [Summary: Universal dApp Compatibility](#summary-universal-dapp-compatibility)
|
|
347
74
|
|
|
348
75
|
### ๐ผ๏ธ NFT Functionality
|
|
349
76
|
- [Get NFT Details](#get-nft-details)
|
|
@@ -355,6 +82,9 @@ For detailed documentation, see [DApp Browser Integration Guide](./docs/DAPP_BRO
|
|
|
355
82
|
- [React Native NFT Component Example](#react-native-nft-component-example)
|
|
356
83
|
- [Get Owned NFTs](#get-owned-nfts)
|
|
357
84
|
- [Transfer NFT](#transfer-nft)
|
|
85
|
+
- [Transfer Solana NFT](#transfer-solana-nft)
|
|
86
|
+
- [Get Solana NFT Balance](#get-solana-nft-balance)
|
|
87
|
+
- [Get Solana NFT Details](#get-solana-nft-details)
|
|
358
88
|
- [Estimate NFT Transfer Gas](#estimate-nft-transfer-gas)
|
|
359
89
|
|
|
360
90
|
### โฝ Advanced Features
|
|
@@ -401,7 +131,26 @@ For detailed documentation, see [DApp Browser Integration Guide](./docs/DAPP_BRO
|
|
|
401
131
|
### ๐ ๏ธ Development
|
|
402
132
|
- [Contributing](#contributing)
|
|
403
133
|
|
|
134
|
+
### ๐ฅ New API: Simple chainId-based usage
|
|
135
|
+
- [Simple chainId-based usage](#new-api-simple-chainid-based-usage)
|
|
136
|
+
|
|
137
|
+
### ๐ฑ QR Code Functionality
|
|
138
|
+
- [Generate Address QR](#generate-address-qr)
|
|
139
|
+
- [Generate Mnemonic QR](#generate-mnemonic-qr)
|
|
140
|
+
- [Generate Transaction QR](#generate-transaction-qr)
|
|
141
|
+
- [Import Wallet from QR](#import-wallet-from-qr)
|
|
142
|
+
- [Process Transaction from QR](#process-transaction-from-qr)
|
|
143
|
+
- [Validate QR Code](#validate-qr-code)
|
|
144
|
+
- [Generate EIP-681 Compatible Address QR](#generate-eip-681-compatible-address-qr-for-metamask-binance-trust-wallet)
|
|
145
|
+
|
|
404
146
|
### ๐ ๏ธ Advanced Transaction Utilities
|
|
147
|
+
- [Build Generic Transaction](#build-generic-transaction)
|
|
148
|
+
- [Sign Transaction (Vault)](#sign-transaction-recommended---using-vault)
|
|
149
|
+
- [Sign Transaction (Private Key)](#sign-transaction-deprecated---using-private-key)
|
|
150
|
+
- [Send Raw Transaction](#send-raw-transaction)
|
|
151
|
+
- [Approve Token (Vault)](#approve-token-recommended---using-vault)
|
|
152
|
+
- [Approve Token (Private Key)](#approve-token-deprecated---using-private-key)
|
|
153
|
+
- [Track Transaction Status](#track-transaction-status)
|
|
405
154
|
|
|
406
155
|
### Build Generic Transaction
|
|
407
156
|
Builds an unsigned transaction for any contract method.
|
|
@@ -1254,7 +1003,7 @@ The PWC Wallet SDK with direct provider injection provides **universal dApp comp
|
|
|
1254
1003
|
|
|
1255
1004
|
#### โ
**One Setup, Universal Access:**
|
|
1256
1005
|
```typescript
|
|
1257
|
-
// Mobile
|
|
1006
|
+
// Mobile developers only need to setup once
|
|
1258
1007
|
<DAppBrowser
|
|
1259
1008
|
vault={vault}
|
|
1260
1009
|
initialUrl="https://pancakeswap.finance/"
|
|
@@ -1473,7 +1222,7 @@ Transfers an NFT (ERC-721) from one address to another.
|
|
|
1473
1222
|
- `tokenId` - Token ID to transfer (string)
|
|
1474
1223
|
|
|
1475
1224
|
```typescript
|
|
1476
|
-
//
|
|
1225
|
+
// Send ERC-721 NFT from this wallet to another wallet
|
|
1477
1226
|
const tx = await vault.transferNFT(
|
|
1478
1227
|
'0xSenderAddress',
|
|
1479
1228
|
'0xRecipientAddress',
|
|
@@ -1483,7 +1232,88 @@ const tx = await vault.transferNFT(
|
|
|
1483
1232
|
console.log('NFT transfer tx hash:', tx.hash);
|
|
1484
1233
|
```
|
|
1485
1234
|
|
|
1486
|
-
> **Note:**
|
|
1235
|
+
> **Note:** Currently supports EVM chains (Ethereum, BSC, etc.) and Solana NFTs. Solana NFT transfers are now fully supported!
|
|
1236
|
+
|
|
1237
|
+
#### Transfer Solana NFT
|
|
1238
|
+
Transfers a Solana NFT from one address to another using the dedicated Solana NFT method.
|
|
1239
|
+
|
|
1240
|
+
**Parameters:**
|
|
1241
|
+
- `fromAddress` - Sender's address
|
|
1242
|
+
- `toAddress` - Recipient's address
|
|
1243
|
+
- `mintAddress` - The NFT mint address
|
|
1244
|
+
- `commitment` - Optional commitment level (default: 'confirmed')
|
|
1245
|
+
|
|
1246
|
+
```typescript
|
|
1247
|
+
// Transfer a Solana NFT
|
|
1248
|
+
const tx = await vault.transferSolanaNFT(
|
|
1249
|
+
'0xYourAddress...',
|
|
1250
|
+
'0xRecipient...',
|
|
1251
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // NFT mint address
|
|
1252
|
+
);
|
|
1253
|
+
console.log('Solana NFT transfer hash:', tx.hash);
|
|
1254
|
+
|
|
1255
|
+
// With custom commitment level
|
|
1256
|
+
const txFast = await vault.transferSolanaNFT(
|
|
1257
|
+
'0xYourAddress...',
|
|
1258
|
+
'0xRecipient...',
|
|
1259
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
1260
|
+
'processed' // Fastest confirmation
|
|
1261
|
+
);
|
|
1262
|
+
```
|
|
1263
|
+
|
|
1264
|
+
#### Get Solana NFT Balance
|
|
1265
|
+
Gets Solana NFT balance for a specific address.
|
|
1266
|
+
|
|
1267
|
+
**Parameters:**
|
|
1268
|
+
- `address` - Wallet address to check balance for
|
|
1269
|
+
- `mintAddress` - The NFT mint address
|
|
1270
|
+
- `commitment` - Optional commitment level (default: 'confirmed')
|
|
1271
|
+
|
|
1272
|
+
```typescript
|
|
1273
|
+
// Check if you own a specific Solana NFT
|
|
1274
|
+
const balance = await vault.getSolanaNFTBalance(
|
|
1275
|
+
'0xYourAddress...',
|
|
1276
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
1277
|
+
);
|
|
1278
|
+
|
|
1279
|
+
if (balance.count > 0) {
|
|
1280
|
+
console.log('You own this NFT!');
|
|
1281
|
+
} else {
|
|
1282
|
+
console.log('You do not own this NFT');
|
|
1283
|
+
}
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
#### Get Solana NFT Details
|
|
1287
|
+
Gets detailed Solana NFT information with metadata.
|
|
1288
|
+
|
|
1289
|
+
**Parameters:**
|
|
1290
|
+
- `mintAddress` - The NFT mint address
|
|
1291
|
+
- `options` - Query options for additional data
|
|
1292
|
+
- `commitment` - Optional commitment level (default: 'confirmed')
|
|
1293
|
+
|
|
1294
|
+
```typescript
|
|
1295
|
+
// Get basic Solana NFT information
|
|
1296
|
+
const nftDetail = await vault.getSolanaNFTDetail(
|
|
1297
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
1298
|
+
);
|
|
1299
|
+
console.log('NFT Name:', nftDetail.name);
|
|
1300
|
+
console.log('Owner:', nftDetail.owner);
|
|
1301
|
+
console.log('Token Type:', nftDetail.tokenType); // 'SPL-NFT'
|
|
1302
|
+
|
|
1303
|
+
// Get extended information with metadata
|
|
1304
|
+
const nftDetailExtended = await vault.getSolanaNFTDetail(
|
|
1305
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
1306
|
+
{
|
|
1307
|
+
includeMetadata: true,
|
|
1308
|
+
includeHistory: true,
|
|
1309
|
+
includeCollection: true
|
|
1310
|
+
}
|
|
1311
|
+
);
|
|
1312
|
+
console.log('Description:', nftDetailExtended.description);
|
|
1313
|
+
console.log('Image URL:', nftDetailExtended.image);
|
|
1314
|
+
console.log('Attributes:', nftDetailExtended.attributes);
|
|
1315
|
+
console.log('Transaction History:', nftDetailExtended.transactionHistory);
|
|
1316
|
+
```
|
|
1487
1317
|
|
|
1488
1318
|
---
|
|
1489
1319
|
|
|
@@ -2006,9 +1836,85 @@ console.log('Transaction hash:', tx.hash);
|
|
|
2006
1836
|
|
|
2007
1837
|
#### Send Token
|
|
2008
1838
|
```typescript
|
|
2009
|
-
// Send ERC-20 tokens
|
|
1839
|
+
// Send ERC-20 tokens on EVM chains
|
|
2010
1840
|
const tx = await vault.sendToken(from, to, amount, tokenAddress, '1');
|
|
2011
1841
|
console.log('Transaction hash:', tx.hash);
|
|
1842
|
+
|
|
1843
|
+
// Send SPL tokens on Solana
|
|
1844
|
+
const solanaTx = await vault.sendSPLToken(
|
|
1845
|
+
from,
|
|
1846
|
+
to,
|
|
1847
|
+
amount,
|
|
1848
|
+
tokenAddress // SPL token mint address
|
|
1849
|
+
);
|
|
1850
|
+
console.log('Solana transaction hash:', solanaTx.hash);
|
|
1851
|
+
```
|
|
1852
|
+
|
|
1853
|
+
#### Send SPL Token (Solana)
|
|
1854
|
+
```typescript
|
|
1855
|
+
// Send USDC on Solana
|
|
1856
|
+
const usdcTx = await vault.sendSPLToken(
|
|
1857
|
+
'0xYourAddress...',
|
|
1858
|
+
'0xRecipient...',
|
|
1859
|
+
'100', // 100 USDC
|
|
1860
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // USDC mint address
|
|
1861
|
+
);
|
|
1862
|
+
|
|
1863
|
+
// Send USDT on Solana
|
|
1864
|
+
const usdtTx = await vault.sendSPLToken(
|
|
1865
|
+
'0xYourAddress...',
|
|
1866
|
+
'0xRecipient...',
|
|
1867
|
+
'50', // 50 USDT
|
|
1868
|
+
'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB' // USDT mint address
|
|
1869
|
+
);
|
|
1870
|
+
|
|
1871
|
+
// Get SPL token balance
|
|
1872
|
+
const usdcBalance = await vault.getSPLTokenBalance(
|
|
1873
|
+
'0xYourAddress...',
|
|
1874
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
1875
|
+
);
|
|
1876
|
+
console.log('USDC Balance:', usdcBalance.toString());
|
|
1877
|
+
|
|
1878
|
+
// Get SPL token information
|
|
1879
|
+
const tokenInfo = await vault.getSPLTokenInfo(
|
|
1880
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
1881
|
+
);
|
|
1882
|
+
console.log('Token:', tokenInfo.name, '(', tokenInfo.symbol, ')');
|
|
1883
|
+
console.log('Decimals:', tokenInfo.decimals);
|
|
1884
|
+
|
|
1885
|
+
// Estimate SPL token transfer fee
|
|
1886
|
+
const transferFee = await vault.estimateSPLTokenTransferFee(
|
|
1887
|
+
'0xYourAddress...',
|
|
1888
|
+
'0xRecipient...',
|
|
1889
|
+
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
1890
|
+
);
|
|
1891
|
+
console.log('Estimated fee:', transferFee.toString(), 'lamports');
|
|
1892
|
+
```
|
|
1893
|
+
|
|
1894
|
+
#### Popular Solana SPL Tokens
|
|
1895
|
+
|
|
1896
|
+
**Mainnet Token Addresses:**
|
|
1897
|
+
```typescript
|
|
1898
|
+
// USDC (USD Coin)
|
|
1899
|
+
const USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
|
|
1900
|
+
|
|
1901
|
+
// USDT (Tether)
|
|
1902
|
+
const USDT_MINT = 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB';
|
|
1903
|
+
|
|
1904
|
+
// BONK (Bonk)
|
|
1905
|
+
const BONK_MINT = 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263';
|
|
1906
|
+
|
|
1907
|
+
// JUP (Jupiter)
|
|
1908
|
+
const JUP_MINT = 'JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN';
|
|
1909
|
+
```
|
|
1910
|
+
|
|
1911
|
+
**Devnet Token Addresses (for testing):**
|
|
1912
|
+
```typescript
|
|
1913
|
+
// USDC Devnet
|
|
1914
|
+
const USDC_DEVNET = '4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU';
|
|
1915
|
+
|
|
1916
|
+
// USDT Devnet
|
|
1917
|
+
const USDT_DEVNET = 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB';
|
|
2012
1918
|
```
|
|
2013
1919
|
|
|
2014
1920
|
#### Export Mnemonic
|
|
@@ -2024,7 +1930,7 @@ console.log('Mnemonic:', mnemonic);
|
|
|
2024
1930
|
```typescript
|
|
2025
1931
|
import { MultiTransferService } from 'pwc-wallet-sdk';
|
|
2026
1932
|
|
|
2027
|
-
const multiTransferService = new MultiTransferService(vault, chainService, '1'); // '1'
|
|
1933
|
+
const multiTransferService = new MultiTransferService(vault, chainService, '1'); // '1' is chainId for Ethereum mainnet
|
|
2028
1934
|
const recipients = [
|
|
2029
1935
|
{ address: '0x1111...', amount: '0.01' },
|
|
2030
1936
|
{ address: '0x2222...', amount: '0.02' },
|
|
@@ -2427,7 +2333,7 @@ const balance = await getTokenBalance('0xToken...', '0x123...', '1');
|
|
|
2427
2333
|
### Example: MultiTransfer
|
|
2428
2334
|
```ts
|
|
2429
2335
|
import { MultiTransferService } from 'pwc-wallet-sdk';
|
|
2430
|
-
const service = new MultiTransferService(vault, chainService, '1'); //
|
|
2336
|
+
const service = new MultiTransferService(vault, chainService, '1'); // pass chainId explicitly
|
|
2431
2337
|
await service.transferNativeTokens('0x123...', [{ address: '0xabc...', amount: '0.1' }], '1');
|
|
2432
2338
|
```
|
|
2433
2339
|
|
package/dist/Vault.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type EncryptedData } from './crypto/EncryptionService';
|
|
2
2
|
import { type ChainId } from './config/chains';
|
|
3
3
|
import { Recipient, MultiTransferResult } from './types/multiTransfer';
|
|
4
|
-
import { NFTDetailExtended, NFTOptions } from './types/nft';
|
|
4
|
+
import { NFTDetailExtended, NFTBalance, NFTOptions } from './types/nft';
|
|
5
5
|
export interface Account {
|
|
6
6
|
address: string;
|
|
7
7
|
type: 'HD' | 'Simple' | 'Solana';
|
|
@@ -150,6 +150,96 @@ export declare class Vault {
|
|
|
150
150
|
* @throws Error if insufficient balance, invalid addresses, or transaction fails
|
|
151
151
|
*/
|
|
152
152
|
sendToken(fromAddress: string, to: string, amount: string, tokenAddress: string, chainId: ChainId): Promise<TransactionResponse>;
|
|
153
|
+
/**
|
|
154
|
+
* Sends SPL tokens on Solana blockchain with enhanced validation and error handling.
|
|
155
|
+
* This method is specifically designed for Solana SPL token transfers.
|
|
156
|
+
* @param fromAddress - The sender's account address
|
|
157
|
+
* @param to - The recipient's address
|
|
158
|
+
* @param amount - The amount of tokens to send as a string
|
|
159
|
+
* @param tokenAddress - The SPL token mint address
|
|
160
|
+
* @param commitment - Optional commitment level for the transaction (default: 'confirmed')
|
|
161
|
+
* @returns Promise resolving to the transaction response with hash and details
|
|
162
|
+
* @throws Error if insufficient balance, invalid addresses, or transaction fails
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* // Send USDC on Solana
|
|
167
|
+
* const tx = await vault.sendSPLToken(
|
|
168
|
+
* '0xYourAddress...',
|
|
169
|
+
* '0xRecipient...',
|
|
170
|
+
* '100', // 100 USDC
|
|
171
|
+
* 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // USDC mint address
|
|
172
|
+
* );
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
sendSPLToken(fromAddress: string, to: string, amount: string, tokenAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<TransactionResponse>;
|
|
176
|
+
/**
|
|
177
|
+
* Gets SPL token balance for a specific address on Solana.
|
|
178
|
+
* @param address - The account address to check balance for
|
|
179
|
+
* @param tokenAddress - The SPL token mint address
|
|
180
|
+
* @param commitment - Optional commitment level (default: 'confirmed')
|
|
181
|
+
* @returns Promise resolving to the token balance as a bigint
|
|
182
|
+
* @throws Error if the balance query fails
|
|
183
|
+
*/
|
|
184
|
+
getSPLTokenBalance(address: string, tokenAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<bigint>;
|
|
185
|
+
/**
|
|
186
|
+
* Gets SPL token information on Solana.
|
|
187
|
+
* @param tokenAddress - The SPL token mint address
|
|
188
|
+
* @param commitment - Optional commitment level (default: 'confirmed')
|
|
189
|
+
* @returns Promise resolving to token metadata
|
|
190
|
+
* @throws Error if the token info query fails
|
|
191
|
+
*/
|
|
192
|
+
getSPLTokenInfo(tokenAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<Token>;
|
|
193
|
+
/**
|
|
194
|
+
* Estimates the transaction fee for SPL token transfers on Solana.
|
|
195
|
+
* @param fromAddress - The sender's account address
|
|
196
|
+
* @param to - The recipient's address
|
|
197
|
+
* @param tokenAddress - The SPL token mint address
|
|
198
|
+
* @param commitment - Optional commitment level (default: 'confirmed')
|
|
199
|
+
* @returns Promise resolving to the estimated fee as a bigint in lamports
|
|
200
|
+
* @throws Error if the fee estimation fails
|
|
201
|
+
*/
|
|
202
|
+
estimateSPLTokenTransferFee(fromAddress: string, to: string, tokenAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<bigint>;
|
|
203
|
+
/**
|
|
204
|
+
* Transfers a Solana NFT from one address to another.
|
|
205
|
+
* This method is specifically designed for Solana NFT transfers.
|
|
206
|
+
* @param fromAddress - The sender's account address
|
|
207
|
+
* @param toAddress - The recipient's address
|
|
208
|
+
* @param mintAddress - The NFT mint address
|
|
209
|
+
* @param commitment - Optional commitment level for the transaction (default: 'confirmed')
|
|
210
|
+
* @returns Promise resolving to the transaction response with hash and details
|
|
211
|
+
* @throws Error if insufficient balance, invalid addresses, or transaction fails
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* // Transfer a Solana NFT
|
|
216
|
+
* const tx = await vault.transferSolanaNFT(
|
|
217
|
+
* '0xYourAddress...',
|
|
218
|
+
* '0xRecipient...',
|
|
219
|
+
* 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' // NFT mint address
|
|
220
|
+
* );
|
|
221
|
+
* console.log('NFT transfer hash:', tx.hash);
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
transferSolanaNFT(fromAddress: string, toAddress: string, mintAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<TransactionResponse>;
|
|
225
|
+
/**
|
|
226
|
+
* Gets Solana NFT balance for a specific address.
|
|
227
|
+
* @param address - Wallet address to check balance for
|
|
228
|
+
* @param mintAddress - The NFT mint address
|
|
229
|
+
* @param commitment - Optional commitment level (default: 'confirmed')
|
|
230
|
+
* @returns Promise resolving to the NFT balance
|
|
231
|
+
* @throws Error if the balance query fails
|
|
232
|
+
*/
|
|
233
|
+
getSolanaNFTBalance(address: string, mintAddress: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<NFTBalance>;
|
|
234
|
+
/**
|
|
235
|
+
* Gets detailed Solana NFT information with metadata.
|
|
236
|
+
* @param mintAddress - The NFT mint address
|
|
237
|
+
* @param options - Query options for additional data
|
|
238
|
+
* @param commitment - Optional commitment level (default: 'confirmed')
|
|
239
|
+
* @returns Promise resolving to extended NFT detail
|
|
240
|
+
* @throws Error if the NFT query fails
|
|
241
|
+
*/
|
|
242
|
+
getSolanaNFTDetail(mintAddress: string, options?: NFTOptions, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<NFTDetailExtended>;
|
|
153
243
|
/**
|
|
154
244
|
* Generates a vanity HD wallet with a specific address prefix.
|
|
155
245
|
* Uses default configuration from VANITY_WALLET_CONFIG for optimal settings.
|