import { SS58String } from 'polkadot-api'; import { bindPersonalIdToAccount } from './bind-personal-id.js'; import { claimPgas } from './claim-pgas.js'; import { bindPaidAliasToAccount } from './bind-paid-alias.js'; import { runChainPrereqProbes } from './chain-prereqs.js'; interface BootstrapState { recognized: boolean; personalIdBound: boolean; pgasBalance: bigint; paidAliasFee: bigint; aliasBound: { paid: boolean; contextHex: string; revision: number; } | null; reviveMapped: boolean; } interface BootstrapResult { initialState: BootstrapState; actionsExecuted: Array<"bind-personal-id" | "claim-pgas" | "bind-paid-alias" | "map-account">; finalState: BootstrapState; } declare class RecognizeRequiredError extends Error { constructor(); } /** * Probe the current bootstrap state from chain for a given account. * All reads are at "best" block — suitable for sequential flow decisions. */ declare function probeBootstrapState({ peopleUnsafeApi, ahUnsafeApi, memberKey, account, }: { peopleUnsafeApi: unknown; ahUnsafeApi: unknown; memberKey: Uint8Array; account: SS58String; }): Promise; /** * Determine the next action needed given the current bootstrap state. * Returns null when the flow is complete. */ declare function nextBootstrapAction(state: BootstrapState): "bind-personal-id" | "claim-pgas" | "bind-paid-alias" | null; /** * Test-only injection seam for `runBootstrap`. When provided, the real WS * connections and environment lookup are bypassed entirely. * * @internal — not part of the public API. */ interface RunBootstrapTestApis { /** Pre-built AH unsafe API (replaces `ahClient.getUnsafeApi()`). */ ahUnsafeApi: unknown; /** Pre-built People unsafe API (replaces `peopleClient.getUnsafeApi()`). */ peopleUnsafeApi: unknown; /** * Mock AH client. Only `destroy` and `submitAndWatch` are used by bootstrap; * a no-op `destroy` is sufficient when the test step doesn't submit. */ ahClient: { destroy: () => void; submitAndWatch?: unknown; }; /** * Mock People client. Only `destroy` and `submitAndWatch` are used. */ peopleClient: { destroy: () => void; submitAndWatch?: unknown; }; /** Override `bindPersonalIdToAccount` (defaults to the real import). */ bindPersonalIdToAccount?: typeof bindPersonalIdToAccount; /** Override `claimPgas` (defaults to the real import). */ claimPgas?: typeof claimPgas; /** Override `bindPaidAliasToAccount` (defaults to the real import). */ bindPaidAliasToAccount?: typeof bindPaidAliasToAccount; /** * Override `runChainPrereqProbes` (defaults to the real import). * Tests can inject a no-op or a function that throws to verify probe * failure is handled correctly. */ runChainPrereqProbes?: typeof runChainPrereqProbes; } declare function runBootstrap({ mnemonic, environmentId, requireRecognized, _testApis, }: { mnemonic: string; environmentId: string; requireRecognized?: boolean; /** * Test-only: inject pre-built API objects and function overrides. * When set the real WS connections and environment lookup are skipped. */ _testApis?: RunBootstrapTestApis; }): Promise; export { type BootstrapResult, type BootstrapState, RecognizeRequiredError, type RunBootstrapTestApis, nextBootstrapAction, probeBootstrapState, runBootstrap };