@opcat-labs/opcat 2.0.0 → 2.0.1-beta-d1e3447-20251124
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/package.json +3 -2
- package/test-cjs/package.json +6 -0
- package/test-cjs/test.cjs +56 -0
- package/test-esm/package.json +7 -0
- package/test-esm/test.mjs +60 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opcat-labs/opcat",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1-beta-d1e3447-20251124",
|
|
4
4
|
"description": "opcat base SDK",
|
|
5
5
|
"main": "./cjs/index.cjs",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"postgen:esm": "npm run fixup",
|
|
19
19
|
"fixup": "node fixup.cjs",
|
|
20
20
|
"gen:types": "tsc",
|
|
21
|
-
"test": "mocha"
|
|
21
|
+
"test": "mocha && npm run test:dist",
|
|
22
|
+
"test:dist": "node test-esm/test.mjs && node test-cjs/test.cjs"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"assert": "^2.1.0",
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CJS Import Test for opcat
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
console.log('Testing opcat CJS import...\n');
|
|
6
|
+
|
|
7
|
+
// Test 1: Package import
|
|
8
|
+
console.log('Test 1: Importing as package (@opcat-labs/opcat)...');
|
|
9
|
+
try {
|
|
10
|
+
const opcat = require('@opcat-labs/opcat');
|
|
11
|
+
console.log('✓ Package import successful');
|
|
12
|
+
console.log(' Exported keys:', Object.keys(opcat).slice(0, 10).join(', '), '...');
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.log('✗ Package import failed:', error.message);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Test 2: Named exports
|
|
18
|
+
console.log('\nTest 2: Testing named exports from package...');
|
|
19
|
+
try {
|
|
20
|
+
const { PrivateKey, PublicKey, Address, Transaction, Script } = require('@opcat-labs/opcat');
|
|
21
|
+
console.log('✓ Named exports from package successful');
|
|
22
|
+
console.log(' PrivateKey:', typeof PrivateKey);
|
|
23
|
+
console.log(' PublicKey:', typeof PublicKey);
|
|
24
|
+
console.log(' Address:', typeof Address);
|
|
25
|
+
console.log(' Transaction:', typeof Transaction);
|
|
26
|
+
console.log(' Script:', typeof Script);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.log('✗ Named exports failed:', error.message);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Test 3: Direct file import
|
|
32
|
+
console.log('\nTest 3: Importing from direct file path...');
|
|
33
|
+
try {
|
|
34
|
+
const opcat = require('../cjs/index.cjs');
|
|
35
|
+
console.log('✓ Direct file import successful');
|
|
36
|
+
console.log(' Exported keys:', Object.keys(opcat).slice(0, 10).join(', '), '...');
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.log('✗ Direct file import failed:', error.message);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Test 4: Functionality test
|
|
42
|
+
console.log('\nTest 4: Testing actual functionality...');
|
|
43
|
+
try {
|
|
44
|
+
const { PrivateKey, Networks } = require('@opcat-labs/opcat');
|
|
45
|
+
const privKey = new PrivateKey();
|
|
46
|
+
const pubKey = privKey.toPublicKey();
|
|
47
|
+
const address = privKey.toAddress(Networks.testnet);
|
|
48
|
+
console.log('✓ Functionality test passed');
|
|
49
|
+
console.log(' Generated private key:', privKey.toString().slice(0, 20) + '...');
|
|
50
|
+
console.log(' Derived public key:', pubKey.toString().slice(0, 20) + '...');
|
|
51
|
+
console.log(' Derived address:', address.toString());
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.log('✗ Functionality test failed:', error.message);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.log('\n=== CJS Import Test Complete ===\n');
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESM Import Test for opcat
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
console.log('Testing opcat ESM import...\n');
|
|
6
|
+
|
|
7
|
+
// Test 1: Package import
|
|
8
|
+
console.log('Test 1: Importing as package (@opcat-labs/opcat)...');
|
|
9
|
+
try {
|
|
10
|
+
const opcat = await import('@opcat-labs/opcat');
|
|
11
|
+
console.log('✓ Package import successful');
|
|
12
|
+
console.log(' Exported keys:', Object.keys(opcat).slice(0, 10).join(', '), '...');
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.log('✗ Package import failed:', error.message);
|
|
15
|
+
console.log(' Full error:', error);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Test 2: Named exports
|
|
19
|
+
console.log('\nTest 2: Testing named exports from package...');
|
|
20
|
+
try {
|
|
21
|
+
const { PrivateKey, PublicKey, Address, Transaction, Script } = await import('@opcat-labs/opcat');
|
|
22
|
+
console.log('✓ Named exports from package successful');
|
|
23
|
+
console.log(' PrivateKey:', typeof PrivateKey);
|
|
24
|
+
console.log(' PublicKey:', typeof PublicKey);
|
|
25
|
+
console.log(' Address:', typeof Address);
|
|
26
|
+
console.log(' Transaction:', typeof Transaction);
|
|
27
|
+
console.log(' Script:', typeof Script);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.log('✗ Named exports failed:', error.message);
|
|
30
|
+
console.log(' Full error:', error);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Test 3: Direct file import
|
|
34
|
+
console.log('\nTest 3: Importing from direct file path...');
|
|
35
|
+
try {
|
|
36
|
+
const opcat = await import('../esm/index.js');
|
|
37
|
+
console.log('✓ Direct file import successful');
|
|
38
|
+
console.log(' Exported keys:', Object.keys(opcat).slice(0, 10).join(', '), '...');
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.log('✗ Direct file import failed:', error.message);
|
|
41
|
+
console.log(' Full error:', error);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Test 4: Functionality test
|
|
45
|
+
console.log('\nTest 4: Testing actual functionality...');
|
|
46
|
+
try {
|
|
47
|
+
const { PrivateKey, Networks } = await import('@opcat-labs/opcat');
|
|
48
|
+
const privKey = new PrivateKey();
|
|
49
|
+
const pubKey = privKey.toPublicKey();
|
|
50
|
+
const address = privKey.toAddress(Networks.testnet);
|
|
51
|
+
console.log('✓ Functionality test passed');
|
|
52
|
+
console.log(' Generated private key:', privKey.toString().slice(0, 20) + '...');
|
|
53
|
+
console.log(' Derived public key:', pubKey.toString().slice(0, 20) + '...');
|
|
54
|
+
console.log(' Derived address:', address.toString());
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.log('✗ Functionality test failed:', error.message);
|
|
57
|
+
console.log(' Full error:', error);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log('\n=== ESM Import Test Complete ===\n');
|