@tari-project/tarijs 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -67
- package/TODO.md +91 -3
- package/docusaurus/tari-docs/README.md +200 -17
- package/docusaurus/tari-docs/docs/api-reference.md +665 -0
- package/docusaurus/tari-docs/docs/contributing.md +619 -0
- package/docusaurus/tari-docs/docs/guides/getting-started-tutorial.md +965 -0
- package/docusaurus/tari-docs/docs/guides/production-deployment.md +977 -0
- package/docusaurus/tari-docs/docs/index.md +114 -11
- package/docusaurus/tari-docs/docs/installation.md +142 -1
- package/docusaurus/tari-docs/docs/signers/metamask.md +529 -0
- package/docusaurus/tari-docs/docs/troubleshooting.md +661 -0
- package/docusaurus/tari-docs/package.json +1 -1
- package/examples/vite-typescript-react/README.md +9 -0
- package/examples/vite-typescript-react/eslint.config.js +23 -0
- package/examples/vite-typescript-react/index.html +13 -0
- package/examples/vite-typescript-react/package.json +35 -0
- package/examples/vite-typescript-react/public/vite.svg +1 -0
- package/examples/vite-typescript-react/src/App.css +42 -0
- package/examples/vite-typescript-react/src/App.tsx +50 -0
- package/examples/vite-typescript-react/src/assets/react.svg +1 -0
- package/examples/vite-typescript-react/src/index.css +68 -0
- package/examples/vite-typescript-react/src/main.tsx +10 -0
- package/examples/vite-typescript-react/src/vite-env.d.ts +1 -0
- package/examples/vite-typescript-react/tsconfig.app.json +27 -0
- package/examples/vite-typescript-react/tsconfig.json +7 -0
- package/examples/vite-typescript-react/tsconfig.node.json +25 -0
- package/examples/vite-typescript-react/vite.config.ts +7 -0
- package/package.json +2 -2
- package/packages/builders/package.json +2 -2
- package/packages/builders/src/transaction/TransactionBuilder.ts +4 -12
- package/packages/indexer_provider/package.json +2 -2
- package/packages/indexer_provider/src/provider.ts +5 -5
- package/packages/indexer_provider/tsconfig.json +4 -2
- package/packages/metamask_signer/package.json +2 -2
- package/packages/metamask_signer/src/index.ts +2 -14
- package/packages/{tari_permissions → permissions}/package.json +2 -2
- package/packages/{tari_permissions → permissions}/src/helpers.ts +1 -1
- package/packages/permissions/src/index.ts +2 -0
- package/packages/{tari_permissions/src/tari_permissions.ts → permissions/src/permissions.ts} +56 -6
- package/packages/react-mui-connect-button/moon.yml +71 -0
- package/packages/react-mui-connect-button/package.json +40 -0
- package/packages/react-mui-connect-button/src/Logos.tsx +60 -0
- package/packages/react-mui-connect-button/src/TariConnectButton.tsx +51 -0
- package/packages/react-mui-connect-button/src/TariWalletSelectionDialog.tsx +116 -0
- package/packages/react-mui-connect-button/src/content/tari-logo-white.svg +18 -0
- package/packages/react-mui-connect-button/src/content/tari-logo.svg +18 -0
- package/packages/react-mui-connect-button/src/content/walletconnect-logo.svg +13 -0
- package/packages/react-mui-connect-button/src/defaultPermissions.ts +0 -0
- package/packages/react-mui-connect-button/src/index.ts +24 -0
- package/packages/react-mui-connect-button/tsconfig.json +31 -0
- package/packages/tari_provider/package.json +2 -2
- package/packages/tari_signer/package.json +2 -2
- package/packages/tari_universe/package.json +2 -2
- package/packages/tari_universe/tsconfig.json +4 -2
- package/packages/tarijs/package.json +2 -2
- package/packages/tarijs/tsconfig.json +4 -2
- package/packages/tarijs_types/package.json +2 -2
- package/packages/wallet_daemon/package.json +2 -2
- package/packages/wallet_daemon/src/provider.ts +9 -12
- package/packages/wallet_daemon/src/signer.ts +11 -6
- package/packages/wallet_daemon/tsconfig.json +1 -1
- package/packages/walletconnect/package.json +3 -2
- package/packages/walletconnect/src/index.ts +52 -26
- package/packages/walletconnect/tsconfig.json +3 -0
- package/pnpm-workspace.yaml +15 -7
- package/scripts/check_versions.sh +4 -0
- package/scripts/clean_everything.sh +38 -0
- package/tsconfig.json +6 -0
- package/packages/tari_permissions/src/index.ts +0 -2
- /package/packages/{tari_permissions → permissions}/moon.yml +0 -0
- /package/packages/{tari_permissions → permissions}/tsconfig.json +0 -0
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 10
|
|
3
|
+
title: Troubleshooting
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Troubleshooting Guide
|
|
7
|
+
|
|
8
|
+
This comprehensive guide covers common issues when working with tari.js and their solutions.
|
|
9
|
+
|
|
10
|
+
## Installation Issues
|
|
11
|
+
|
|
12
|
+
### Package Installation Problems
|
|
13
|
+
|
|
14
|
+
#### ❌ Module '@tari-project/tarijs' not found
|
|
15
|
+
|
|
16
|
+
**Symptoms:**
|
|
17
|
+
```
|
|
18
|
+
Error: Cannot resolve module '@tari-project/tarijs'
|
|
19
|
+
Module not found: Error: Can't resolve '@tari-project/tarijs'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Solutions:**
|
|
23
|
+
```bash
|
|
24
|
+
# 1. Clear package manager cache
|
|
25
|
+
npm cache clean --force
|
|
26
|
+
# or for pnpm
|
|
27
|
+
pnpm store prune
|
|
28
|
+
|
|
29
|
+
# 2. Delete node_modules and reinstall
|
|
30
|
+
rm -rf node_modules package-lock.json
|
|
31
|
+
npm install
|
|
32
|
+
|
|
33
|
+
# 3. Verify package exists in npm registry
|
|
34
|
+
npm view @tari-project/tarijs
|
|
35
|
+
|
|
36
|
+
# 4. Try installing specific version
|
|
37
|
+
npm install @tari-project/tarijs@latest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### ❌ Peer dependency warnings
|
|
41
|
+
|
|
42
|
+
**Symptoms:**
|
|
43
|
+
```
|
|
44
|
+
npm WARN ERESOLVE overriding peer dependency
|
|
45
|
+
npm WARN ERESOLVE Conflicting peerDependencies
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Solutions:**
|
|
49
|
+
```bash
|
|
50
|
+
# Install with legacy peer deps flag
|
|
51
|
+
npm install --legacy-peer-deps
|
|
52
|
+
|
|
53
|
+
# Or force the installation
|
|
54
|
+
npm install --force
|
|
55
|
+
|
|
56
|
+
# For pnpm users
|
|
57
|
+
pnpm install --shamefully-hoist
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### ❌ TypeScript type errors during installation
|
|
61
|
+
|
|
62
|
+
**Symptoms:**
|
|
63
|
+
```
|
|
64
|
+
Cannot find type definition file for '@tari-project/tarijs'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Solutions:**
|
|
68
|
+
```bash
|
|
69
|
+
# Install TypeScript and Node types
|
|
70
|
+
npm install --save-dev typescript @types/node
|
|
71
|
+
|
|
72
|
+
# Update tsconfig.json
|
|
73
|
+
{
|
|
74
|
+
"compilerOptions": {
|
|
75
|
+
"moduleResolution": "node",
|
|
76
|
+
"allowSyntheticDefaultImports": true,
|
|
77
|
+
"esModuleInterop": true,
|
|
78
|
+
"skipLibCheck": true
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Build and Development Issues
|
|
84
|
+
|
|
85
|
+
### Bundler Configuration Problems
|
|
86
|
+
|
|
87
|
+
#### ❌ Vite build errors
|
|
88
|
+
|
|
89
|
+
**Symptoms:**
|
|
90
|
+
```
|
|
91
|
+
[ERROR] Could not resolve "@tari-project/tarijs"
|
|
92
|
+
Buffer is not defined
|
|
93
|
+
global is not defined
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Solutions:**
|
|
97
|
+
|
|
98
|
+
Add to `vite.config.ts`:
|
|
99
|
+
```typescript
|
|
100
|
+
import { defineConfig } from 'vite'
|
|
101
|
+
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
|
|
102
|
+
|
|
103
|
+
export default defineConfig({
|
|
104
|
+
define: {
|
|
105
|
+
global: 'globalThis',
|
|
106
|
+
},
|
|
107
|
+
optimizeDeps: {
|
|
108
|
+
include: ['@tari-project/tarijs'],
|
|
109
|
+
},
|
|
110
|
+
plugins: [
|
|
111
|
+
NodeGlobalsPolyfillPlugin({
|
|
112
|
+
buffer: true
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Install required polyfills:
|
|
119
|
+
```bash
|
|
120
|
+
npm install --save-dev @esbuild-plugins/node-globals-polyfill buffer
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### ❌ Webpack build errors
|
|
124
|
+
|
|
125
|
+
**Symptoms:**
|
|
126
|
+
```
|
|
127
|
+
Module not found: Error: Can't resolve 'crypto'
|
|
128
|
+
Module not found: Error: Can't resolve 'buffer'
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Solutions:**
|
|
132
|
+
|
|
133
|
+
Add to `webpack.config.js`:
|
|
134
|
+
```javascript
|
|
135
|
+
const webpack = require('webpack');
|
|
136
|
+
|
|
137
|
+
module.exports = {
|
|
138
|
+
resolve: {
|
|
139
|
+
fallback: {
|
|
140
|
+
"buffer": require.resolve("buffer"),
|
|
141
|
+
"crypto": require.resolve("crypto-browserify"),
|
|
142
|
+
"stream": require.resolve("stream-browserify"),
|
|
143
|
+
"util": require.resolve("util/")
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
plugins: [
|
|
147
|
+
new webpack.ProvidePlugin({
|
|
148
|
+
Buffer: ['buffer', 'Buffer'],
|
|
149
|
+
process: 'process/browser',
|
|
150
|
+
}),
|
|
151
|
+
],
|
|
152
|
+
};
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Install polyfills:
|
|
156
|
+
```bash
|
|
157
|
+
npm install --save-dev buffer crypto-browserify stream-browserify util
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### ❌ Next.js configuration issues
|
|
161
|
+
|
|
162
|
+
**Symptoms:**
|
|
163
|
+
```
|
|
164
|
+
Module parse failed: Unexpected token
|
|
165
|
+
ReferenceError: Buffer is not defined
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Solutions:**
|
|
169
|
+
|
|
170
|
+
Add to `next.config.js`:
|
|
171
|
+
```javascript
|
|
172
|
+
/** @type {import('next').NextConfig} */
|
|
173
|
+
const nextConfig = {
|
|
174
|
+
experimental: {
|
|
175
|
+
esmExternals: false
|
|
176
|
+
},
|
|
177
|
+
webpack: (config) => {
|
|
178
|
+
config.resolve.fallback = {
|
|
179
|
+
...config.resolve.fallback,
|
|
180
|
+
crypto: require.resolve('crypto-browserify'),
|
|
181
|
+
buffer: require.resolve('buffer'),
|
|
182
|
+
};
|
|
183
|
+
config.plugins.push(
|
|
184
|
+
new webpack.ProvidePlugin({
|
|
185
|
+
Buffer: ['buffer', 'Buffer'],
|
|
186
|
+
})
|
|
187
|
+
);
|
|
188
|
+
return config;
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
module.exports = nextConfig;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Wallet Connection Issues
|
|
196
|
+
|
|
197
|
+
### MetaMask Integration Problems
|
|
198
|
+
|
|
199
|
+
#### ❌ MetaMask not detected
|
|
200
|
+
|
|
201
|
+
**Symptoms:**
|
|
202
|
+
```
|
|
203
|
+
MetaMask provider not found
|
|
204
|
+
No Ethereum provider detected
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Solutions:**
|
|
208
|
+
```typescript
|
|
209
|
+
// Check if MetaMask is installed
|
|
210
|
+
if (typeof window.ethereum === 'undefined') {
|
|
211
|
+
console.error('MetaMask not installed');
|
|
212
|
+
// Guide user to install MetaMask Flask
|
|
213
|
+
window.open('https://metamask.io/flask/', '_blank');
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Wait for MetaMask initialization
|
|
218
|
+
await new Promise(resolve => {
|
|
219
|
+
if (window.ethereum) resolve();
|
|
220
|
+
else window.addEventListener('ethereum#initialized', resolve);
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### ❌ Tari Snap installation failures
|
|
225
|
+
|
|
226
|
+
**Symptoms:**
|
|
227
|
+
```
|
|
228
|
+
Snap installation failed
|
|
229
|
+
Snap not found in MetaMask
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Solutions:**
|
|
233
|
+
```typescript
|
|
234
|
+
// Install the Tari snap
|
|
235
|
+
try {
|
|
236
|
+
await window.ethereum.request({
|
|
237
|
+
method: 'wallet_requestSnaps',
|
|
238
|
+
params: {
|
|
239
|
+
'npm:@tari-project/wallet-snap': {}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
} catch (error) {
|
|
243
|
+
console.error('Snap installation failed:', error);
|
|
244
|
+
// Ensure MetaMask Flask is being used
|
|
245
|
+
// Check snap permissions in MetaMask settings
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### ❌ MetaMask connection rejected
|
|
250
|
+
|
|
251
|
+
**Symptoms:**
|
|
252
|
+
```
|
|
253
|
+
User rejected the request
|
|
254
|
+
Connection request denied
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Solutions:**
|
|
258
|
+
```typescript
|
|
259
|
+
// Implement proper error handling
|
|
260
|
+
try {
|
|
261
|
+
const accounts = await window.ethereum.request({
|
|
262
|
+
method: 'eth_requestAccounts'
|
|
263
|
+
});
|
|
264
|
+
} catch (error) {
|
|
265
|
+
if (error.code === 4001) {
|
|
266
|
+
console.log('User rejected connection');
|
|
267
|
+
// Show user-friendly message
|
|
268
|
+
} else {
|
|
269
|
+
console.error('Unexpected error:', error);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Wallet Daemon Connection Problems
|
|
275
|
+
|
|
276
|
+
#### ❌ Connection refused to wallet daemon
|
|
277
|
+
|
|
278
|
+
**Symptoms:**
|
|
279
|
+
```
|
|
280
|
+
ECONNREFUSED 127.0.0.1:18103
|
|
281
|
+
fetch failed: Connection refused
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Solutions:**
|
|
285
|
+
```bash
|
|
286
|
+
# 1. Check if wallet daemon is running
|
|
287
|
+
ps aux | grep minotari_wallet_daemon
|
|
288
|
+
|
|
289
|
+
# 2. Start wallet daemon with JSON-RPC enabled
|
|
290
|
+
./target/release/minotari_wallet_daemon --config-path ./config.toml
|
|
291
|
+
|
|
292
|
+
# 3. Verify JSON-RPC endpoint in config.toml
|
|
293
|
+
[wallet]
|
|
294
|
+
json_rpc_address = "127.0.0.1:18103"
|
|
295
|
+
|
|
296
|
+
# 4. Check firewall settings
|
|
297
|
+
sudo ufw status
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
#### ❌ Authentication errors
|
|
301
|
+
|
|
302
|
+
**Symptoms:**
|
|
303
|
+
```
|
|
304
|
+
401 Unauthorized
|
|
305
|
+
Invalid credentials
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Solutions:**
|
|
309
|
+
```typescript
|
|
310
|
+
// Check authentication configuration
|
|
311
|
+
const signer = new WalletDaemonSigner({
|
|
312
|
+
endpoint: 'http://localhost:18103',
|
|
313
|
+
// Add authentication if required
|
|
314
|
+
auth: {
|
|
315
|
+
username: 'your-username',
|
|
316
|
+
password: 'your-password'
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
#### ❌ CORS errors with wallet daemon
|
|
322
|
+
|
|
323
|
+
**Symptoms:**
|
|
324
|
+
```
|
|
325
|
+
Access to fetch blocked by CORS policy
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
**Solutions:**
|
|
329
|
+
|
|
330
|
+
Add CORS headers to wallet daemon config:
|
|
331
|
+
```toml
|
|
332
|
+
[wallet.json_rpc]
|
|
333
|
+
cors_allowed_origins = ["http://localhost:3000", "http://localhost:5173"]
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Or use a proxy in development:
|
|
337
|
+
```typescript
|
|
338
|
+
// In vite.config.ts
|
|
339
|
+
export default defineConfig({
|
|
340
|
+
server: {
|
|
341
|
+
proxy: {
|
|
342
|
+
'/api': {
|
|
343
|
+
target: 'http://localhost:18103',
|
|
344
|
+
changeOrigin: true,
|
|
345
|
+
rewrite: (path) => path.replace(/^\/api/, '')
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Tari Universe Wallet Issues
|
|
353
|
+
|
|
354
|
+
#### ❌ Tari Universe not responding
|
|
355
|
+
|
|
356
|
+
**Symptoms:**
|
|
357
|
+
```
|
|
358
|
+
Wallet connection timeout
|
|
359
|
+
No response from Tari Universe
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Solutions:**
|
|
363
|
+
```typescript
|
|
364
|
+
// Add timeout and retry logic
|
|
365
|
+
const signer = new TariUniverseSigner({
|
|
366
|
+
timeout: 30000, // 30 second timeout
|
|
367
|
+
retryAttempts: 3,
|
|
368
|
+
retryDelay: 1000
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// Check wallet status
|
|
372
|
+
try {
|
|
373
|
+
const status = await signer.getWalletStatus();
|
|
374
|
+
console.log('Wallet status:', status);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
console.error('Wallet not responding:', error);
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### WalletConnect Integration Issues
|
|
381
|
+
|
|
382
|
+
#### ❌ WalletConnect pairing fails
|
|
383
|
+
|
|
384
|
+
**Symptoms:**
|
|
385
|
+
```
|
|
386
|
+
QR code not scanning
|
|
387
|
+
Pairing request timeout
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
**Solutions:**
|
|
391
|
+
```typescript
|
|
392
|
+
// Ensure proper WalletConnect configuration
|
|
393
|
+
import { WalletConnectSigner } from '@tari-project/walletconnect';
|
|
394
|
+
|
|
395
|
+
const signer = new WalletConnectSigner({
|
|
396
|
+
projectId: 'your-walletconnect-project-id', // Get from WalletConnect Cloud
|
|
397
|
+
metadata: {
|
|
398
|
+
name: 'Your App Name',
|
|
399
|
+
description: 'Your App Description',
|
|
400
|
+
url: 'https://your-app.com',
|
|
401
|
+
icons: ['https://your-app.com/icon.png']
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// Handle connection errors
|
|
406
|
+
signer.on('connect_error', (error) => {
|
|
407
|
+
console.error('WalletConnect error:', error);
|
|
408
|
+
});
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
## Transaction Issues
|
|
412
|
+
|
|
413
|
+
### Transaction Building Problems
|
|
414
|
+
|
|
415
|
+
#### ❌ Invalid transaction structure
|
|
416
|
+
|
|
417
|
+
**Symptoms:**
|
|
418
|
+
```
|
|
419
|
+
Transaction validation failed
|
|
420
|
+
Invalid instruction format
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
**Solutions:**
|
|
424
|
+
```typescript
|
|
425
|
+
// Ensure proper transaction structure
|
|
426
|
+
const transaction = new TransactionBuilder()
|
|
427
|
+
.fee(100) // Always set fee first
|
|
428
|
+
.inputs([...requiredInputs]) // Add all required inputs
|
|
429
|
+
.callMethod('account', 'transfer', {
|
|
430
|
+
amount: 1000,
|
|
431
|
+
destination: destinationAddress
|
|
432
|
+
})
|
|
433
|
+
.build();
|
|
434
|
+
|
|
435
|
+
// Validate before submission
|
|
436
|
+
if (!transaction.isValid()) {
|
|
437
|
+
console.error('Transaction validation failed');
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
#### ❌ Insufficient funds errors
|
|
443
|
+
|
|
444
|
+
**Symptoms:**
|
|
445
|
+
```
|
|
446
|
+
Insufficient balance
|
|
447
|
+
Not enough funds for transaction
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
**Solutions:**
|
|
451
|
+
```typescript
|
|
452
|
+
// Check balance before transaction
|
|
453
|
+
const account = await signer.getDefaultAccount();
|
|
454
|
+
const balance = await signer.getBalance(account);
|
|
455
|
+
|
|
456
|
+
if (balance < transactionAmount + fee) {
|
|
457
|
+
throw new Error(`Insufficient funds. Required: ${transactionAmount + fee}, Available: ${balance}`);
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
#### ❌ Fee calculation errors
|
|
462
|
+
|
|
463
|
+
**Symptoms:**
|
|
464
|
+
```
|
|
465
|
+
Fee too low
|
|
466
|
+
Transaction rejected due to insufficient fee
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
**Solutions:**
|
|
470
|
+
```typescript
|
|
471
|
+
// Use fee estimation
|
|
472
|
+
const estimatedFee = await provider.estimateFee(transaction);
|
|
473
|
+
const transaction = new TransactionBuilder()
|
|
474
|
+
.fee(estimatedFee * 1.1) // Add 10% buffer
|
|
475
|
+
.callMethod(...)
|
|
476
|
+
.build();
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### Transaction Submission Problems
|
|
480
|
+
|
|
481
|
+
#### ❌ Transaction timeout
|
|
482
|
+
|
|
483
|
+
**Symptoms:**
|
|
484
|
+
```
|
|
485
|
+
Transaction submission timeout
|
|
486
|
+
No response from network
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**Solutions:**
|
|
490
|
+
```typescript
|
|
491
|
+
// Add proper timeout handling
|
|
492
|
+
try {
|
|
493
|
+
const result = await Promise.race([
|
|
494
|
+
signer.submitTransaction(transaction),
|
|
495
|
+
new Promise((_, reject) =>
|
|
496
|
+
setTimeout(() => reject(new Error('Timeout')), 30000)
|
|
497
|
+
)
|
|
498
|
+
]);
|
|
499
|
+
} catch (error) {
|
|
500
|
+
if (error.message === 'Timeout') {
|
|
501
|
+
console.error('Transaction submission timed out');
|
|
502
|
+
// Implement retry logic
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
#### ❌ Transaction rejected by network
|
|
508
|
+
|
|
509
|
+
**Symptoms:**
|
|
510
|
+
```
|
|
511
|
+
Transaction validation failed
|
|
512
|
+
Invalid transaction format
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**Solutions:**
|
|
516
|
+
```typescript
|
|
517
|
+
// Validate transaction before submission
|
|
518
|
+
const validationResult = await provider.validateTransaction(transaction);
|
|
519
|
+
if (!validationResult.isValid) {
|
|
520
|
+
console.error('Transaction validation errors:', validationResult.errors);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// Check network status
|
|
525
|
+
const networkInfo = await provider.getNetworkInfo();
|
|
526
|
+
if (!networkInfo.isHealthy) {
|
|
527
|
+
console.warn('Network may be experiencing issues');
|
|
528
|
+
}
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
## Performance Issues
|
|
532
|
+
|
|
533
|
+
### Slow Query Performance
|
|
534
|
+
|
|
535
|
+
#### ❌ Slow substate queries
|
|
536
|
+
|
|
537
|
+
**Symptoms:**
|
|
538
|
+
```
|
|
539
|
+
Long response times for getSubstate calls
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
**Solutions:**
|
|
543
|
+
```typescript
|
|
544
|
+
// Use batch queries for multiple substates
|
|
545
|
+
const substates = await provider.getSubstatesBatch([id1, id2, id3]);
|
|
546
|
+
|
|
547
|
+
// Implement caching
|
|
548
|
+
const cache = new Map();
|
|
549
|
+
const cachedResult = cache.get(substateId);
|
|
550
|
+
if (cachedResult) {
|
|
551
|
+
return cachedResult;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Use connection pooling
|
|
555
|
+
const provider = new IndexerProvider({
|
|
556
|
+
endpoint: 'http://localhost:18300',
|
|
557
|
+
maxConnections: 10,
|
|
558
|
+
timeout: 5000
|
|
559
|
+
});
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
#### ❌ Memory leaks in long-running applications
|
|
563
|
+
|
|
564
|
+
**Symptoms:**
|
|
565
|
+
```
|
|
566
|
+
Increasing memory usage over time
|
|
567
|
+
Application becoming unresponsive
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
**Solutions:**
|
|
571
|
+
```typescript
|
|
572
|
+
// Properly cleanup resources
|
|
573
|
+
class MyApp {
|
|
574
|
+
private signer?: TariSigner;
|
|
575
|
+
|
|
576
|
+
async cleanup() {
|
|
577
|
+
if (this.signer) {
|
|
578
|
+
await this.signer.disconnect();
|
|
579
|
+
this.signer = undefined;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// Remove event listeners
|
|
585
|
+
signer.removeAllListeners();
|
|
586
|
+
|
|
587
|
+
// Clear caches periodically
|
|
588
|
+
setInterval(() => {
|
|
589
|
+
cache.clear();
|
|
590
|
+
}, 300000); // Clear every 5 minutes
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
## Debugging Tips
|
|
594
|
+
|
|
595
|
+
### Enable Debug Logging
|
|
596
|
+
|
|
597
|
+
```typescript
|
|
598
|
+
// Enable debug mode
|
|
599
|
+
localStorage.setItem('debug', 'tari:*');
|
|
600
|
+
|
|
601
|
+
// Or set specific debug levels
|
|
602
|
+
localStorage.setItem('debug', 'tari:signer,tari:provider');
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### Common Debug Commands
|
|
606
|
+
|
|
607
|
+
```typescript
|
|
608
|
+
// Check provider connection
|
|
609
|
+
console.log('Provider status:', await provider.getStatus());
|
|
610
|
+
|
|
611
|
+
// Verify signer state
|
|
612
|
+
console.log('Signer accounts:', await signer.getAccounts());
|
|
613
|
+
|
|
614
|
+
// Monitor transaction status
|
|
615
|
+
const txId = await signer.submitTransaction(tx);
|
|
616
|
+
const status = await provider.getTransactionStatus(txId);
|
|
617
|
+
console.log('Transaction status:', status);
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
### Browser Developer Tools
|
|
621
|
+
|
|
622
|
+
1. **Network Tab**: Check for failed HTTP requests
|
|
623
|
+
2. **Console Tab**: Look for JavaScript errors and warnings
|
|
624
|
+
3. **Application Tab**: Verify localStorage/sessionStorage state
|
|
625
|
+
4. **Sources Tab**: Set breakpoints for debugging
|
|
626
|
+
|
|
627
|
+
## Getting Help
|
|
628
|
+
|
|
629
|
+
If you're still experiencing issues:
|
|
630
|
+
|
|
631
|
+
1. **Check the latest documentation**: https://tari-project.github.io/tari.js/
|
|
632
|
+
2. **Search existing issues**: https://github.com/tari-project/tari.js/issues
|
|
633
|
+
3. **Ask in discussions**: https://github.com/tari-project/tari.js/discussions
|
|
634
|
+
4. **Create a new issue** with:
|
|
635
|
+
- Your environment (OS, Node.js version, browser)
|
|
636
|
+
- Complete error messages
|
|
637
|
+
- Minimal reproduction steps
|
|
638
|
+
- Expected vs actual behavior
|
|
639
|
+
|
|
640
|
+
## Environment Information
|
|
641
|
+
|
|
642
|
+
When reporting issues, include:
|
|
643
|
+
|
|
644
|
+
```bash
|
|
645
|
+
# System information
|
|
646
|
+
node --version
|
|
647
|
+
npm --version
|
|
648
|
+
# or
|
|
649
|
+
pnpm --version
|
|
650
|
+
|
|
651
|
+
# Package versions
|
|
652
|
+
npm list @tari-project/tarijs
|
|
653
|
+
npm list typescript
|
|
654
|
+
|
|
655
|
+
# Browser information (for web apps)
|
|
656
|
+
# Check developer tools → console → navigator.userAgent
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
---
|
|
660
|
+
|
|
661
|
+
*Last updated: 2025-06-25*
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
5
|
+
import tseslint from 'typescript-eslint'
|
|
6
|
+
import { globalIgnores } from 'eslint/config'
|
|
7
|
+
|
|
8
|
+
export default tseslint.config([
|
|
9
|
+
globalIgnores(['dist']),
|
|
10
|
+
{
|
|
11
|
+
files: ['**/*.{ts,tsx}'],
|
|
12
|
+
extends: [
|
|
13
|
+
js.configs.recommended,
|
|
14
|
+
tseslint.configs.recommended,
|
|
15
|
+
reactHooks.configs['recommended-latest'],
|
|
16
|
+
reactRefresh.configs.vite,
|
|
17
|
+
],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
ecmaVersion: 2020,
|
|
20
|
+
globals: globals.browser,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
])
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Tari.js Connect Button Example</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|