wait_for_wallet_ready
Poll a wallet until MPC key generation completes, checking every 2 seconds up to a configurable maximum wait time.
Instructions
Poll a wallet until its status becomes "ready" (MPC key generation complete). Polls every 2 seconds up to a configurable max wait time (default 30s).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| walletId | Yes | The wallet ID to poll | |
| maxWaitMs | No | Maximum time to wait in milliseconds (default 30000) |
Implementation Reference
- src/tools/wait-for-wallet.ts:24-77 (handler)The handler function implements the polling logic to check the status of a wallet until it is 'ready', 'error', or times out.
export async function handler(client: ParaClient, args: Record<string, unknown>) { const walletId = args.walletId as string; const maxWaitMs = (args.maxWaitMs as number) ?? 30_000; const pollIntervalMs = 2_000; const start = Date.now(); while (Date.now() - start < maxWaitMs) { const wallet = await client.requestWithRetry<Wallet>(`/v1/wallets/${walletId}`); if (wallet.status === 'ready') { return { content: [ { type: 'text' as const, text: JSON.stringify( { ...wallet, _note: 'Wallet is ready. You can now use sign_raw to sign data.' }, null, 2, ), }, ], }; } if (wallet.status === 'error') { return { content: [ { type: 'text' as const, text: JSON.stringify( { ...wallet, _note: 'Wallet creation failed. Try creating a new wallet.' }, null, 2, ), }, ], isError: true, }; } await new Promise((r) => setTimeout(r, pollIntervalMs)); } return { content: [ { type: 'text' as const, text: `Wallet ${walletId} did not become ready within ${maxWaitMs}ms. Current status is still "creating". You can call wait_for_wallet_ready again to keep polling.`, }, ], isError: true, }; } - src/tools/wait-for-wallet.ts:4-22 (schema)The definition object contains the name, description, and input schema for the 'wait_for_wallet_ready' tool.
export const definition = { name: 'wait_for_wallet_ready', description: 'Poll a wallet until its status becomes "ready" (MPC key generation complete). Polls every 2 seconds up to a configurable max wait time (default 30s).', inputSchema: { type: 'object' as const, properties: { walletId: { type: 'string', description: 'The wallet ID to poll', }, maxWaitMs: { type: 'number', description: 'Maximum time to wait in milliseconds (default 30000)', }, }, required: ['walletId'], }, };