@smartledger/bsv 3.2.1 → 3.3.2
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/CHANGELOG.md +147 -0
- package/README.md +289 -55
- package/architecture_demo.js +247 -0
- package/bsv-covenant.min.js +10 -0
- package/bsv-gdaf.min.js +37 -0
- package/bsv-ltp.min.js +37 -0
- package/bsv-script-helper.min.js +10 -0
- package/bsv-security.min.js +31 -0
- package/bsv-shamir.min.js +12 -0
- package/bsv-smartcontract.min.js +37 -0
- package/bsv.bundle.js +9 -9
- package/bsv.min.js +3 -3
- package/build/bsv-covenant.min.js +10 -0
- package/build/bsv-script-helper.min.js +10 -0
- package/build/bsv-security.min.js +31 -0
- package/build/bsv-smartcontract.min.js +39 -0
- package/build/bsv.bundle.js +39 -0
- package/build/bsv.min.js +39 -0
- package/build/webpack.bundle.config.js +22 -0
- package/build/webpack.config.js +18 -0
- package/build/webpack.covenant.config.js +27 -0
- package/build/webpack.gdaf.config.js +54 -0
- package/build/webpack.ltp.config.js +17 -0
- package/build/webpack.script-helper.config.js +27 -0
- package/build/webpack.security.config.js +23 -0
- package/build/webpack.smartcontract.config.js +25 -0
- package/build/webpack.subproject.config.js +6 -0
- package/bundle-entry.js +341 -0
- package/complete_ltp_demo.js +511 -0
- package/covenant-entry.js +44 -0
- package/docs/pushtx-key-insights.md +106 -0
- package/gdaf-entry.js +54 -0
- package/index.js +272 -5
- package/lib/crypto/shamir.js +360 -0
- package/lib/gdaf/attestation-signer.js +461 -0
- package/lib/gdaf/attestation-verifier.js +600 -0
- package/lib/gdaf/did-resolver.js +382 -0
- package/lib/gdaf/index.js +471 -0
- package/lib/gdaf/schema-validator.js +682 -0
- package/lib/gdaf/smartledger-anchor.js +486 -0
- package/lib/gdaf/zk-prover.js +507 -0
- package/lib/ltp/anchor.js +438 -0
- package/lib/ltp/claim.js +1026 -0
- package/lib/ltp/index.js +470 -0
- package/lib/ltp/obligation.js +945 -0
- package/lib/ltp/proof.js +828 -0
- package/lib/ltp/registry.js +702 -0
- package/lib/ltp/right.js +765 -0
- package/lib/smart_contract/API_REFERENCE.md +1 -1
- package/lib/smart_contract/EXAMPLES.md +2 -2
- package/lib/smart_contract/QUICK_START.md +2 -2
- package/lib/smart_contract/README.md +1 -1
- package/lib/smart_contract/index.js +4 -0
- package/ltp-entry.js +92 -0
- package/package.json +91 -20
- package/script-helper-entry.js +49 -0
- package/security-entry.js +70 -0
- package/shamir-entry.js +173 -0
- package/shamir_demo.js +121 -0
- package/simple_demo.js +204 -0
- package/smartcontract-entry.js +133 -0
- package/test_shamir.js +221 -0
- package/test_standalone_shamir.html +83 -0
- package/tests/bundle-completeness-test.html +131 -0
- package/tests/bundle-demo.html +476 -0
- package/tests/smartcontract-test.html +239 -0
- package/tests/standalone-modules-test.html +260 -0
- package/tests/test.html +612 -0
- package/tests/unpkg-demo.html +194 -0
- package/docs/nchain.md +0 -958
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>SmartLedger BSV Bundle Demo - All-in-One</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: Arial, sans-serif;
|
|
10
|
+
max-width: 1000px;
|
|
11
|
+
margin: 0 auto;
|
|
12
|
+
padding: 20px;
|
|
13
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
14
|
+
color: white;
|
|
15
|
+
}
|
|
16
|
+
.demo-section {
|
|
17
|
+
background: rgba(255,255,255,0.1);
|
|
18
|
+
backdrop-filter: blur(10px);
|
|
19
|
+
padding: 20px;
|
|
20
|
+
margin: 20px 0;
|
|
21
|
+
border-radius: 12px;
|
|
22
|
+
border: 1px solid rgba(255,255,255,0.2);
|
|
23
|
+
}
|
|
24
|
+
h1 {
|
|
25
|
+
color: #fff;
|
|
26
|
+
text-align: center;
|
|
27
|
+
font-size: 2.5em;
|
|
28
|
+
margin-bottom: 10px;
|
|
29
|
+
}
|
|
30
|
+
h2 {
|
|
31
|
+
color: #f0f0f0;
|
|
32
|
+
border-bottom: 2px solid rgba(255,255,255,0.3);
|
|
33
|
+
padding-bottom: 5px;
|
|
34
|
+
}
|
|
35
|
+
.result {
|
|
36
|
+
background: rgba(0,0,0,0.3);
|
|
37
|
+
padding: 15px;
|
|
38
|
+
border-left: 4px solid #4CAF50;
|
|
39
|
+
margin: 10px 0;
|
|
40
|
+
font-family: 'Courier New', monospace;
|
|
41
|
+
border-radius: 5px;
|
|
42
|
+
font-size: 0.9em;
|
|
43
|
+
line-height: 1.4;
|
|
44
|
+
}
|
|
45
|
+
.button {
|
|
46
|
+
background: linear-gradient(45deg, #4CAF50, #45a049);
|
|
47
|
+
color: white;
|
|
48
|
+
border: none;
|
|
49
|
+
padding: 12px 24px;
|
|
50
|
+
border-radius: 25px;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
margin: 8px;
|
|
53
|
+
font-weight: bold;
|
|
54
|
+
transition: all 0.3s;
|
|
55
|
+
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
|
56
|
+
}
|
|
57
|
+
.button:hover {
|
|
58
|
+
transform: translateY(-2px);
|
|
59
|
+
box-shadow: 0 6px 12px rgba(0,0,0,0.3);
|
|
60
|
+
}
|
|
61
|
+
.feature-grid {
|
|
62
|
+
display: grid;
|
|
63
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
64
|
+
gap: 15px;
|
|
65
|
+
margin: 20px 0;
|
|
66
|
+
}
|
|
67
|
+
.feature-card {
|
|
68
|
+
background: rgba(255,255,255,0.1);
|
|
69
|
+
padding: 15px;
|
|
70
|
+
border-radius: 8px;
|
|
71
|
+
text-align: center;
|
|
72
|
+
border: 1px solid rgba(255,255,255,0.2);
|
|
73
|
+
}
|
|
74
|
+
.bundle-info {
|
|
75
|
+
background: linear-gradient(45deg, #FF6B6B, #FF8E53);
|
|
76
|
+
padding: 20px;
|
|
77
|
+
border-radius: 12px;
|
|
78
|
+
margin: 20px 0;
|
|
79
|
+
text-align: center;
|
|
80
|
+
}
|
|
81
|
+
</style>
|
|
82
|
+
</head>
|
|
83
|
+
<body>
|
|
84
|
+
<h1>🚀 SmartLedger BSV Complete Bundle</h1>
|
|
85
|
+
|
|
86
|
+
<div class="bundle-info">
|
|
87
|
+
<h2>📦 Single File - Everything Included!</h2>
|
|
88
|
+
<p><strong>Size:</strong> ~770KB | <strong>File:</strong> bsv.bundle.js | <strong>Version:</strong> v3.2.1</p>
|
|
89
|
+
<p>Core BSV + Message + 24-Word Mnemonics + ECIES + SmartContract + Debug Tools</p>
|
|
90
|
+
<p><em>🔒 Defaults to 24-word mnemonics (256-bit entropy) for maximum security</em></p>
|
|
91
|
+
<p><em>🐛 Includes integrated debug tools for script analysis</em></p>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div class="demo-section">
|
|
95
|
+
<h2>📋 Bundle Contents & Information</h2>
|
|
96
|
+
<div id="bundle-info" class="result">Loading bundle information...</div>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div class="demo-section">
|
|
100
|
+
<h2>🔑 Core BSV - Keys & Addresses</h2>
|
|
101
|
+
<button class="button" onclick="testCore()">Generate Keys</button>
|
|
102
|
+
<div id="core-results" class="result">Click button to test core functionality...</div>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<div class="demo-section">
|
|
106
|
+
<h2>💬 Message Signing (Built-in)</h2>
|
|
107
|
+
<button class="button" onclick="testMessage()">Sign Message</button>
|
|
108
|
+
<div id="message-results" class="result">Click button to test message signing...</div>
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<div class="demo-section">
|
|
112
|
+
<h2>🎲 HD Wallets & Mnemonic (Built-in)</h2>
|
|
113
|
+
<button class="button" onclick="testMnemonic()">Generate Mnemonic</button>
|
|
114
|
+
<div id="mnemonic-results" class="result">Click button to test mnemonic generation...</div>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<div class="demo-section">
|
|
118
|
+
<h2>🔒 ECIES Encryption (Built-in)</h2>
|
|
119
|
+
<button class="button" onclick="testECIES()">Test Encryption</button>
|
|
120
|
+
<div id="ecies-results" class="result">Click button to test ECIES encryption...</div>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<div class="demo-section">
|
|
124
|
+
<h2>🛡️ SmartLedger Bundle Helper</h2>
|
|
125
|
+
<button class="button" onclick="testBundleHelpers()">Quick Generate</button>
|
|
126
|
+
<div id="helper-results" class="result">Click button to test bundle helpers...</div>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div class="demo-section">
|
|
130
|
+
<h2>🐛 Debug Tools (v3.2.1 NEW!)</h2>
|
|
131
|
+
<button class="button" onclick="testDebugTools()">Test Script Debug</button>
|
|
132
|
+
<div id="debug-results" class="result">Click button to test integrated debug tools...</div>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<div class="demo-section">
|
|
136
|
+
<h2>📊 Feature Comparison</h2>
|
|
137
|
+
<div class="feature-grid">
|
|
138
|
+
<div class="feature-card">
|
|
139
|
+
<strong>bsv.min.js</strong><br>
|
|
140
|
+
459KB<br>
|
|
141
|
+
Core only
|
|
142
|
+
</div>
|
|
143
|
+
<div class="feature-card">
|
|
144
|
+
<strong>4 Separate Files</strong><br>
|
|
145
|
+
~1.3MB total<br>
|
|
146
|
+
Load as needed
|
|
147
|
+
</div>
|
|
148
|
+
<div class="feature-card" style="background: rgba(76, 175, 80, 0.3);">
|
|
149
|
+
<strong>bsv.bundle.js</strong><br>
|
|
150
|
+
770KB<br>
|
|
151
|
+
Everything included!
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<!-- Load the complete bundle -->
|
|
157
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.2.1/bsv.bundle.js"></script>
|
|
158
|
+
|
|
159
|
+
<script>
|
|
160
|
+
// Check if library loaded properly
|
|
161
|
+
function checkLibraryLoaded() {
|
|
162
|
+
if (typeof bsv === 'undefined') {
|
|
163
|
+
console.error('SmartLedger-BSV not loaded');
|
|
164
|
+
document.getElementById('bundle-info').innerHTML = `
|
|
165
|
+
<strong>❌ Library Loading Failed</strong><br>
|
|
166
|
+
CDN: https://unpkg.com/@smartledger/bsv@3.2.1/bsv.bundle.js<br>
|
|
167
|
+
Please check your internet connection and try refreshing the page.
|
|
168
|
+
`;
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
console.log('✅ SmartLedger-BSV v3.2.1 Bundle loaded successfully');
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
// Display bundle information
|
|
175
|
+
function showBundleInfo() {
|
|
176
|
+
const info = document.getElementById('bundle-info');
|
|
177
|
+
|
|
178
|
+
let bundleContent = `
|
|
179
|
+
<strong>Bundle Version:</strong> v3.2.1<br>
|
|
180
|
+
<strong>CDN Source:</strong> https://unpkg.com/@smartledger/bsv@3.2.1/<br>
|
|
181
|
+
<strong>Bundle Size:</strong> ~770KB<br>
|
|
182
|
+
<strong>Available Classes:</strong><br>
|
|
183
|
+
`;
|
|
184
|
+
|
|
185
|
+
// Check what's available
|
|
186
|
+
const available = [];
|
|
187
|
+
if (bsv.PrivateKey) available.push('PrivateKey');
|
|
188
|
+
if (bsv.PublicKey) available.push('PublicKey');
|
|
189
|
+
if (bsv.Address) available.push('Address');
|
|
190
|
+
if (bsv.Transaction) available.push('Transaction');
|
|
191
|
+
if (bsv.Script) available.push('Script');
|
|
192
|
+
if (bsv.Message) available.push('Message');
|
|
193
|
+
if (bsv.Mnemonic) available.push('Mnemonic');
|
|
194
|
+
if (bsv.HDPrivateKey) available.push('HDPrivateKey');
|
|
195
|
+
if (bsv.ECIES) available.push('ECIES');
|
|
196
|
+
if (bsv.crypto) available.push('crypto');
|
|
197
|
+
|
|
198
|
+
bundleContent += ` ${available.join(', ')}<br>`;
|
|
199
|
+
|
|
200
|
+
// Check SmartContract debug methods if available
|
|
201
|
+
if (bsv.SmartContract) {
|
|
202
|
+
const methodCount = Object.keys(bsv.SmartContract).length;
|
|
203
|
+
const hasDebugTools = !!(bsv.SmartContract.examineStack && bsv.SmartContract.interpretScript);
|
|
204
|
+
bundleContent += `<strong>SmartContract Methods:</strong> ${methodCount}<br>`;
|
|
205
|
+
bundleContent += `<strong>Debug Tools Available:</strong> ${hasDebugTools ? 'Yes ✅' : 'No ❌'}<br>`;
|
|
206
|
+
} else {
|
|
207
|
+
bundleContent += `<strong>SmartContract Interface:</strong> Not in bundle (available in bsv.min.js)<br>`;
|
|
208
|
+
bundleContent += `<strong>Bundle Focus:</strong> Core BSV + Message + Mnemonic + ECIES<br>`;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Show total available properties
|
|
212
|
+
const totalProps = Object.keys(bsv).length;
|
|
213
|
+
bundleContent += `<strong>Total BSV Properties:</strong> ${totalProps}<br>`;
|
|
214
|
+
bundleContent += `<strong>Bundle Status:</strong> ${available.length > 5 ? 'Fully Loaded ✅' : 'Partially Loaded ⚠️'}`;
|
|
215
|
+
|
|
216
|
+
info.innerHTML = bundleContent;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Test core BSV functionality
|
|
220
|
+
function testCore() {
|
|
221
|
+
try {
|
|
222
|
+
const privateKey = new bsv.PrivateKey();
|
|
223
|
+
const publicKey = privateKey.toPublicKey();
|
|
224
|
+
const address = privateKey.toAddress();
|
|
225
|
+
|
|
226
|
+
document.getElementById('core-results').innerHTML = `
|
|
227
|
+
<strong>✅ Core BSV Working!</strong><br>
|
|
228
|
+
Private Key: ${privateKey.toString().substring(0, 20)}...<br>
|
|
229
|
+
Public Key: ${publicKey.toString().substring(0, 40)}...<br>
|
|
230
|
+
Address: ${address.toString()}<br>
|
|
231
|
+
Network: ${address.network.name}
|
|
232
|
+
`;
|
|
233
|
+
} catch (error) {
|
|
234
|
+
document.getElementById('core-results').innerHTML = `❌ Error: ${error.message}`;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Test message functionality
|
|
239
|
+
function testMessage() {
|
|
240
|
+
try {
|
|
241
|
+
const privateKey = new bsv.PrivateKey();
|
|
242
|
+
const message = new bsv.Message('Hello from SmartLedger BSV Bundle!');
|
|
243
|
+
const signature = message.sign(privateKey);
|
|
244
|
+
const verified = message.verify(privateKey.toAddress(), signature);
|
|
245
|
+
|
|
246
|
+
document.getElementById('message-results').innerHTML = `
|
|
247
|
+
<strong>✅ Message Signing Working!</strong><br>
|
|
248
|
+
Message: "Hello from SmartLedger BSV Bundle!"<br>
|
|
249
|
+
Signature: ${signature.substring(0, 40)}...<br>
|
|
250
|
+
Address: ${privateKey.toAddress().toString()}<br>
|
|
251
|
+
Verified: ${verified ? '✅ Valid' : '❌ Invalid'}
|
|
252
|
+
`;
|
|
253
|
+
} catch (error) {
|
|
254
|
+
document.getElementById('message-results').innerHTML = `❌ Error: ${error.message}`;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Test mnemonic functionality
|
|
259
|
+
function testMnemonic() {
|
|
260
|
+
try {
|
|
261
|
+
// Generate 24-word mnemonic (256-bit entropy) for maximum security
|
|
262
|
+
const mnemonic = new bsv.Mnemonic(256);
|
|
263
|
+
const hdKey = mnemonic.toHDPrivateKey();
|
|
264
|
+
const firstAddress = hdKey.deriveChild(0).privateKey.toAddress();
|
|
265
|
+
|
|
266
|
+
document.getElementById('mnemonic-results').innerHTML = `
|
|
267
|
+
<strong>✅ 24-Word Mnemonic Generation Working!</strong><br>
|
|
268
|
+
Mnemonic: ${mnemonic.toString()}<br>
|
|
269
|
+
Word Count: ${mnemonic.toString().split(' ').length} words (256-bit entropy)<br>
|
|
270
|
+
HD Master: ${hdKey.toString().substring(0, 30)}...<br>
|
|
271
|
+
First Address: ${firstAddress.toString()}<br>
|
|
272
|
+
<em>🔒 Maximum security with 24-word phrase</em>
|
|
273
|
+
`;
|
|
274
|
+
} catch (error) {
|
|
275
|
+
if (error.message.includes('createHmac') || error.message.includes('crypto')) {
|
|
276
|
+
document.getElementById('mnemonic-results').innerHTML = `
|
|
277
|
+
<strong>ℹ️ Browser Crypto Limitation</strong><br>
|
|
278
|
+
<em>Mnemonic generation requires Node.js crypto module</em><br><br>
|
|
279
|
+
<strong>✅ Available Solutions:</strong><br>
|
|
280
|
+
• Use separate <code>bsv-mnemonic.min.js</code> for full browser support<br>
|
|
281
|
+
• Or use in Node.js environment for complete functionality<br><br>
|
|
282
|
+
<strong>Bundle Status:</strong> Core BSV + Message + ECIES working perfectly!<br>
|
|
283
|
+
<em>This is expected behavior for browser crypto limitations</em>
|
|
284
|
+
`;
|
|
285
|
+
} else {
|
|
286
|
+
document.getElementById('mnemonic-results').innerHTML = `❌ Error: ${error.message}`;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Test ECIES functionality
|
|
292
|
+
function testECIES() {
|
|
293
|
+
try {
|
|
294
|
+
const privateKey = new bsv.PrivateKey();
|
|
295
|
+
const publicKey = privateKey.toPublicKey();
|
|
296
|
+
const message = 'Secret message for ECIES encryption test!';
|
|
297
|
+
|
|
298
|
+
// This might not work depending on ECIES implementation
|
|
299
|
+
if (bsv.ECIES && bsv.ECIES.encrypt) {
|
|
300
|
+
const encrypted = bsv.ECIES.encrypt(message, publicKey);
|
|
301
|
+
|
|
302
|
+
document.getElementById('ecies-results').innerHTML = `
|
|
303
|
+
<strong>✅ ECIES Encryption Working!</strong><br>
|
|
304
|
+
Original: "${message}"<br>
|
|
305
|
+
Encrypted: ${encrypted.toString('hex').substring(0, 40)}...<br>
|
|
306
|
+
Public Key: ${publicKey.toString().substring(0, 40)}...
|
|
307
|
+
`;
|
|
308
|
+
} else {
|
|
309
|
+
document.getElementById('ecies-results').innerHTML = `
|
|
310
|
+
<strong>ℹ️ ECIES Available but needs specific usage pattern</strong><br>
|
|
311
|
+
ECIES module loaded: ${bsv.ECIES ? 'Yes' : 'No'}<br>
|
|
312
|
+
Check console for ECIES object structure
|
|
313
|
+
`;
|
|
314
|
+
console.log('ECIES object:', bsv.ECIES);
|
|
315
|
+
}
|
|
316
|
+
} catch (error) {
|
|
317
|
+
document.getElementById('ecies-results').innerHTML = `❌ Error: ${error.message}`;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Test bundle helper functions
|
|
322
|
+
function testBundleHelpers() {
|
|
323
|
+
try {
|
|
324
|
+
// Test basic functionality that should be available
|
|
325
|
+
const privateKey = new bsv.PrivateKey();
|
|
326
|
+
const address = privateKey.toAddress();
|
|
327
|
+
|
|
328
|
+
// Try to create a simple transaction
|
|
329
|
+
const tx = new bsv.Transaction();
|
|
330
|
+
|
|
331
|
+
document.getElementById('helper-results').innerHTML = `
|
|
332
|
+
<strong>✅ Bundle Core Functions Working!</strong><br>
|
|
333
|
+
<strong>Quick Key Generation:</strong><br>
|
|
334
|
+
Address: ${address.toString()}<br>
|
|
335
|
+
Network: ${address.network.name}<br>
|
|
336
|
+
<strong>Transaction Creation:</strong><br>
|
|
337
|
+
Empty TX: ${tx.id || 'Created successfully'}<br>
|
|
338
|
+
<strong>Bundle Status:</strong> All core features operational!<br>
|
|
339
|
+
<em>Note: Advanced helpers may vary by bundle configuration</em>
|
|
340
|
+
`;
|
|
341
|
+
} catch (error) {
|
|
342
|
+
document.getElementById('helper-results').innerHTML = `❌ Error: ${error.message}`;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Test debug tools (NEW in v3.2.1)
|
|
347
|
+
function testDebugTools() {
|
|
348
|
+
try {
|
|
349
|
+
// First, let's see what's actually available in the bsv object
|
|
350
|
+
console.log('BSV object keys:', Object.keys(bsv));
|
|
351
|
+
console.log('SmartContract available:', !!bsv.SmartContract);
|
|
352
|
+
|
|
353
|
+
let debugContent = `<strong>🐛 Debug Tools Investigation (v3.2.1):</strong><br>`;
|
|
354
|
+
|
|
355
|
+
// Check for SmartContract interface
|
|
356
|
+
if (bsv.SmartContract) {
|
|
357
|
+
const methodCount = Object.keys(bsv.SmartContract).length;
|
|
358
|
+
const hasExaminer = !!bsv.SmartContract.examineStack;
|
|
359
|
+
const hasInterpreter = !!bsv.SmartContract.interpretScript;
|
|
360
|
+
const hasMetrics = !!bsv.SmartContract.getScriptMetrics;
|
|
361
|
+
const hasOptimizer = !!bsv.SmartContract.optimizeScript;
|
|
362
|
+
|
|
363
|
+
debugContent += `
|
|
364
|
+
<strong>✅ SmartContract Interface Found!</strong><br>
|
|
365
|
+
<strong>Total Methods:</strong> ${methodCount}<br>
|
|
366
|
+
<strong>Debug Tools Available:</strong><br>
|
|
367
|
+
examineStack: ${hasExaminer ? '✅' : '❌'}<br>
|
|
368
|
+
interpretScript: ${hasInterpreter ? '✅' : '❌'}<br>
|
|
369
|
+
getScriptMetrics: ${hasMetrics ? '✅' : '❌'}<br>
|
|
370
|
+
optimizeScript: ${hasOptimizer ? '✅' : '❌'}<br>
|
|
371
|
+
`;
|
|
372
|
+
|
|
373
|
+
// Test with a simple script if debug tools are available
|
|
374
|
+
if (hasExaminer) {
|
|
375
|
+
try {
|
|
376
|
+
const script = bsv.Script.fromASM('OP_1 OP_2 OP_ADD');
|
|
377
|
+
const result = bsv.SmartContract.examineStack(script);
|
|
378
|
+
debugContent += `<strong>Live Test:</strong><br>`;
|
|
379
|
+
debugContent += ` Script: OP_1 OP_2 OP_ADD<br>`;
|
|
380
|
+
debugContent += ` Examination: Success ✅<br>`;
|
|
381
|
+
} catch (e) {
|
|
382
|
+
debugContent += ` Script test error: ${e.message}<br>`;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
debugContent += `<strong>Status:</strong> Debug tools ${hasExaminer && hasInterpreter ? 'fully integrated! 🚀' : 'partially available'}`;
|
|
387
|
+
} else {
|
|
388
|
+
// SmartContract not available, but let's check what debug functionality might exist
|
|
389
|
+
debugContent += `
|
|
390
|
+
<strong>ℹ️ SmartContract Interface Not Found in Bundle</strong><br>
|
|
391
|
+
<strong>Available BSV Components:</strong><br>
|
|
392
|
+
`;
|
|
393
|
+
|
|
394
|
+
// List available components
|
|
395
|
+
const coreComponents = [
|
|
396
|
+
'PrivateKey', 'PublicKey', 'Address', 'Transaction', 'Script',
|
|
397
|
+
'Message', 'Mnemonic', 'HDPrivateKey', 'crypto', 'util'
|
|
398
|
+
];
|
|
399
|
+
|
|
400
|
+
coreComponents.forEach(component => {
|
|
401
|
+
if (bsv[component]) {
|
|
402
|
+
debugContent += ` ${component}: ✅<br>`;
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
// Check for script-related debugging capability
|
|
407
|
+
if (bsv.Script) {
|
|
408
|
+
try {
|
|
409
|
+
const script = bsv.Script.fromASM('OP_1 OP_2 OP_ADD');
|
|
410
|
+
debugContent += `<strong>Basic Script Test:</strong><br>`;
|
|
411
|
+
debugContent += ` Script creation: ✅<br>`;
|
|
412
|
+
debugContent += ` ASM: ${script.toASM()}<br>`;
|
|
413
|
+
debugContent += ` Hex: ${script.toHex().substring(0, 20)}...<br>`;
|
|
414
|
+
} catch (e) {
|
|
415
|
+
debugContent += ` Script test failed: ${e.message}<br>`;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
debugContent += `
|
|
420
|
+
<strong>Bundle Note:</strong> Debug tools may be in the separate minified file.<br>
|
|
421
|
+
<em>Use <code>bsv.min.js</code> for full SmartContract interface with debug tools.</em>
|
|
422
|
+
`;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
document.getElementById('debug-results').innerHTML = debugContent;
|
|
426
|
+
} catch (error) {
|
|
427
|
+
document.getElementById('debug-results').innerHTML = `
|
|
428
|
+
<strong>❌ Debug Tools Test Failed:</strong><br>
|
|
429
|
+
Error: ${error.message}<br><br>
|
|
430
|
+
<strong>Troubleshooting:</strong><br>
|
|
431
|
+
• Check browser console for detailed errors<br>
|
|
432
|
+
• Verify CDN connectivity<br>
|
|
433
|
+
• Try refreshing the page<br>
|
|
434
|
+
• Debug tools may require the main bsv.min.js file
|
|
435
|
+
`;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// Initialize on page load
|
|
440
|
+
window.addEventListener('load', () => {
|
|
441
|
+
// Wait a moment for the library to fully load
|
|
442
|
+
setTimeout(() => {
|
|
443
|
+
if (checkLibraryLoaded()) {
|
|
444
|
+
showBundleInfo();
|
|
445
|
+
|
|
446
|
+
// Enhanced debugging information
|
|
447
|
+
console.log('=== SmartLedger-BSV Bundle Debug Info ===');
|
|
448
|
+
console.log('BSV object keys:', Object.keys(bsv));
|
|
449
|
+
console.log('SmartContract available:', !!bsv.SmartContract);
|
|
450
|
+
console.log('Total BSV properties:', Object.keys(bsv).length);
|
|
451
|
+
|
|
452
|
+
if (bsv.SmartContract) {
|
|
453
|
+
console.log('SmartContract methods:', Object.keys(bsv.SmartContract).length);
|
|
454
|
+
console.log('Debug tools:', {
|
|
455
|
+
examineStack: !!bsv.SmartContract.examineStack,
|
|
456
|
+
interpretScript: !!bsv.SmartContract.interpretScript,
|
|
457
|
+
getScriptMetrics: !!bsv.SmartContract.getScriptMetrics,
|
|
458
|
+
optimizeScript: !!bsv.SmartContract.optimizeScript
|
|
459
|
+
});
|
|
460
|
+
} else {
|
|
461
|
+
console.log('SmartContract not found in bundle - debug tools available in bsv.min.js');
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Check for other important components
|
|
465
|
+
const components = ['crypto', 'Message', 'Script', 'Transaction'];
|
|
466
|
+
components.forEach(comp => {
|
|
467
|
+
console.log(`${comp} available:`, !!bsv[comp]);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
console.log('=== End Debug Info ===');
|
|
471
|
+
}
|
|
472
|
+
}, 500);
|
|
473
|
+
});
|
|
474
|
+
</script>
|
|
475
|
+
</body>
|
|
476
|
+
</html>
|