Constructors

Properties

Methods

_getSignerOfferings changeActiveFiatCurrency changeBitcoinExchangeRateUpdateInterval checkPsbts deleteApprovals deleteCompletedProposals deleteDirectMessages deleteKeyAgentSignalingEvent deletePolicies deleteProposals deleteSignerOfferings deleteSigners disconnect downloadProposalPsbt extractKey finalizeSpendingProposal getActiveFiatCurrency getActiveProposalsByType getApprovals getApprovalsByPolicyId getAuthority getBitcoinExchangeRate getChat getCompletedProposalByTx getCompletedProposals getCompletedProposalsById getCompletedProposalsByPolicyId getCompletedProposalsByType getContactProfiles getContactSignersCount getContacts getContactsEvents getContactsSignerOfferingsBySignerDescriptor getConversations getDirectMessagesByConversationId getLastCompletedKeyAgentPaymentProposal getMySharedSigners getMySharedSignersBySharedWith getOwnedSignerOfferings getOwnedSignerOfferingsById getOwnedSignerOfferingsBySignerDescriptor getOwnedSignerOfferingsBySignerFingerprint getOwnedSigners getOwnedSignersByOfferingIdentifiers getPaymentOptions getPolicies getPoliciesByAuthor getPoliciesById getPolicyEvent getPolicyIds getPolicyMembers getProfile getProfiles getProposalPsbt getProposals getProposalsById getProposalsByPolicyId getPsbtFromFileSystem getRecommendedContacts getSharedKeysById getSharedSigners getSharedSignersByOfferingIdentifiers getSharedSignersEvents getSignerOfferings getSignerOfferingsById getSignerOfferingsByKeyAgentPubKey getStore getSuggestedPaymentAmount getSuggestedPaymentPeriod getTransactionMetadata getTransactionMetadataById getTransactionMetadataByPolicyId getTransactionMetadataBySourceId getUnverifiedKeyAgentEventsByPubkey getUnverifiedKeyAgents getVerifiedKeyAgents getVerifiedKeyAgentsEvent getVerifiedKeyAgentsPubKeys hasActiveKeyAgentPaymentProposal initChat initEventKindHandlerFactory initStores isAuthority isKeyAgent isVerifiedKeyAgent removeContacts removeVerifiedKeyAgent revokeMySharedSigners saveKeyAgent saveKeyAgentPaymentProposal saveOwnedSigner savePolicy saveSharedSigner saveSignerOffering saveTransactionMetadata saveVerifiedKeyAgent sendDirectMsg sendGroupMsg sendMessage setAuthenticator setProfile signedPsbtSanityCheck spend subscribe updateBitcoinExchangeRate updateProfile upsertContacts

Constructors

Properties

authenticator: Authenticator
bitcoinUtil: BitcoinUtil
network: NetworkType
nostrClient: NostrClient
stores: Map<number, Store>

