pwc-sdk-wallet 0.6.3

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 (46) hide show
  1. package/README.md +2062 -0
  2. package/dist/Vault.d.ts +493 -0
  3. package/dist/Vault.js +1090 -0
  4. package/dist/chain/ChainService.d.ts +84 -0
  5. package/dist/chain/ChainService.js +136 -0
  6. package/dist/chain/SolanaChainService.d.ts +94 -0
  7. package/dist/chain/SolanaChainService.js +167 -0
  8. package/dist/config/chains.d.ts +233 -0
  9. package/dist/config/chains.js +285 -0
  10. package/dist/config/constants.d.ts +102 -0
  11. package/dist/config/constants.js +109 -0
  12. package/dist/config/environment.d.ts +46 -0
  13. package/dist/config/environment.js +114 -0
  14. package/dist/config/gas.d.ts +107 -0
  15. package/dist/config/gas.js +123 -0
  16. package/dist/crypto/EncryptionService.d.ts +74 -0
  17. package/dist/crypto/EncryptionService.js +178 -0
  18. package/dist/index.d.ts +22 -0
  19. package/dist/index.js +96 -0
  20. package/dist/keyrings/HDKeyring.d.ts +72 -0
  21. package/dist/keyrings/HDKeyring.js +156 -0
  22. package/dist/keyrings/SimpleKeyring.d.ts +31 -0
  23. package/dist/keyrings/SimpleKeyring.js +49 -0
  24. package/dist/keyrings/SolanaKeyring.d.ts +71 -0
  25. package/dist/keyrings/SolanaKeyring.js +159 -0
  26. package/dist/services/BatchProcessor.d.ts +42 -0
  27. package/dist/services/BatchProcessor.js +188 -0
  28. package/dist/services/MultiTransferService.d.ts +78 -0
  29. package/dist/services/MultiTransferService.js +252 -0
  30. package/dist/services/QRCodeService.d.ts +193 -0
  31. package/dist/services/QRCodeService.js +299 -0
  32. package/dist/services/TokenUtils.d.ts +307 -0
  33. package/dist/services/TokenUtils.js +429 -0
  34. package/dist/services/nft/MetadataResolver.d.ts +57 -0
  35. package/dist/services/nft/MetadataResolver.js +162 -0
  36. package/dist/services/nft/NFTAPIService.d.ts +53 -0
  37. package/dist/services/nft/NFTAPIService.js +122 -0
  38. package/dist/services/nft/NFTService.d.ts +241 -0
  39. package/dist/services/nft/NFTService.js +910 -0
  40. package/dist/types/multiTransfer.d.ts +68 -0
  41. package/dist/types/multiTransfer.js +2 -0
  42. package/dist/types/nft/index.d.ts +68 -0
  43. package/dist/types/nft/index.js +2 -0
  44. package/dist/types/nft.d.ts +265 -0
  45. package/dist/types/nft.js +6 -0
  46. package/package.json +70 -0
