MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / main

Function main

sdk/js/test-outputs.js:10–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8const { toKeypair, toKeypairSecure } = require('./dist/node/solana.js');
9
10async function main() {
11 console.log("=== JS SDK Output Test ===");
12
13 try {
14 // Test client get_key
15 const client = new DstackClient();
16 console.log("\n1. Testing DstackClient.getKey()");
17
18 const testPaths = [
19 { path: "test/wallet", purpose: "ethereum" },
20 { path: "test/signing", purpose: "solana" },
21 { path: "user/alice", purpose: "mainnet" }
22 ];
23
24 for (const { path, purpose } of testPaths) {
25 const keyResult = await client.getKey(path, purpose);
26 console.log(`getKey('${path}', '${purpose}'):`);
27 console.log(` key: ${Buffer.from(keyResult.key).toString('hex')}`);
28 console.log(` signature_chain length: ${keyResult.signature_chain.length}`);
29 console.log(` signature_chain[0]: ${Buffer.from(keyResult.signature_chain[0]).toString('hex')}`);
30 }
31
32 // Test viem integration
33 console.log("\n2. Testing Viem Integration");
34 const ethKey = await client.getKey("eth/test", "wallet");
35
36 console.log("\n2.1 toViemAccount (legacy):");
37 try {
38 const account = toViemAccount(ethKey);
39 console.log(` address: ${account.address}`);
40 console.log(` type: ${account.type}`);
41 } catch (error) {
42 console.log(` error: ${error.message}`);
43 }
44
45 console.log("\n2.2 toViemAccountSecure:");
46 try {
47 const accountSecure = toViemAccountSecure(ethKey);
48 console.log(` address: ${accountSecure.address}`);
49 console.log(` type: ${accountSecure.type}`);
50 } catch (error) {
51 console.log(` error: ${error.message}`);
52 }
53
54 // Test solana integration
55 console.log("\n3. Testing Solana Integration");
56 const solKey = await client.getKey("sol/test", "wallet");
57
58 console.log("\n3.1 toKeypair (legacy):");
59 try {
60 const keypair = toKeypair(solKey);
61 console.log(` publicKey: ${keypair.publicKey.toString()}`);
62 console.log(` secretKey length: ${keypair.secretKey.length}`);
63 console.log(` secretKey (first 32 bytes): ${Buffer.from(keypair.secretKey.slice(0, 32)).toString('hex')}`);
64 } catch (error) {
65 console.log(` error: ${error.message}`);
66 }
67

Callers 1

test-outputs.jsFile · 0.70

Calls 11

getKeyMethod · 0.95
tdxQuoteMethod · 0.95
getQuoteMethod · 0.95
toViemAccountFunction · 0.85
toViemAccountSecureFunction · 0.85
toKeypairFunction · 0.85
toKeypairSecureFunction · 0.85
getComposeHashFunction · 0.50
fromMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected