UNPKG

aftermath-ts-sdk

Version:
66 lines (65 loc) 2.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Multisig = void 0; const caller_1 = require("../../general/utils/caller"); /** * The `Multisig` class provides methods to interact with multisig-related functionality, * such as retrieving a multisig address and associated public key for a user. */ class Multisig extends caller_1.Caller { // ========================================================================= // Constructor // ========================================================================= /** * Creates a new instance of `Multisig`. * * @param config - Optional configuration for the `Caller`, including network and access token. * @param Provider - An optional instance of `AftermathApi` to build or fetch multisig data. */ constructor(config, Provider) { super(config, "multisig"); this.Provider = Provider; // ========================================================================= // Private Helpers // ========================================================================= /** * Internal helper to get the configured `Multisig` provider from `AftermathApi`. * Throws an error if the provider is not available. */ this.useProvider = () => { var _a; const provider = (_a = this.Provider) === null || _a === void 0 ? void 0 : _a.Multisig(); if (!provider) throw new Error("missing AftermathApi Provider"); return provider; }; } // ========================================================================= // API // ========================================================================= /** * Retrieves a multisig address and corresponding public key for a user based on their * provided single public key. * * @param inputs - An object implementing `ApiMultisigUserBody`, containing the user's public key as a `Uint8Array`. * @returns A promise that resolves to an object containing both the multisig address and its public key. * * @example * ```typescript * * const afSdk = new Aftermath("MAINNET"); * await afSdk.init(); // initialize provider * * const multisig = afSdk.Multisig(); * * const data = await multisig.getMultisigForUser({ * userPublicKey: myPublicKeyBytes * }); * console.log(data.address, data.publicKey); * ``` */ getMultisigForUser(inputs) { return this.useProvider().getMultisigForUser(inputs); } } exports.Multisig = Multisig;