Methods

  • Changes the fiat currency used to fetch the Bitcoin exchange rate.

    Parameters

    Returns void

    Example

    changeFiatCurrency("usd");
    
  • Changes the interval at which the bitcoin exchange rate is updated

    Parameters

    • interval: number

      The interval in minutes

    Returns void

    Example

    changeBitcoinExchangeRateUpdateInterval(30);
    
  • Method to check if a proposal's PSBTs can be finalized.

    This method retrieves all approvals for a given proposal ID, filters out the approvals that are expired, and checks if the PSBTs for the active approvals can be finalized.

    Parameters

    • proposalId: string

      The ID of the proposal to check.

    Returns Promise<boolean>

    A Promise that resolves to a boolean indicating whether the PSBTs for the given proposal can be finalized.

  • Asynchronously deletes approvals with the given IDs.

    Parameters

    • ids: string | string[]

      Single or multiple approval IDs to be deleted.

    Returns Promise<void>

    • A promise that resolves to void when the operation is successful.

    Async

    Throws

    • Throws an error if the deletion process fails.

    Example

    await deleteApprovals('some-approval-id');
    
  • Asynchronously deletes completed proposals with the given IDs.

    Parameters

    • ids: string | string[]

      Single or multiple completed proposal IDs to be deleted.

    Returns Promise<void>

    • A promise that resolves to void when the operation is successful.

    Async

    Throws

    • Throws an error if the deletion process fails.

    Example

    await deleteCompletedProposals('some-completed-proposal-id');
    
  • Parameters

    • ids: string | string[]

    Returns Promise<void>

  • Parameters

    • deleteOfferings: boolean = false

    Returns Promise<void>

  • Asynchronously deletes policies with the given IDs.

    Parameters

    • ids: string | string[]

      Single or multiple policy IDs to be deleted.

    Returns Promise<void>

    • A promise that resolves to void when the operation is successful.

    Async

    Throws

    • Throws an error if the deletion process fails.

    Example

    await deletePolicies('some-policy-id');
    
  • Asynchronously deletes proposals with the given IDs.

    Parameters

    • ids: string | string[]

      Single or multiple proposal IDs to be deleted.

    Returns Promise<void>

    • A promise that resolves to void when the operation is successful.

    Async

    Throws

    • Throws an error if the deletion process fails.

    Example

    await deleteProposals('some-proposal-id');
    
  • Parameters

    • signerOfferingsIds: string[]

    Returns Promise<void>

  • Asynchronously deletes signers with the given IDs.

    Parameters

    • ids: string | string[]

      Single or multiple signer IDs to be deleted.

    Returns Promise<void>

    • A promise that resolves to void when the operation is successful.

    Async

    Throws

    • Throws an error if the deletion process fails.

    Example

    await deleteSigners('some-signer-id');
    
  • Disconnects from the SmartVaults instance relay.

    Returns void

    • No return value.

    Example

    smartVaults.disconnect();
    
  • Parameters

    • proposalId: string

    Returns Promise<void>

  • Parameters

    • descriptor: string

    Returns string

  • Method to finalize a spending proposal.

    This method finalizes a spending proposal by doing the following:

    1. It retrieves the proposal by ID and ensures it's a spending proposal.
    2. It fetches the associated policy.
    3. It retrieves all active approvals for the given proposal ID and checks if their PSBTs can be finalized.
    4. If the PSBTs can be finalized, it proceeds to finalize the transaction and broadcast the proposal.
    5. It then encrypts the completed proposal and builds two events: a completed proposal event and a proposal deletion event.
    6. Both events are published
    7. Finally, it constructs and returns the published completed proposal.

    Parameters

    • proposalId: string

      The ID of the spending proposal to finalize.

    Returns Promise<CompletedPublishedProposal>

    A Promise that resolves to a CompletedPublishedProposal object representing the finalized proposal.

    Throws

    An error if the proposal or policy cannot be found, if there are no approvals for the proposal, if the PSBTs cannot be finalized, or if the proposal cannot be broadcast.

  • Asynchronously fetches approvals associated with given proposal IDs.

    Parameters

    • Optional proposal_ids: string | string[]

      Optional proposal IDs to filter the approvals by.

    Returns Promise<Map<string, PublishedApprovedProposal[]>>

    - A Promise that resolves to a Map. Each key in the map is a proposal ID, and the corresponding value is an array of approved proposals associated with that proposal ID.

    Async

    Example

    const approvalsMap = await getApprovals(['proposal1', 'proposal2']);
    const allApprovalsMap = await getApprovals();

    Throws

    • Throws an error if there is a failure in fetching approvals.
  • Asynchronously fetches approved proposals by their associated policy IDs.

    Parameters

    • policy_ids: string | string[]

      A single policy ID or an array of policy IDs for which to fetch approved proposals. If this is not specified, the function fetches approvals for all available policy IDs.

    Returns Promise<Map<string, PublishedApprovedProposal | PublishedApprovedProposal[]>>

    • A promise that resolves to a Map. Each key in the map corresponds to a policy ID. The value is either a single PublishedApprovedProposal object or an array of PublishedApprovedProposal objects.

    Async

    Method

    Throws

    • Throws an error if there is a failure in fetching the approved proposals.

    Example

    // Fetch approvals for a single policy ID
    const approvals = await getApprovalsByPolicyId('some-policy-id');

    // Fetch approvals for multiple policy IDs
    const approvals = await getApprovalsByPolicyId(['policy-id-1', 'policy-id-2']);

    See

    SmartVaultsTypes.PublishedApprovedProposal - For the structure of a PublishedApprovedProposal object.

  • Returns the current bitcoin exchange rate against the active fiat currency

    Returns Promise<number>

    Example

    const rate = getBitcoinExchangeRate();
    
  • Asynchronously fetches all completed proposals, optionally with pagination.

    Parameters

    • Optional paginationOpts: PaginationOpts = {}

      Optional pagination options to control the returned data.

    Returns Promise<CompletedPublishedProposal[]>

    • A promise that resolves to an array of CompletedPublishedProposal objects.

    Async

    Method

    Throws

    • Throws an error if there is a failure in fetching the proposals.

    Example

    // Fetch completed proposals with default settings
    const proposals = await getCompletedProposals();

    // Fetch completed proposals with pagination
    const proposals = await getCompletedProposals({ limit: 5 });

    See

    SmartVaultsTypes.CompletedPublishedProposal - For the structure of a CompletedPublishedProposal object.

  • Asynchronously fetches completed proposals by their IDs.

    Parameters

    • ids: string | string[]

      The IDs of the completed proposals to fetch.

    • Optional paginationOpts: PaginationOpts = {}

      Optional pagination options to limit the number of returned proposals or to fetch from a specific offset.

    Returns Promise<Map<string, CompletedPublishedProposal>>

    • A promise that resolves to a map where the keys are proposal IDs and the values are CompletedPublishedProposal objects.

    Async

    Throws

    • Throws an error if the network request fails.

    Example

    // Fetch a single proposal by ID
    const proposals = await getCompletedProposalsById("some-proposal-id");

    // Fetch multiple proposals by IDs with pagination
    const proposals = await getCompletedProposalsById(["id1", "id2"], { since: new Date() });

    See

    SmartVaultsTypes.CompletedPublishedProposal - For the structure of a CompletedPublishedProposal object.

  • Asynchronously fetches completed proposals by their associated policy IDs.

    Parameters

    • policy_ids: string | string[]

      The policy IDs corresponding to the completed proposals to fetch.

    • Optional paginationOpts: PaginationOpts = {}

      Optional pagination options to limit the number of returned proposals or to fetch from a specific offset.

    Returns Promise<Map<string, CompletedPublishedProposal | CompletedPublishedProposal[]>>

    • A promise that resolves to a map where the keys are policy IDs and the values are either single or arrays of CompletedPublishedProposal objects.

    Async

    Method

    Throws

    • Throws an error if the network request fails or if the internal store is inconsistent.

    Example

    // Fetch a single proposal by policy ID
    const proposals = await getCompletedProposalsByPolicyId("some-policy-id");

    // Fetch multiple proposals by policy IDs with pagination
    const proposals = await getCompletedProposalsByPolicyId(["policy-id1", "policy-id2"], { since : new Date() });

    See

    SmartVaultsTypes.PublishedCompletedSpendingProposal - For the structure of a PublishedCompletedSpendingProposal object.

  • Retrieves profiles for given contacts or for all contacts if none are provided.

    Parameters

    • Optional contacts: Contact[]

      Optional array of contacts.

    Returns Promise<(Contact | ContactProfile)[]>

    • Array of profiles or contacts.

    Async

    Example

    const contactProfiles = await getContactProfiles([{ publicKey: 'key1' }, { publicKey: 'key2' }]);
    
  • Returns the number of contacts that have shared their signer.

    Parameters

    • pubkey: string

      The Nostr hex public key of user for which to fetch the number of contacts that have shared their signer.

    Returns Promise<number>

    - A promise that resolves to the number of contacts that have shared their signer.

    Async

    Example

    const howManySigners = await getContactSignersCount("hexPubKey");
    
  • Retrieves all contacts for the authenticated user.

    Returns Promise<Contact[]>

    • Array of contacts.

    Async

    Example

    const contacts = await getContacts();
    
  • Returns Promise<Event<Contacts>[]>

  • Asynchronously fetches signers the user has shared. If IDs are provided, the method fetches signers corresponding to those IDs. Otherwise, it fetches all shared signers based.

    Parameters

    • Optional id: string | string[]

      Optional ID(s) of the signers to fetch.

    Returns Promise<Map<string, MySharedSigner | MySharedSigner[]>>

    • A promise that resolves to a Map of shared signers, mapped by their IDs.

    Async

    Throws

    Will throw an error if any issue occurs during the request to the relay.

    Example

    // Fetch a single shared signer by ID
    const result = await getMySharedSigners("some-signer-id");

    // Fetch multiple shared signers by IDs
    const result = await getMySharedSigners(["id1", "id2"]);

    // Fetch all shared signers
    const result = await getMySharedSigners();

    See

    SmartVaultsTypes.MySharedSigner - For the structure of MySharedSigner objects.

  • Fetches signers owned by the user and returns them as an array of BaseOwnedSigner objects.

    Returns Promise<PublishedOwnedSigner[]>

    A promise that resolves to an array of BaseOwnedSigner objects. Each BaseOwnedSigner object represents an owned signer and contains all the properties of the base signer object, plus `ownerPubKey' and 'createdAt' properties.

    Throws

    Throws an error if there's an issue in fetching signer events or decrypting content.

    Async

  • Asynchronously retrieves policies within a specified pagination scope.

    Parameters

    • Optional paginationOpts: PaginationOpts = {}

      Pagination options for fetching policies.

    Returns Promise<PublishedPolicy[]>

    • An array of PublishedPolicy objects.

    Async

    Throws

    • If unable to fetch policies.

    Example

    const paginationOpts = { limit: 10, page: 2 };
    const policies = await getPolicies(paginationOpts);
  • Asynchronously retrieves policies by their IDs.

    Parameters

    • ids: string[]

      An array of policy IDs.

    Returns Promise<Map<string, PublishedPolicy>>

    • A map where the key is the policy ID and the value is the PublishedPolicy object.

    Async

    Throws

    • If unable to fetch policies by IDs.

    Example

    const ids = ['id1', 'id2'];
    const policiesById = await getPoliciesById(ids);
  • Parameters

    • policy_id: string

    Returns Promise<Event>

  • Returns Promise<Set<string>>

  • Parameters

    • policy_id: string

    Returns Promise<string[]>

  • Retrieves a profile by a given public key or uses the instance's public key if not provided.

    Parameters

    • Optional publicKey: string

      Optional public key to fetch the profile.

    Returns Promise<Profile>

    • The fetched profile.

    Async

    Example

    const profile = await getProfile('publicKey123');
    
  • Retrieves multiple profiles by their public keys.

    Parameters

    • publicKeys: string[]

      Array of public keys.

    Returns Promise<Profile[]>

    • Array of fetched profiles.

    Async

    Example

    const profiles = await getProfiles(['publicKey1', 'publicKey2']);
    
  • Parameters

    • proposalId: string

    Returns Promise<string>

  • Asynchronously fetches proposals by their IDs.

    Parameters

    • proposal_ids: string | string[]

      A single proposal ID or an array of proposal IDs to fetch.

    • Optional paginationOpts: PaginationOpts = {}

      Optional pagination options.

    Returns Promise<Map<string, ActivePublishedProposal>>

    • A promise that resolves to a Map. Each key corresponds to a proposal ID, and the value is a ActivePublishedProposal object.

    Async

    Throws

    • Throws an error if there is a failure in fetching the proposals.

    Example

    const proposalsById = await getProposalsById('some-proposal-id');
    
  • Asynchronously fetches proposals by associated policy IDs.

    Parameters

    • policy_ids: string | string[]

      A single policy ID or an array of policy IDs for which to fetch proposals.

    • Optional paginationOpts: PaginationOpts = {}

      Optional pagination options.

    Returns Promise<Map<string, ActivePublishedProposal | ActivePublishedProposal[]>>

    • A promise that resolves to a Map. Each key corresponds to a policy ID, and the value is either a single ActivePublishedProposal object or an array of them.

    Async

    Throws

    • Throws an error if there is a failure in fetching the proposals.

    Example

    const proposalsByPolicyId = await getProposalsByPolicyId('some-policy-id');
    
  • Retrieves a list of recommended contacts based on shared signers.

    Returns Promise<(string | Profile)[]>

    • Array of profiles or public keys.

    Async

    Throws

    • On failure to fetch shared signers or contacts.

    Example

    const recommendedContacts = await getRecommendedContacts();
    
  • Asynchronously retrieves shared keys by their IDs.

    Parameters

    • Optional ids: string[]

      An array of shared key IDs.

    Returns Promise<Map<string, SharedKeyAuthenticator>>

    • A map where the key is the shared key ID and the value is the SharedKeyAuthenticator object.

    Async

    Throws

    • If unable to fetch shared keys by IDs.

    Example

    const ids = ['id1', 'id2'];
    const sharedKeysById = await getSharedKeysById(ids);
  • Asynchronously fetches signers shared with the user based on specified public keys. Returns them as an array of PublishedSharedSigner objects, each containing details such as owner's public key and creation time.

    Parameters

    • Optional publicKeys: string | string[]

      Optional public keys to filter the fetched signers. Can be a single string or an array of strings.

    Returns Promise<PublishedSharedSigner[]>

    • A promise that resolves to an array of PublishedSharedSigner objects.

    Async

    Throws

    • Throws an error if any issue occurs during the fetching of signer events or decryption of content.

    Example

    // Fetch shared signers by a specific public key
    const result = await getSharedSigners("some-public-key");

    // Fetch shared signers by multiple public keys
    const result = await getSharedSigners(["key1", "key2"]);

    // Fetch all shared signers
    const result = await getSharedSigners();

    See

    SmartVaultsTypes.PublishedSharedSigner - For the structure of PublishedSharedSigner objects.

  • Asynchronously retrieves transactionMetadata based on the given pagination options.

    Parameters

    • Optional paginationOpts: PaginationOpts = {}

      Optional pagination options for fetching transactionMetadata.

    Returns Promise<PublishedTransactionMetadata[]>

    • A promise that resolves to an array of published transactionMetadata.

    Async

    Example

    const transactionMetadata = await getTransactionMetadata();
    
  • Asynchronously retrieves one or more transactionMetadata by their IDs.

    Parameters

    • transactionMetadataIds: string | string[]

      The transactionMetadata IDs to fetch.

    • Optional paginationOpts: PaginationOpts = {}

      Optional pagination options.

    Returns Promise<Map<string, PublishedTransactionMetadata>>

    - A promise that resolves to a map where the keys are transactionMetadata IDs and the values are the corresponding transactionMetadata.

    Async

    Example

    const transactionMetadataMap = await getTransactionMetadataById(['transactionMetadata1', 'transactionMetadata2']);
    
  • Asynchronously retrieves transactionMetadata associated with one or more policy IDs.

    This method first converts the input into an array of policy IDs (if not already), builds the appropriate filter with pagination options, and then fetches the transactionMetadata.

    Parameters

    • policy_ids: string | string[]

      The policy IDs to filter transactionMetadata by.

    • Optional paginationOpts: PaginationOpts = {}

      Optional pagination options.

    Returns Promise<Map<string, PublishedTransactionMetadata | PublishedTransactionMetadata[]>>

    - A promise that resolves to a map where the keys are policy IDs and the values are the associated transactionMetadata.

    Async

    Example

    const transactionMetadataMap = await getTransactionMetadataByPolicyId(['policy1', 'policy2']);
    
  • Asynchronously retrieves a transactionMetadata given its transactionMetadata data.

    Parameters

    • policyId: string

      The policy ID associaded with the transactionMetadata.

    • sourceId: string | string[]

      The source ID (could be an address a txid, etc).

    Returns Promise<Map<string, PublishedTransactionMetadata>>

    • ººº A promise that resolves to a PublishedTransactionMetadata.

    Async

    Example

    const transactionMetadata = await getTransactionMetadataBySourceId("policyId","trxid");
    
  • Parameters

    • Optional pubkeys: string[]

    Returns Promise<Map<string, Event<number>>>

  • Returns Promise<string[]>

  • Parameters

    • policyId: string
    • Optional signerDescriptor: string

    Returns Promise<boolean>

  • Parameters

    • Optional pubkey: string

    Returns Promise<boolean>

  • Parameters

    • Optional pubkey: string

    Returns Promise<boolean>

  • Parameters

    • Optional pubkey: string

    Returns Promise<boolean>

  • Asynchronously removes contacts by publicKey and publishes a Contacts event.

    Parameters

    • contactsToRemove: string | string[]

      publicKeys of contacts to remove.

    Returns Promise<Contact[]>

    • Resolves to an Event of Kind.Contacts.

    Async

    Throws

    • If removal or event publishing fails.

    Example

    await removeContacts('somePubKey');
    await removeContacts(['somePubKey', 'otherPubKey']);
  • Parameters

    • keyAgentPubKey: string

    Returns Promise<void>

  • Asynchronously revokes shared signers with the given IDs.

    Parameters

    • ids: string | string[]

      Single or multiple shared signer IDs to be revoked ( not signer ids ).

    Returns Promise<void>

    • A promise that resolves to void when the operation is successful.

    Async

    Throws

    • Throws an error if the revocation process fails or if a shared signer with the given ID is not found.

    Example

    await revokeMySharedSigners('some-shared-signer-id');
    
  • Asynchronously saves an owned signer by encrypting its properties, building a new event, and publishing it via NostrClient.

    Parameters

    • params: BaseOwnedSigner

      Parameters for the owned signer, including description, descriptor, fingerprint, name, t.

    Returns Promise<PublishedOwnedSigner>

    A promise that resolves to an BaseOwnedSigner object with encrypted data and includes the owner's public key and creation date.

    Async

    Throws

    Will throw an error if the event publishing fails.

    Example

    const signer = await saveOwnedSigner({description, descriptor, fingerprint, name, t});
    
  • Asynchronously saves a new policy and associated shared keys, then publishes the policy event.

    Parameters

    Returns Promise<PublishedPolicy>

    • A PublishedPolicy instance.

    Async

    Throws

    • If the policy cannot be saved or events cannot be published.

    Example

    const payload = {
    name: 'My Policy',
    description: 'Description here',
    miniscript: 'miniscriptString',
    nostrPublicKeys: ['key1', 'key2'],
    createdAt: new Date()
    };
    const publishedPolicy = await savePolicy(payload);
  • Asynchronously creates and publishes a 'SharedSigners' event.

    Parameters

    Returns Promise<PublishedSharedSigner[]>

    A promise that resolves to a PublishedSharedSigner object, includes the owner's public key and shared date.

    Async

    Throws

    Will throw an error if the event publishing fails or if the user tries to share a signer with themselves.

    Example

    const signer = await saveSharedSigner({descriptor, fingerprint}, pubkey);
    
  • Asynchronously saves a transactionMetadata associated with a given policy ID.

    The method creates and publishes a TransactionMetadata event.

    Parameters

    • policyId: string

      The ID of the policy to which the transactionMetadata is to be associated.

    • transactionMetadata: TransactionMetadata | TransactionMetadata[]

      The transactionMetadata object containing the data to be saved.

    Returns Promise<PublishedTransactionMetadata[]>

    • A promise that resolves to the published transactionMetadata.

    Async

    Throws

    • Throws an error if the policy event retrieval fails, or if shared keys are not found.

    Example

    const publishedTransactionMetadata = await saveTransactionMetadata('some-policy-id', { data: { 'Address': 'some-address' }, text: 'some-transactionMetadata-text' });
    
  • Parameters

    • authenticator: Authenticator

    Returns void

  • Sets the profile metadata and publishes a Metadata event.

    Parameters

    • metadata: Metadata

      Metadata for the profile.

    Returns Promise<Profile>

    • The updated profile.

    Async

    Throws

    • On failure to set metadata or publish the event.

    Example

    await setProfile({ name: 'Alice', about: 'Learning about Smart Vaults' });
    
  • Parameters

    • unsigned: string
    • signed: string

    Returns Promise<void>

  • Asynchronously initiates a spending proposal.

    Parameters

    Returns Promise<PublishedSpendingProposal | PublishedKeyAgentPaymentProposal>

    • The published spending proposal.

    Async

    Throws

    • If invalid UTXOs are provided.

    Throws

    • If frozen UTXOs are provided but 'useFrozenUtxos' is not set to true.

    Throws

    • If an error occurs while building the transaction.

    Throws

    • If an error occurs while publishing the proposal.

    Example

    const payload = {
    policy,
    to_address: "abc123",
    description: "A spending proposal",
    amountDescriptor: 10,
    feeRatePriority: 'high',
    policyPath: new Map([['nodeId',[0,1,2]]]),
    utxos: ["utxo1", "utxo2"],
    useFrozenUtxos: false
    };
    const spendingProposal = await spend(payload);
  • Subscribes to specified kinds of events and handles them using a provided callback function.

    Parameters

    • kinds: Kind | SmartVaultsKind | (Kind | SmartVaultsKind)[]

      The event kinds to subscribe to. This can either be an array or a single value.

    • callback: ((eventKind, payload) => void)

      The callback function to handle incoming events. It receives the kind of event and the associated payload.

        • (eventKind, payload): void
        • Parameters

          • eventKind: number
          • payload: any

          Returns void

    Returns Sub<number>

    • A subscription object that can be used to manage the subscription.

    Throws

    • If an error occurs while processing an event, the error is caught and logged, but does not break the subscription.

    Example

    const kindsToSubscribe = [SmartVaultsKind.Policy, SmartVaultsKind.Proposal];
    const myCallback = (kind, payload) => {
    console.log(`Received event of kind ${kind} with payload:`, payload);
    };

    const mySubscription = subscribe(kindsToSubscribe, myCallback);

    // To unsubscribe
    mySubscription.disconnect();
  • Updates the bitcoin exchange rate against the active fiat currency

    Returns Promise<void>

    Async

    Example

    await updateBitcoinExchangeRate();
    
  • Asynchronously upserts contacts and publishes a Contacts event.

    Parameters

    Returns Promise<Contact[]>

    • Resolves to an Event of Kind.Contacts.

    Async

    Throws

    • If event publishing fails or if the authenticated user is trying to add himself as a contact.

    Example

    const contact = new Contact({ publicKey: 'somePubKey', relay: 'some.relay.com' });
    await upsertContacts(contact);

Generated using TypeDoc