UNPKG

openraas

Version:

Open Robot-as-a-Service Protocol - A comprehensive TypeScript library for building and consuming RaaS applications with X402 payment support on Solana

30 lines (29 loc) 1.02 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.WalletManager = void 0; const web3_js_1 = require("@solana/web3.js"); const bs58_1 = __importDefault(require("bs58")); class WalletManager { constructor(privateKeyOrKeypair) { if (privateKeyOrKeypair instanceof web3_js_1.Keypair) { this.keypair = privateKeyOrKeypair; } else if (typeof privateKeyOrKeypair === 'string') { const secretKey = bs58_1.default.decode(privateKeyOrKeypair); this.keypair = web3_js_1.Keypair.fromSecretKey(secretKey); } else { this.keypair = web3_js_1.Keypair.fromSecretKey(privateKeyOrKeypair); } } getPublicKey() { return this.keypair.publicKey.toBase58(); } getKeypair() { return this.keypair; } } exports.WalletManager = WalletManager;