@@ -0,0 +1,53 @@
1
+ import { NFTDetailExtended, CollectionInfo, NFTOptions } from '../../types/nft';
2
+ import { ChainConfig } from '../../config/chains';
3
+ /**
4
+ * Service for interacting with NFT APIs for individual NFT details
5
+ */
6
+ export declare class NFTAPIService {
7
+ private chainConfig;
8
+ private chainId;
9
+ private apiKey?;
10
+ constructor(chainConfig: ChainConfig, chainId: string, apiKey?: string);
11
+ /**
12
+ * Gets detailed NFT information
13
+ * @param contractAddress - NFT contract address
14
+ * @param tokenId - Token ID
15
+ * @param options - Query options
16
+ * @returns Promise resolving to extended NFT detail
17
+ */
18
+ getNFTDetail(contractAddress: string, tokenId: string, options?: NFTOptions): Promise<NFTDetailExtended>;
19
+ /**
20
+ * Gets collection information
21
+ * @param contractAddress - Collection contract address
22
+ * @returns Promise resolving to collection info
23
+ */
24
+ getCollectionInfo(contractAddress: string): Promise<CollectionInfo>;
25
+ /**
26
+ * Gets detailed EVM NFT information
27
+ * @param contractAddress - NFT contract address
28
+ * @param tokenId - Token ID
29
+ * @param options - Query options
30
+ * @returns Promise resolving to extended NFT detail
31
+ */
32
+ private getEVMNFTDetail;
33
+ /**
34
+ * Gets detailed Solana NFT information
35
+ * @param contractAddress - NFT contract address
36
+ * @param tokenId - Token ID
37
+ * @param options - Query options
38
+ * @returns Promise resolving to extended NFT detail
39
+ */
40
+ private getSolanaNFTDetail;
41
+ /**
42
+ * Gets EVM collection information
43
+ * @param contractAddress - Collection contract address
44
+ * @returns Promise resolving to collection info
45
+ */
46
+ private getEVMCollectionInfo;
47
+ /**
48
+ * Gets Solana collection information
49
+ * @param contractAddress - Collection contract address
50
+ * @returns Promise resolving to collection info
51
+ */
52
+ private getSolanaCollectionInfo;
53
+ }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NFTAPIService = void 0;
4
+ /**
5
+ * Service for interacting with NFT APIs for individual NFT details
6
+ */
7
+ class NFTAPIService {
8
+ constructor(chainConfig, chainId, apiKey) {
9
+ this.chainConfig = chainConfig;
10
+ this.chainId = chainId;
11
+ this.apiKey = apiKey;
12
+ }
13
+ /**
14
+ * Gets detailed NFT information
15
+ * @param contractAddress - NFT contract address
16
+ * @param tokenId - Token ID
17
+ * @param options - Query options
18
+ * @returns Promise resolving to extended NFT detail
19
+ */
20
+ async getNFTDetail(contractAddress, tokenId, options = {}) {
21
+ switch (this.chainConfig.type) {
22
+ case 'evm':
23
+ return this.getEVMNFTDetail(contractAddress, tokenId, options);
24
+ case 'solana':
25
+ return this.getSolanaNFTDetail(contractAddress, tokenId, options);
26
+ default:
27
+ throw new Error(`Unsupported chain type: ${this.chainConfig.type}`);
28
+ }
29
+ }
30
+ /**
31
+ * Gets collection information
32
+ * @param contractAddress - Collection contract address
33
+ * @returns Promise resolving to collection info
34
+ */
35
+ async getCollectionInfo(contractAddress) {
36
+ switch (this.chainConfig.type) {
37
+ case 'evm':
38
+ return this.getEVMCollectionInfo(contractAddress);
39
+ case 'solana':
40
+ return this.getSolanaCollectionInfo(contractAddress);
41
+ default:
42
+ throw new Error(`Unsupported chain type: ${this.chainConfig.type}`);
43
+ }
44
+ }
45
+ /**
46
+ * Gets detailed EVM NFT information
47
+ * @param contractAddress - NFT contract address
48
+ * @param tokenId - Token ID
49
+ * @param options - Query options
50
+ * @returns Promise resolving to extended NFT detail
51
+ */
52
+ async getEVMNFTDetail(contractAddress, tokenId, options) {
53
+ // For now, return basic info. In a real implementation,
54
+ // you'd fetch from OpenSea, Alchemy, or other APIs
55
+ const basicNFT = {
56
+ contractAddress,
57
+ tokenId,
58
+ tokenType: 'ERC-721',
59
+ name: `NFT #${tokenId}`,
60
+ description: '',
61
+ image: '',
62
+ owner: '',
63
+ chainId: this.chainId
64
+ };
65
+ return basicNFT;
66
+ }
67
+ /**
68
+ * Gets detailed Solana NFT information
69
+ * @param contractAddress - NFT contract address
70
+ * @param tokenId - Token ID
71
+ * @param options - Query options
72
+ * @returns Promise resolving to extended NFT detail
73
+ */
74
+ async getSolanaNFTDetail(contractAddress, tokenId, options) {
75
+ // For now, return basic info. In a real implementation,
76
+ // you'd fetch from Helius, Solscan, or other APIs
77
+ const basicNFT = {
78
+ contractAddress,
79
+ tokenId,
80
+ tokenType: 'SPL-NFT',
81
+ name: `NFT #${tokenId}`,
82
+ description: '',
83
+ image: '',
84
+ owner: '',
85
+ chainId: this.chainId
86
+ };
87
+ return basicNFT;
88
+ }
89
+ /**
90
+ * Gets EVM collection information
91
+ * @param contractAddress - Collection contract address
92
+ * @returns Promise resolving to collection info
93
+ */
94
+ async getEVMCollectionInfo(contractAddress) {
95
+ // For now, return basic info. In a real implementation,
96
+ // you'd fetch from OpenSea, Alchemy, or other APIs
97
+ return {
98
+ name: 'Unknown Collection',
99
+ description: '',
100
+ image: '',
101
+ verified: false,
102
+ total_supply: 0
103
+ };
104
+ }
105
+ /**
106
+ * Gets Solana collection information
107
+ * @param contractAddress - Collection contract address
108
+ * @returns Promise resolving to collection info
109
+ */
110
+ async getSolanaCollectionInfo(contractAddress) {
111
+ // For now, return basic info. In a real implementation,
112
+ // you'd fetch from Helius, Solscan, or other APIs
113
+ return {
114
+ name: 'Unknown Collection',
115
+ description: '',
116
+ image: '',
117
+ verified: false,
118
+ total_supply: 0
119
+ };
120
+ }
121
+ }
122
+ exports.NFTAPIService = NFTAPIService;
@@ -0,0 +1,241 @@
1
+ import { ChainId } from '../../config/chains';
2
+ import { NFTDetailExtended, NFTOptions, NFTBalance } from '../../types/nft';
3
+ import { Vault } from '../../Vault';
4
+ /**
5
+ * Pure blockchain NFT service
6
+ * Reads all data directly from smart contracts without third-party APIs
7
+ */
8
+ export declare class NFTService {
9
+ private chainService?;
10
+ private vault?;
11
+ private chainId;
12
+ /**
13
+ * Creates a new NFTService instance.
14
+ * @param chainId - The chain ID to operate on
15
+ * @param vault - Optional vault instance for write operations
16
+ * @param fromAddress - Optional sender address for write operations
17
+ */
18
+ constructor(chainId: ChainId, vault?: Vault, fromAddress?: string);
19
+ /**
20
+ * Initialize chain service for write operations
21
+ * @param vault - The vault instance
22
+ * @param fromAddress - The sender's address
23
+ */
24
+ private initializeChainService;
25
+ /**
26
+ * Initialize chain service for write operations after construction
27
+ * @param vault - The vault instance
28
+ * @param fromAddress - The sender's address
29
+ */
30
+ initializeForWrite(vault: Vault, fromAddress: string): Promise<void>;
31
+ /**
32
+ * Gets comprehensive NFT detail by reading directly from blockchain.
33
+ * @param contractAddress - NFT contract address
34
+ * @param tokenId - Token ID (string)
35
+ * @param options - Optional parameters for additional data
36
+ * @param options.includeMetadata - Whether to fetch and include metadata (default: false)
37
+ * @param options.includeHistory - Whether to fetch transaction history (default: false)
38
+ * @param options.includeCollection - Whether to fetch collection information (default: false)
39
+ * @returns Promise resolving to extended NFT detail
40
+ * @example
41
+ * ```typescript
42
+ * const nftDetail = await nftService.getNFTDetail(
43
+ * '0xContract...',
44
+ * '123',
45
+ * { includeMetadata: true, includeHistory: true }
46
+ * );
47
+ * console.log('NFT:', nftDetail.name, 'Owner:', nftDetail.owner);
48
+ * ```
49
+ */
50
+ getNFTDetail(contractAddress: string, tokenId: string, options?: NFTOptions): Promise<NFTDetailExtended>;
51
+ /**
52
+ * Gets on-chain NFT data directly from smart contract
53
+ * @param contractAddress - NFT contract address
54
+ * @param tokenId - Token ID
55
+ * @returns Promise resolving to on-chain data
56
+ */
57
+ private getOnChainData;
58
+ /**
59
+ * Gets EVM NFT on-chain data
60
+ * @param contractAddress - NFT contract address
61
+ * @param tokenId - Token ID
62
+ * @returns Promise resolving to on-chain data
63
+ */
64
+ private getEVMOnChainData;
65
+ /**
66
+ * Gets Solana NFT on-chain data
67
+ * @param contractAddress - NFT mint address
68
+ * @param tokenId - Token ID (not used for Solana)
69
+ * @returns Promise resolving to on-chain data
70
+ */
71
+ private getSolanaOnChainData;
72
+ /**
73
+ * Resolves metadata from tokenURI (IPFS or HTTP)
74
+ * @param tokenURI - Token URI
75
+ * @returns Promise resolving to metadata
76
+ */
77
+ private resolveMetadata;
78
+ /**
79
+ * Gets transaction history from blockchain events
80
+ * @param contractAddress - NFT contract address
81
+ * @param tokenId - Token ID
82
+ * @returns Promise resolving to transaction history
83
+ */
84
+ private getTransactionHistory;
85
+ /**
86
+ * Gets collection information from contract
87
+ * @param contractAddress - NFT contract address
88
+ * @returns Promise resolving to collection info
89
+ */
90
+ private getCollectionInfo;
91
+ /**
92
+ * Gets NFT balance for an address from a specific contract.
93
+ * Supports both ERC-721 and ERC-1155 contracts.
94
+ * @param address - Wallet address to check balance for
95
+ * @param contractAddress - NFT contract address
96
+ * @param tokenId - (Optional) Token ID for ERC-1155 contracts
97
+ * @returns Promise resolving to NFT balance information
98
+ * @example
99
+ * ```typescript
100
+ * // For ERC-721
101
+ * const balance = await nftService.getNFTBalance('0xAccount...', '0xContract...');
102
+ * console.log('ERC-721 Count:', balance.count);
103
+ *
104
+ * // For ERC-1155
105
+ * const balance = await nftService.getNFTBalance('0xAccount...', '0xContract...', '123');
106
+ * console.log('ERC-1155 Balance:', balance.count);
107
+ * ```
108
+ */
109
+ getNFTBalance(address: string, contractAddress: string, tokenId?: string): Promise<NFTBalance>;
110
+ /**
111
+ * Gets ERC-1155 token balance for a specific address and token ID.
112
+ * @param address - Wallet address to check balance for
113
+ * @param contractAddress - ERC-1155 contract address
114
+ * @param tokenId - Token ID to check balance for
115
+ * @returns Promise resolving to the balance amount as bigint
116
+ * @example
117
+ * ```typescript
118
+ * const balance = await nftService.getERC1155Balance('0xAccount...', '0xContract...', '123');
119
+ * console.log('ERC-1155 Balance:', balance.toString());
120
+ * ```
121
+ */
122
+ getERC1155Balance(address: string, contractAddress: string, tokenId: string): Promise<bigint>;
123
+ /**
124
+ * Gets all ERC-1155 token balances for an address from a specific contract.
125
+ * @param address - Wallet address to check balances for
126
+ * @param contractAddress - ERC-1155 contract address
127
+ * @param tokenIds - Array of token IDs to check
128
+ * @returns Promise resolving to array of balance objects
129
+ * @example
130
+ * ```typescript
131
+ * const balances = await nftService.getERC1155Balances('0xAccount...', '0xContract...', ['123', '456', '789']);
132
+ * balances.forEach(balance => {
133
+ * console.log(`Token ${balance.tokenId}: ${balance.amount.toString()}`);
134
+ * });
135
+ * ```
136
+ */
137
+ getERC1155Balances(address: string, contractAddress: string, tokenIds: string[]): Promise<Array<{
138
+ tokenId: string;
139
+ amount: bigint;
140
+ }>>;
141
+ /**
142
+ * Gets mint timestamp from blockchain
143
+ * @param contractAddress - NFT contract address
144
+ * @param tokenId - Token ID
145
+ * @returns Promise resolving to mint timestamp
146
+ */
147
+ private getMintTimestamp;
148
+ /**
149
+ * Gets last transfer timestamp from blockchain
150
+ * @param contractAddress - NFT contract address
151
+ * @param tokenId - Token ID
152
+ * @returns Promise resolving to last transfer timestamp
153
+ */
154
+ private getLastTransferTimestamp;
155
+ /**
156
+ * Estimates gas cost for transferring an NFT
157
+ * @param fromAddress - The sender's address
158
+ * @param toAddress - The recipient's address
159
+ * @param contractAddress - The NFT contract address
160
+ * @param tokenId - The token ID to transfer
161
+ * @param amount - (Optional) Amount to transfer (for ERC-1155, default 1 for ERC-721)
162
+ * @returns Promise resolving to the estimated gas cost as bigint
163
+ * @example
164
+ * ```typescript
165
+ * const gasEstimate = await nftService.estimateGasForTransfer(
166
+ * '0xSender...',
167
+ * '0xRecipient...',
168
+ * '0xContract...',
169
+ * '123'
170
+ * );
171
+ * console.log('Estimated gas:', gasEstimate.toString());
172
+ * ```
173
+ */
174
+ estimateGasForTransfer(fromAddress: string, toAddress: string, contractAddress: string, tokenId: string, amount?: string): Promise<bigint>;
175
+ /**
176
+ * Estimates gas cost for various NFT operations
177
+ * @param operation - The operation to estimate gas for
178
+ * @param contractAddress - The NFT contract address
179
+ * @param params - Operation-specific parameters
180
+ * @returns Promise resolving to the estimated gas cost as bigint
181
+ * @example
182
+ * ```typescript
183
+ * // Estimate gas for transfer
184
+ * const transferGas = await nftService.estimateGas('transfer', contractAddress, {
185
+ * fromAddress: '0xSender...',
186
+ * toAddress: '0xRecipient...',
187
+ * tokenId: '123'
188
+ * });
189
+ *
190
+ * // Estimate gas for approve
191
+ * const approveGas = await nftService.estimateGas('approve', contractAddress, {
192
+ * toAddress: '0xSpender...',
193
+ * tokenId: '123'
194
+ * });
195
+ * ```
196
+ */
197
+ estimateGas(operation: 'transfer' | 'approve' | 'setApprovalForAll', contractAddress: string, params: {
198
+ fromAddress?: string;
199
+ toAddress: string;
200
+ tokenId?: string;
201
+ amount?: string;
202
+ approved?: boolean;
203
+ }): Promise<bigint>;
204
+ /**
205
+ * Transfers an NFT using Vault (RECOMMENDED). Supports both ERC-721 and ERC-1155.
206
+ * @param fromAddress - The sender's address
207
+ * @param toAddress - The recipient's address
208
+ * @param contractAddress - The NFT contract address
209
+ * @param tokenId - The token ID to transfer
210
+ * @param amount - (Optional) Amount to transfer (for ERC-1155, default 1 for ERC-721)
211
+ * @returns Promise resolving to the transaction response
212
+ */
213
+ transferNFTWithVault(fromAddress: string, toAddress: string, contractAddress: string, tokenId: string, amount?: string): Promise<any>;
214
+ /**
215
+ * @deprecated Use transferNFTWithVault instead for better security
216
+ * Transfers an NFT from one address to another. Supports both ERC-721 and ERC-1155.
217
+ * @param fromAddress - The sender's address
218
+ * @param toAddress - The recipient's address
219
+ * @param contractAddress - The NFT contract address
220
+ * @param tokenId - The token ID to transfer
221
+ * @param amount - (Optional) Amount to transfer (for ERC-1155, default 1 for ERC-721)
222
+ * @returns Promise resolving to the transaction response
223
+ */
224
+ transferNFT(fromAddress: string, toAddress: string, contractAddress: string, tokenId: string, amount?: string): Promise<any>;
225
+ /**
226
+ * Checks if an address is owner or approved for ERC-1155 token
227
+ * @param address - Address to check
228
+ * @param contractAddress - ERC-1155 contract address
229
+ * @param tokenId - Token ID
230
+ * @returns Promise resolving to boolean indicating if address can transfer
231
+ */
232
+ canTransferERC1155(address: string, contractAddress: string, tokenId: string): Promise<boolean>;
233
+ /**
234
+ * Creates a contract instance with wallet for gas estimation
235
+ * @param contractAddress - Contract address
236
+ * @param abi - Contract ABI
237
+ * @param fromAddress - Address to use for signing
238
+ * @returns Promise resolving to contract instance with wallet
239
+ */
240
+ private createContractWithWallet;
241
+ }