@phala/dstack-sdk
Version:
26 lines (22 loc) • 897 B
JavaScript
;
var sha256 = require('@noble/hashes/sha256');
var web3_js = require('@solana/web3.js');
// src/solana.ts
function toKeypair(keyResponse) {
if (keyResponse.__name__ === "GetTlsKeyResponse") {
console.warn("toKeypair: Please don't use `deriveKey` method to get key, use `getKey` instead.");
const bytes = keyResponse.asUint8Array(32);
return web3_js.Keypair.fromSeed(bytes);
}
return web3_js.Keypair.fromSeed(keyResponse.key);
}
function toKeypairSecure(keyResponse) {
if (keyResponse.__name__ === "GetTlsKeyResponse") {
console.warn("toKeypairSecure: Please don't use `deriveKey` method to get key, use `getKey` instead.");
const buf = sha256.sha256(keyResponse.asUint8Array());
return web3_js.Keypair.fromSeed(buf);
}
return web3_js.Keypair.fromSeed(keyResponse.key);
}
exports.toKeypair = toKeypair;
exports.toKeypairSecure = toKeypairSecure;