@kagamidigital/salt-sdk-mirror
    Preparing search index...

    Class NudgeListener

    Listens for incoming keygen and signing nudges. By default automatically joins and runs the MPC ceremony for each one. Errors encountered while validating, joining, or running a ceremony surface through the NudgeListenerEvents.error event.

    Pass autoJoin: false to take manual control: the listener emits NudgeListenerEvents.nudgeReceived with a join callback the consumer can invoke when it decides this nudge should be accepted. join() resolves with an AccountCeremony (keygen) or TransactionJoinCeremony (signing). Both implement the SaltCeremony interface, so await ceremony.wait() drives either to completion without branching on kind. Sessions are de-duplicated — a given nudge can only be joined once regardless of mode.

    Concurrency: nudges are joined and run concurrently — multiple ceremonies can be in flight simultaneously.

    Obtain a NudgeListener via Salt.listenToAccountNudges.

    const nudgeListener = await salt.listenToAccountNudges({ signer });

    nudgeListener.on('error', (err) => {
    console.error('Ceremony failed:', err);
    });
    const nudgeListener = await salt.listenToAccountNudges({
    signer,
    autoJoin: false,
    });

    nudgeListener.on('nudgeReceived', async ({ join }) => {
    const ceremony = await join();
    await ceremony.wait();
    });
    nudgeListener.on('nudgeReceived', async ({ kind, nudge, join }) => {
    if (kind === 'keygen') {
    if (nudge.organisationId !== acceptedOrg) return;
    const ceremony = await join();
    ceremony.on('keygenCompleted', () => { ... });
    const { account } = await ceremony.wait();
    } else {
    const ceremony = await join();
    await ceremony.wait();
    }
    });

    Hierarchy

    Index

    Properties

    prefixed: string | boolean

    Methods

    • Stop listening for nudges. Unsubscribes from nudge events without closing the underlying websocket — call Salt.disconnect to close the socket and allow the Node.js process to exit.

      Returns void

      nudgeListener.disableNudgeListener();
      salt.disconnect();
    • Subscribes to nudge events on the underlying socket. Called by Salt.listenToAccountNudges after construction; you only need to call it again after a matching disableNudgeListener to resume listening. Idempotent — calling while already enabled is a no-op.

      Returns void

      nudgeListener.enableNudgeListener();
      
    • Return an array listing the events for which the emitter has registered listeners.

      Returns (keyof NudgeListenerEvents)[]

    • Return the number of listeners listening to a given event.

      Parameters

      Returns number

    • Remove all listeners, or those of the specified event.

      Parameters

      • Optionalevent: keyof NudgeListenerEvents

      Returns this