UNPKG

@roochnetwork/rooch-sdk-kit

Version:
85 lines (81 loc) 2.7 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/wellet/bitcoin.ts var bitcoin_exports = {}; __export(bitcoin_exports, { BitcoinWallet: () => BitcoinWallet }); module.exports = __toCommonJS(bitcoin_exports); var import_rooch_sdk2 = require("@roochnetwork/rooch-sdk"); // src/wellet/wallet.ts var import_rooch_sdk = require("@roochnetwork/rooch-sdk"); var Wallet = class extends import_rooch_sdk.Signer { /** * Checks if the wallet is installed. * @returns A promise that resolves to true if the wallet is installed, otherwise false. */ async checkInstalled() { for (let i = 1; i < 10 && !this.getTarget(); i += 1) { await new Promise((resolve) => setTimeout(resolve, 100 * i)); } return Promise.resolve(this.getTarget() !== void 0); } }; // src/wellet/bitcoin.ts var BitcoinWallet = class extends Wallet { async signTransaction(input) { const message = new import_rooch_sdk2.BitcoinSignMessage(input.hashData(), input.getInfo() || ""); return import_rooch_sdk2.Authenticator.bitcoin(message, this, "raw"); } getPublicKey() { if (!this.publicKey) { throw Error("Please connect your wallet first"); } return new import_rooch_sdk2.Secp256k1PublicKey((0, import_rooch_sdk2.fromHEX)(this.publicKey)); } getRoochAddress() { if (!this.currentAddress) { throw Error("Please connect your wallet first"); } return this.currentAddress.genRoochAddress(); } getBitcoinAddress() { if (!this.currentAddress) { throw Error("Please connect your wallet first"); } return this.currentAddress; } getKeyScheme() { return "Secp256k1"; } normalize_recovery_id(v) { let normalizeV = v - 27 - 4; if (normalizeV < 0) { normalizeV = normalizeV + 4; } return normalizeV; } switchAccount() { throw new Error("Method not implemented."); } getChain() { return "bitcoin"; } }; //# sourceMappingURL=bitcoin.js.map