@n1xyz/wallet-widget 0.0.35-alpha.43 → 0.0.35-alpha.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,7 +46,6 @@ export declare const prepareBurnTx: (withdrawalId: string, params: {
46
46
  destinationAddress: string;
47
47
  }) => Promise<{
48
48
  tx: string;
49
- canonicalParams?: any;
50
49
  blockhash: string;
51
50
  lastValidBlockHeight: number;
52
51
  }>;
@@ -65,7 +64,6 @@ export declare const prepareClaimTx: (depositId: string, params: {
65
64
  lookupTableAddress?: string;
66
65
  }) => Promise<{
67
66
  tx: string;
68
- canonicalParams?: any;
69
67
  blockhash: string;
70
68
  lastValidBlockHeight: number;
71
69
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/features/onboarding-flow/bridge-assist/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAc3D,IAAM,QAAQ,GAAG,UAAC,KAAgC;IAChD,IAAM,CAAC,GAAG,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACtC,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,QAAQ,CAAC;IACrD,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,WAAW;QAAE,OAAO,kBAAkB,CAAC;IAC1F,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,kB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I,IAAI,EAAC;;;gBAE7B,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,eAAe,EAAE,kCAAkC,EAAE;oBACtF,KAAK,EAAE,OAAK,YAAY,KAAK,CAAC,CAAC,CAAC,OAAK,CAAC,CAAC,CAAC,SAAS;iBAClD,CAAC,CAAC,CAAC;gBACJ,4FAA4F;gBAC5F,iEAAiE;gBACjE,MAAM,IAAI,iBAAiB,CAAC,uCAAuC,EAAE,SAAS,CAAC,CAAC;;;;KAEnF,CAAA","sourcesContent":["import { BridgeAssistError } from './types';\nimport { getBridgeAssistConfig } from './config';\nimport { logger } from '../../../utils/logger';\nimport { createDepositError } from '../../../utils/errors';\nimport type { PendingDepositStage } from '../utils/deposit/storage';\n\nexport interface BridgeAssistStatus {\n stage: PendingDepositStage;\n tx?: string | null;\n reason?: string | null;\n bridgeTx?: string | null;\n solanaTx?: string | null;\n mintTx?: string | null;\n attestationId?: string | null;\n depositId?: string | null;\n}\n\nconst mapStage = (stage: string | null | undefined): PendingDepositStage => {\n const s = (stage ?? '').toLowerCase();\n if (s === 'failed' || s === 'error') return 'failed';\n if (s === 'confirmed' || s === 'complete' || s === 'completed') return 'solana_confirmed';\n if (s === 'submitted' || s === 'processing' || s === 'pending') return 'solana_submitted';\n // Fallback to initiated if unknown\n return 'initiated';\n};\n\nconst handleResponse = async (response: Response): Promise<any> => {\n if (!response.ok) {\n let errorMessage = response.statusText;\n let retryAfter: number | undefined;\n\n const retryHeader = response.headers.get('Retry-After');\n if (retryHeader) {\n retryAfter = parseInt(retryHeader, 10);\n }\n\n try {\n const errorBody = await response.json();\n if (errorBody.message) {\n errorMessage = errorBody.message;\n } else if (errorBody.error) {\n errorMessage = errorBody.error;\n } else if (Array.isArray(errorBody.errors) && errorBody.errors.length) {\n errorMessage = errorBody.errors.join(', ');\n }\n } catch {\n // ignore json parse error\n }\n throw new BridgeAssistError(errorMessage, response.status, retryAfter);\n }\n return response.json();\n};\n\nexport const createBridgeDeposit = async (\n params: {\n wallet: string;\n chain: string;\n solanaAddress: string;\n amount: string;\n bridgeTx: string;\n depositId?: string;\n attestationId?: string | null;\n }\n): Promise<BridgeAssistStatus | null> => {\n const config = getBridgeAssistConfig();\n if (!config) return null;\n try {\n const response = await fetch(`${config.baseUrl}/deposits`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params)\n });\n const body = await handleResponse(response);\n const stage = mapStage(body?.stage);\n return {\n stage,\n tx: body?.tx ?? body?.solanaTx ?? null,\n bridgeTx: body?.bridgeTx ?? params.bridgeTx ?? null,\n solanaTx: body?.solanaTx ?? body?.tx ?? null,\n attestationId: body?.attestationId ?? params.attestationId ?? null,\n depositId: body?.depositId ?? params.depositId ?? null,\n reason: body?.reason ?? null,\n };\n } catch (error) {\n logger.logError(createDepositError('BRIDGE_FAILED', 'Failed to create bridge deposit', {\n cause: error instanceof Error ? error : undefined,\n }));\n throw error;\n }\n}\n\nexport const fetchBridgeStatus = async (depositId: string): Promise<BridgeAssistStatus | null> => {\n const config = getBridgeAssistConfig();\n if (!config) return null;\n if (!depositId) return null;\n try {\n const response = await fetch(`${config.baseUrl}/deposits/${depositId}`, {\n method: 'GET',\n });\n if (response.status === 404) {\n return null;\n }\n const body = await handleResponse(response);\n const stage = mapStage(body?.stage);\n return {\n stage,\n tx: body?.solanaTx ?? body?.tx ?? null,\n bridgeTx: body?.bridgeTx ?? null,\n solanaTx: body?.solanaTx ?? null,\n mintTx: body?.mintTx ?? null,\n attestationId: body?.attestationId ?? null,\n depositId: body?.depositId ?? depositId,\n reason: body?.reason ?? null,\n };\n } catch (error) {\n logger.logError(createDepositError('BRIDGE_FAILED', 'Failed to fetch bridge status', {\n cause: error instanceof Error ? error : undefined,\n context: { depositId },\n }));\n throw error;\n }\n};\n\nexport const submitBridgeClaim = async (\n depositId: string,\n params: {\n solanaTx?: string;\n message?: string;\n attestation?: string;\n sourceChain?: string;\n destinationAddress?: string;\n blockhash?: string;\n lastValidBlockHeight?: number;\n lookupTableAddress?: string;\n userSignature?: string;\n txHash?: string;\n }\n): Promise<{\n tx?: string;\n requiresUserSignature?: boolean;\n stage?: string;\n blockhash?: string;\n lastValidBlockHeight?: number;\n lookupTableAddress?: string;\n signedTx?: string;\n} | null> => {\n const config = getBridgeAssistConfig();\n if (!config) return null;\n\n if (!depositId) throw new Error('Missing depositId for submitBridgeClaim');\n if (!params.message) throw new Error('Missing message for submitBridgeClaim');\n if (!params.attestation) throw new Error('Missing attestation for submitBridgeClaim');\n if (!params.sourceChain) throw new Error('Missing sourceChain for submitBridgeClaim');\n if (!params.destinationAddress) throw new Error('Missing destinationAddress for submitBridgeClaim');\n if (!params.userSignature) throw new Error('Missing userSignature for submitBridgeClaim');\n if (!params.txHash) throw new Error('Missing txHash (hash of signed tx) for submitBridgeClaim');\n\n try {\n // Single-request flow: always send full payload\n const payload = params;\n const url = `${config.baseUrl}/deposits/${depositId}/claim`;\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload)\n });\n return handleResponse(response);\n } catch (error) {\n logger.logError(createDepositError('CLAIM_FAILED', 'Failed to submit bridge claim', {\n cause: error instanceof Error ? error : undefined,\n context: { depositId },\n }));\n throw error;\n }\n}\n\nexport const prepareBurnTx = async (\n withdrawalId: string,\n params: {\n userAddress: string;\n amount: string;\n destinationChain: string;\n destinationAddress: string;\n }\n): Promise<{ tx: string; canonicalParams?: any; blockhash: string; lastValidBlockHeight: number }> => {\n const config = getBridgeAssistConfig();\n if (!config) throw new BridgeAssistError('Bridge Assist not configured');\n if (!withdrawalId) throw new Error('Missing withdrawalId for prepareBurnTx');\n\n try {\n const response = await fetch(`${config.baseUrl}/withdrawals/${withdrawalId}/prepare-burn`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n });\n return handleResponse(response);\n } catch (error) {\n logger.logError(createDepositError('BRIDGE_FAILED', 'Failed to prepare burn transaction', {\n cause: error instanceof Error ? error : undefined,\n context: { withdrawalId },\n }));\n throw error;\n }\n};\n\nexport const submitBurnTx = async (\n withdrawalId: string,\n params: {\n userSignature: string; // base64\n txHash: string; // hex\n }\n): Promise<{ burnTx: string; explorerUrl?: string }> => {\n const config = getBridgeAssistConfig();\n if (!config) throw new BridgeAssistError('Bridge Assist not configured');\n if (!withdrawalId) throw new Error('Missing withdrawalId for submitBurnTx');\n\n try {\n const response = await fetch(`${config.baseUrl}/withdrawals/${withdrawalId}/submit-burn`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n });\n return handleResponse(response);\n } catch (error) {\n logger.logError(createDepositError('BRIDGE_FAILED', 'Failed to submit burn transaction', {\n cause: error instanceof Error ? error : undefined,\n context: { withdrawalId },\n }));\n throw error;\n }\n};\n\nexport const prepareClaimTx = async (\n depositId: string,\n params: {\n message: string;\n attestation: string;\n sourceChain: string;\n destinationAddress: string;\n lookupTableAddress?: string;\n }\n): Promise<{ tx: string; canonicalParams?: any; blockhash: string; lastValidBlockHeight: number }> => {\n const config = getBridgeAssistConfig();\n if (!config) throw new BridgeAssistError('Bridge Assist not configured');\n if (!depositId) throw new Error('Missing depositId for prepareClaimTx');\n\n try {\n const response = await fetch(`${config.baseUrl}/deposits/${depositId}/prepare-claim`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n });\n return handleResponse(response);\n } catch (error) {\n logger.logError(createDepositError('CLAIM_FAILED', 'Failed to prepare claim transaction', {\n cause: error instanceof Error ? error : undefined,\n context: { depositId },\n }));\n throw error;\n }\n};\n\nexport const submitClaimTx = async (\n depositId: string,\n params: {\n userSignature: string;\n txHash: string;\n }\n): Promise<{ tx: string; stage?: string }> => {\n const config = getBridgeAssistConfig();\n if (!config) throw new BridgeAssistError('Bridge Assist not configured');\n if (!depositId) throw new Error('Missing depositId for submitClaimTx');\n\n try {\n const response = await fetch(`${config.baseUrl}/deposits/${depositId}/submit-claim`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n });\n return handleResponse(response);\n } catch (error) {\n logger.logError(createDepositError('CLAIM_FAILED', 'Failed to submit claim transaction', {\n cause: error instanceof Error ? error : undefined,\n context: { depositId },\n }));\n throw error;\n }\n};\n\nexport const reattestDeposit = async (depositId: string): Promise<boolean> => {\n const config = getBridgeAssistConfig();\n if (!config) return false;\n try {\n const response = await fetch(`${config.baseUrl}/deposits/${depositId}/reattest`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ depositId }),\n });\n return response.ok;\n } catch {\n return false;\n }\n};\n\nexport const fetchServerFeePayer = async (): Promise<string | null> => {\n const config = getBridgeAssistConfig();\n if (!config) return null;\n try {\n const response = await fetch(`${config.baseUrl}/health`, {\n method: 'GET',\n });\n const data = await handleResponse(response);\n return data.feePayer || null;\n } catch (error) {\n logger.logError(createDepositError('BRIDGE_FAILED', 'Failed to fetch server fee payer', {\n cause: error instanceof Error ? error : undefined,\n }));\n // Surface a clear, typed error for callers so UI can show \"server not available\" and retry.\n // Network/CORS failures typically land here with no HTTP status.\n throw new BridgeAssistError('Bridge Assist server is not available', undefined);\n }\n}\n\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/features/onboarding-flow/bridge-assist/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAc3D,IAAM,QAAQ,GAAG,UAAC,KAAgC;IAChD,IAAM,CAAC,GAAG,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,WAAW,EA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I,CAAC,MAAM;oBAAE,sBAAO,IAAI,EAAC;;;;gBAEN,qBAAM,KAAK,CAAC,UAAG,MAAM,CAAC,OAAO,YAAS,EAAE;wBACvD,MAAM,EAAE,KAAK;qBACd,CAAC,EAAA;;gBAFI,QAAQ,GAAG,SAEf;gBACW,qBAAM,cAAc,CAAC,QAAQ,CAAC,EAAA;;gBAArC,IAAI,GAAG,SAA8B;gBAC3C,sBAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAC;;;gBAE7B,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,eAAe,EAAE,kCAAkC,EAAE;oBACtF,KAAK,EAAE,OAAK,YAAY,KAAK,CAAC,CAAC,CAAC,OAAK,CAAC,CAAC,CAAC,SAAS;iBAClD,CAAC,CAAC,CAAC;gBACJ,4FAA4F;gBAC5F,iEAAiE;gBACjE,MAAM,IAAI,iBAAiB,CAAC,uCAAuC,EAAE,SAAS,CAAC,CAAC;;;;KAEnF,CAAA","sourcesContent":["import { BridgeAssistError } from './types';\nimport { getBridgeAssistConfig } from './config';\nimport { logger } from '../../../utils/logger';\nimport { createDepositError } from '../../../utils/errors';\nimport type { PendingDepositStage } from '../utils/deposit/storage';\n\nexport interface BridgeAssistStatus {\n stage: PendingDepositStage;\n tx?: string | null;\n reason?: string | null;\n bridgeTx?: string | null;\n solanaTx?: string | null;\n mintTx?: string | null;\n attestationId?: string | null;\n depositId?: string | null;\n}\n\nconst mapStage = (stage: string | null | undefined): PendingDepositStage => {\n const s = (stage ?? '').toLowerCase();\n if (s === 'failed' || s === 'error') return 'failed';\n if (s === 'confirmed' || s === 'complete' || s === 'completed') return 'solana_confirmed';\n if (s === 'submitted' || s === 'processing' || s === 'pending') return 'solana_submitted';\n // Fallback to initiated if unknown\n return 'initiated';\n};\n\nconst handleResponse = async (response: Response): Promise<any> => {\n if (!response.ok) {\n let errorMessage = response.statusText;\n let retryAfter: number | undefined;\n\n const retryHeader = response.headers.get('Retry-After');\n if (retryHeader) {\n retryAfter = parseInt(retryHeader, 10);\n }\n\n try {\n const errorBody = await response.json();\n if (errorBody.message) {\n errorMessage = errorBody.message;\n } else if (errorBody.error) {\n errorMessage = errorBody.error;\n } else if (Array.isArray(errorBody.errors) && errorBody.errors.length) {\n errorMessage = errorBody.errors.join(', ');\n }\n } catch {\n // ignore json parse error\n }\n throw new BridgeAssistError(errorMessage, response.status, retryAfter);\n }\n return response.json();\n};\n\nexport const createBridgeDeposit = async (\n params: {\n wallet: string;\n chain: string;\n solanaAddress: string;\n amount: string;\n bridgeTx: string;\n depositId?: string;\n attestationId?: string | null;\n }\n): Promise<BridgeAssistStatus | null> => {\n const config = getBridgeAssistConfig();\n if (!config) return null;\n try {\n const response = await fetch(`${config.baseUrl}/deposits`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params)\n });\n const body = await handleResponse(response);\n const stage = mapStage(body?.stage);\n return {\n stage,\n tx: body?.tx ?? body?.solanaTx ?? null,\n bridgeTx: body?.bridgeTx ?? params.bridgeTx ?? null,\n solanaTx: body?.solanaTx ?? body?.tx ?? null,\n attestationId: body?.attestationId ?? params.attestationId ?? null,\n depositId: body?.depositId ?? params.depositId ?? null,\n reason: body?.reason ?? null,\n };\n } catch (error) {\n logger.logError(createDepositError('BRIDGE_FAILED', 'Failed to create bridge deposit', {\n cause: error instanceof Error ? error : undefined,\n }));\n throw error;\n }\n}\n\nexport const fetchBridgeStatus = async (depositId: string): Promise<BridgeAssistStatus | null> => {\n const config = getBridgeAssistConfig();\n if (!config) return null;\n if (!depositId) return null;\n try {\n const response = await fetch(`${config.baseUrl}/deposits/${depositId}`, {\n method: 'GET',\n });\n if (response.status === 404) {\n return null;\n }\n const body = await handleResponse(response);\n const stage = mapStage(body?.stage);\n return {\n stage,\n tx: body?.solanaTx ?? body?.tx ?? null,\n bridgeTx: body?.bridgeTx ?? null,\n solanaTx: body?.solanaTx ?? null,\n mintTx: body?.mintTx ?? null,\n attestationId: body?.attestationId ?? null,\n depositId: body?.depositId ?? depositId,\n reason: body?.reason ?? null,\n };\n } catch (error) {\n logger.logError(createDepositError('BRIDGE_FAILED', 'Failed to fetch bridge status', {\n cause: error instanceof Error ? error : undefined,\n context: { depositId },\n }));\n throw error;\n }\n};\n\nexport const submitBridgeClaim = async (\n depositId: string,\n params: {\n solanaTx?: string;\n message?: string;\n attestation?: string;\n sourceChain?: string;\n destinationAddress?: string;\n blockhash?: string;\n lastValidBlockHeight?: number;\n lookupTableAddress?: string;\n userSignature?: string;\n txHash?: string;\n }\n): Promise<{\n tx?: string;\n requiresUserSignature?: boolean;\n stage?: string;\n blockhash?: string;\n lastValidBlockHeight?: number;\n lookupTableAddress?: string;\n signedTx?: string;\n} | null> => {\n const config = getBridgeAssistConfig();\n if (!config) return null;\n\n if (!depositId) throw new Error('Missing depositId for submitBridgeClaim');\n if (!params.message) throw new Error('Missing message for submitBridgeClaim');\n if (!params.attestation) throw new Error('Missing attestation for submitBridgeClaim');\n if (!params.sourceChain) throw new Error('Missing sourceChain for submitBridgeClaim');\n if (!params.destinationAddress) throw new Error('Missing destinationAddress for submitBridgeClaim');\n if (!params.userSignature) throw new Error('Missing userSignature for submitBridgeClaim');\n if (!params.txHash) throw new Error('Missing txHash (hash of signed tx) for submitBridgeClaim');\n\n try {\n // Single-request flow: always send full payload\n const payload = params;\n const url = `${config.baseUrl}/deposits/${depositId}/claim`;\n\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload)\n });\n return handleResponse(response);\n } catch (error) {\n logger.logError(createDepositError('CLAIM_FAILED', 'Failed to submit bridge claim', {\n cause: error instanceof Error ? error : undefined,\n context: { depositId },\n }));\n throw error;\n }\n}\n\nexport const prepareBurnTx = async (\n withdrawalId: string,\n params: {\n userAddress: string;\n amount: string;\n destinationChain: string;\n destinationAddress: string;\n }\n): Promise<{ tx: string; blockhash: string; lastValidBlockHeight: number }> => {\n const config = getBridgeAssistConfig();\n if (!config) throw new BridgeAssistError('Bridge Assist not configured');\n if (!withdrawalId) throw new Error('Missing withdrawalId for prepareBurnTx');\n\n try {\n const response = await fetch(`${config.baseUrl}/withdrawals/${withdrawalId}/prepare-burn`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n });\n return handleResponse(response);\n } catch (error) {\n logger.logError(createDepositError('BRIDGE_FAILED', 'Failed to prepare burn transaction', {\n cause: error instanceof Error ? error : undefined,\n context: { withdrawalId },\n }));\n throw error;\n }\n};\n\nexport const submitBurnTx = async (\n withdrawalId: string,\n params: {\n userSignature: string; // base64\n txHash: string; // hex\n }\n): Promise<{ burnTx: string; explorerUrl?: string }> => {\n const config = getBridgeAssistConfig();\n if (!config) throw new BridgeAssistError('Bridge Assist not configured');\n if (!withdrawalId) throw new Error('Missing withdrawalId for submitBurnTx');\n\n try {\n const response = await fetch(`${config.baseUrl}/withdrawals/${withdrawalId}/submit-burn`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n });\n return handleResponse(response);\n } catch (error) {\n logger.logError(createDepositError('BRIDGE_FAILED', 'Failed to submit burn transaction', {\n cause: error instanceof Error ? error : undefined,\n context: { withdrawalId },\n }));\n throw error;\n }\n};\n\nexport const prepareClaimTx = async (\n depositId: string,\n params: {\n message: string;\n attestation: string;\n sourceChain: string;\n destinationAddress: string;\n lookupTableAddress?: string;\n }\n): Promise<{ tx: string; blockhash: string; lastValidBlockHeight: number }> => {\n const config = getBridgeAssistConfig();\n if (!config) throw new BridgeAssistError('Bridge Assist not configured');\n if (!depositId) throw new Error('Missing depositId for prepareClaimTx');\n\n try {\n const response = await fetch(`${config.baseUrl}/deposits/${depositId}/prepare-claim`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n });\n return handleResponse(response);\n } catch (error) {\n logger.logError(createDepositError('CLAIM_FAILED', 'Failed to prepare claim transaction', {\n cause: error instanceof Error ? error : undefined,\n context: { depositId },\n }));\n throw error;\n }\n};\n\nexport const submitClaimTx = async (\n depositId: string,\n params: {\n userSignature: string;\n txHash: string;\n }\n): Promise<{ tx: string; stage?: string }> => {\n const config = getBridgeAssistConfig();\n if (!config) throw new BridgeAssistError('Bridge Assist not configured');\n if (!depositId) throw new Error('Missing depositId for submitClaimTx');\n\n try {\n const response = await fetch(`${config.baseUrl}/deposits/${depositId}/submit-claim`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(params),\n });\n return handleResponse(response);\n } catch (error) {\n logger.logError(createDepositError('CLAIM_FAILED', 'Failed to submit claim transaction', {\n cause: error instanceof Error ? error : undefined,\n context: { depositId },\n }));\n throw error;\n }\n};\n\nexport const reattestDeposit = async (depositId: string): Promise<boolean> => {\n const config = getBridgeAssistConfig();\n if (!config) return false;\n try {\n const response = await fetch(`${config.baseUrl}/deposits/${depositId}/reattest`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ depositId }),\n });\n return response.ok;\n } catch {\n return false;\n }\n};\n\nexport const fetchServerFeePayer = async (): Promise<string | null> => {\n const config = getBridgeAssistConfig();\n if (!config) return null;\n try {\n const response = await fetch(`${config.baseUrl}/health`, {\n method: 'GET',\n });\n const data = await handleResponse(response);\n return data.feePayer || null;\n } catch (error) {\n logger.logError(createDepositError('BRIDGE_FAILED', 'Failed to fetch server fee payer', {\n cause: error instanceof Error ? error : undefined,\n }));\n // Surface a clear, typed error for callers so UI can show \"server not available\" and retry.\n // Network/CORS failures typically land here with no HTTP status.\n throw new BridgeAssistError('Bridge Assist server is not available', undefined);\n }\n}\n\n"]}
@@ -1 +1,6 @@
1
- export { hashVersionedTransaction } from '@n1xyz/cctp-tx-builder';
1
+ import type { VersionedTransaction } from '@solana/web3.js';
2
+ /**
3
+ * Hashes a VersionedTransaction for signature verification.
4
+ * Local copy to avoid cross-package import that breaks tsc rootDir.
5
+ */
6
+ export declare const hashVersionedTransaction: (tx: VersionedTransaction) => string;
@@ -1,2 +1,11 @@
1
- export { hashVersionedTransaction } from '@n1xyz/cctp-tx-builder';
1
+ import { sha256 } from '@noble/hashes/sha2';
2
+ import { bytesToHex } from '@noble/hashes/utils';
3
+ /**
4
+ * Hashes a VersionedTransaction for signature verification.
5
+ * Local copy to avoid cross-package import that breaks tsc rootDir.
6
+ */
7
+ export var hashVersionedTransaction = function (tx) {
8
+ var serialized = tx.serialize();
9
+ return bytesToHex(sha256(serialized));
10
+ };
2
11
  //# sourceMappingURL=solanaClaim.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"solanaClaim.js","sourceRoot":"","sources":["../../../../src/features/onboarding-flow/cctp/solanaClaim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["export { hashVersionedTransaction } from '@n1xyz/cctp-tx-builder';\n"]}
1
+ {"version":3,"file":"solanaClaim.js","sourceRoot":"","sources":["../../../../src/features/onboarding-flow/cctp/solanaClaim.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,IAAM,wBAAwB,GAAG,UAAC,EAAwB;IAC/D,IAAM,UAAU,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;IAClC,OAAO,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import type { VersionedTransaction } from '@solana/web3.js';\nimport { sha256 } from '@noble/hashes/sha2';\nimport { bytesToHex } from '@noble/hashes/utils';\n\n/**\n * Hashes a VersionedTransaction for signature verification.\n * Local copy to avoid cross-package import that breaks tsc rootDir.\n */\nexport const hashVersionedTransaction = (tx: VersionedTransaction): string => {\n const serialized = tx.serialize();\n return bytesToHex(sha256(serialized));\n};\n"]}
@@ -134,11 +134,10 @@ var validateClaimTransaction = function (tx, destinationAddress) {
134
134
  }
135
135
  };
136
136
  var buildSignAndSubmitClaimTx = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
137
- var signer, prepared, tx, buildClaimTx, canonical, txBytes, userKey, preSignAccountKeys, numRequiredSigners, userSignerIndex, signed, accountKeys, sigIndex, sig, userSignatureBase64, txHash, submission;
138
- var _c;
137
+ var signer, prepared, txBytes, tx, userKey, preSignAccountKeys, numRequiredSigners, userSignerIndex, signed, accountKeys, sigIndex, sig, userSignatureBase64, txHash, submission;
139
138
  var depositId = _b.depositId, message = _b.message, attestation = _b.attestation, sourceChain = _b.sourceChain, destinationAddress = _b.destinationAddress, lookupTableAddress = _b.lookupTableAddress, solanaWallet = _b.solanaWallet;
140
- return __generator(this, function (_d) {
141
- switch (_d.label) {
139
+ return __generator(this, function (_c) {
140
+ switch (_c.label) {
142
141
  case 0:
143
142
  if (!lookupTableAddress) {
144
143
  throw new Error('CCTP lookup table not configured (NEXT_PUBLIC_CCTP_LOOKUP_TABLE_ADDRESS)');
@@ -152,7 +151,7 @@ var buildSignAndSubmitClaimTx = function (_a) { return __awaiter(void 0, [_a], v
152
151
  }
153
152
  return [4 /*yield*/, solanaWallet.getSigner()];
154
153
  case 1:
155
- signer = _d.sent();
154
+ signer = _c.sent();
156
155
  if (!(signer === null || signer === void 0 ? void 0 : signer.signTransaction)) {
157
156
  throw new Error('Connected wallet cannot sign transactions');
158
157
  }
@@ -164,28 +163,11 @@ var buildSignAndSubmitClaimTx = function (_a) { return __awaiter(void 0, [_a], v
164
163
  lookupTableAddress: lookupTableAddress,
165
164
  })];
166
165
  case 2:
167
- prepared = _d.sent();
168
- if (!prepared.canonicalParams) return [3 /*break*/, 4];
169
- return [4 /*yield*/, import('@n1xyz/cctp-tx-builder')];
170
- case 3:
171
- buildClaimTx = (_d.sent()).buildClaimTx;
172
- canonical = prepared.canonicalParams;
173
- // Validate canonical params match what the user expects
174
- if (canonical.destinationAddress !== destinationAddress) {
175
- throw new Error('Canonical params destination address mismatch');
176
- }
177
- if (((_c = canonical.sourceChain) === null || _c === void 0 ? void 0 : _c.toLowerCase()) !== sourceChain.toLowerCase()) {
178
- throw new Error('Canonical params source chain mismatch');
179
- }
180
- tx = buildClaimTx(canonical);
181
- return [3 /*break*/, 5];
182
- case 4:
166
+ prepared = _c.sent();
183
167
  txBytes = Buffer.from(prepared.tx, 'base64');
184
168
  tx = VersionedTransaction.deserialize(txBytes);
185
169
  // Validate the transaction only contains expected CCTP instructions and references USDC
186
170
  validateClaimTransaction(tx, destinationAddress);
187
- _d.label = 5;
188
- case 5:
189
171
  userKey = new PublicKey(destinationAddress);
190
172
  preSignAccountKeys = tx.message.staticAccountKeys;
191
173
  numRequiredSigners = tx.message.header.numRequiredSignatures;
@@ -194,8 +176,8 @@ var buildSignAndSubmitClaimTx = function (_a) { return __awaiter(void 0, [_a], v
194
176
  throw new Error('Server-provided transaction does not include the user wallet as a required signer');
195
177
  }
196
178
  return [4 /*yield*/, signer.signTransaction(tx)];
197
- case 6:
198
- signed = _d.sent();
179
+ case 3:
180
+ signed = _c.sent();
199
181
  if (!(signed instanceof VersionedTransaction)) {
200
182
  throw new Error('Lookup-table claims require a VersionedTransaction');
201
183
  }
@@ -214,8 +196,8 @@ var buildSignAndSubmitClaimTx = function (_a) { return __awaiter(void 0, [_a], v
214
196
  userSignature: userSignatureBase64,
215
197
  txHash: txHash,
216
198
  })];
217
- case 7:
218
- submission = _d.sent();
199
+ case 4:
200
+ submission = _c.sent();
219
201
  if (!(submission === null || submission === void 0 ? void 0 : submission.tx)) {
220
202
  throw new Error('Bridge Assist did not return a transaction signature');
221
203
  }
@@ -1 +1 @@
1
- {"version":3,"file":"claimSubmission.js","sourceRoot":"","sources":["../../../../../src/features/onboarding-flow/utils/deposit/claimSubmission.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO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AC,GAAG,IAAI,CAAC;wBAC7D,qBAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,KAAM,CAAC,CAAC,EAAA;;wBAA3D,SAA2D,CAAC;wBAC5D,UAAU,EAAE,CAAC;wBACN,qBAAM,aAAa,EAAE,EAAA;6BAA5B,sBAAO,SAAqB,EAAC,CAAC,qCAAqC;;oBAIvE,0CAA0C;oBAC1C,MAAM,OAAK,CAAC;;;;aAEf,CAAC;QAEF,sBAAO,aAAa,EAAE,EAAC;;KACxB,CAAC","sourcesContent":["import { Buffer } from 'buffer';\nimport { ComputeBudgetProgram, PublicKey, SystemProgram, VersionedTransaction } from '@solana/web3.js';\nimport { BridgeAssistError } from '../../bridge-assist/types';\nimport { createBridgeDeposit, prepareClaimTx, submitClaimTx } from '../../bridge-assist';\nimport { mapChainToBridgeKit } from '../../cctp/bridgeKitClient';\nimport { hashVersionedTransaction } from '../../cctp/solanaClaim';\nimport { delay } from './solanaUtils';\n\n// Well-known Solana program IDs used in CCTP claim transactions\nconst SPL_TOKEN_PROGRAM_ID = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';\nconst ASSOCIATED_TOKEN_PROGRAM_ID = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';\n\n/**\n * Validates that a server-provided claim transaction only contains expected CCTP\n * instructions. This prevents signing a malicious transaction if the Bridge Assist\n * server is compromised or misconfigured.\n *\n * Checks:\n * 1. Every instruction targets a program in the allowlist (CCTP v1/v2, ComputeBudget,\n * SPL Token, Associated Token Account). SystemProgram instructions are validated\n * individually to ensure the user is never the source of a SOL transfer.\n * 2. The Solana USDC mint address appears in the transaction's account keys\n */\nconst validateClaimTransaction = (tx: VersionedTransaction, destinationAddress: string): void => {\n const solanaChain = mapChainToBridgeKit('solana');\n const contracts = solanaChain.cctp?.contracts;\n if (!contracts) {\n throw new Error('Cannot validate claim transaction: CCTP contracts not found for Solana');\n }\n\n // Programs unconditionally allowed (purpose-specific, not exploitable for fund drain)\n const allowedProgramIds = new Set<string>([\n contracts.v1.messageTransmitter,\n contracts.v1.tokenMessenger,\n contracts.v2.messageTransmitter,\n contracts.v2.tokenMessenger,\n ComputeBudgetProgram.programId.toBase58(),\n SPL_TOKEN_PROGRAM_ID, // USDC fee transfer\n ASSOCIATED_TOKEN_PROGRAM_ID, // optional ATA creation\n ]);\n\n const systemProgramId = SystemProgram.programId.toBase58();\n const accountKeys = tx.message.staticAccountKeys;\n const userKey = new PublicKey(destinationAddress);\n\n // Check 1: All instruction program IDs must be in the allowlist.\n // SystemProgram is NOT blanket-allowed — each SystemProgram instruction is validated\n // individually to prevent a malicious SOL transfer from the user's wallet.\n const compiledInstructions = tx.message.compiledInstructions;\n for (const ix of compiledInstructions) {\n const programKey = accountKeys[ix.programIdIndex];\n if (!programKey) {\n throw new Error('Claim transaction contains an instruction with an invalid program ID index');\n }\n const programId = programKey.toBase58();\n\n if (programId === systemProgramId) {\n // Validate SystemProgram instructions: only allow transfer (discriminator = 2)\n // where the user is NOT the source. The legitimate use is a SOL rebate FROM\n // the fee payer TO the user.\n const data = Buffer.from(ix.data);\n if (data.length < 4) {\n throw new Error(\n 'Claim transaction contains a SystemProgram instruction with invalid data. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n const discriminator = data.readUInt32LE(0);\n // SystemProgram instruction types: 0=CreateAccount, 2=Transfer, 3=CreateAccountWithSeed, etc.\n if (discriminator !== 2) {\n throw new Error(\n `Claim transaction contains an unexpected SystemProgram instruction (type ${discriminator}). ` +\n 'Transaction rejected to protect your wallet.'\n );\n }\n // For SystemProgram::Transfer: account[0] = from (signer), account[1] = to\n // The 'from' must be a signer, so its index is always within staticAccountKeys.\n const fromAccountIndex = ix.accountKeyIndexes[0];\n const fromKey = fromAccountIndex < accountKeys.length ? accountKeys[fromAccountIndex] : null;\n if (fromKey && fromKey.equals(userKey)) {\n throw new Error(\n 'Claim transaction contains a SOL transfer from the user wallet. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n continue;\n }\n\n if (!allowedProgramIds.has(programId)) {\n throw new Error(\n `Claim transaction contains an unexpected program: ${programId}. ` +\n 'Transaction rejected to protect your wallet.'\n );\n }\n }\n\n // Check 2: USDC mint must appear in the transaction's account keys.\n // Skip when address lookup tables are used — the lookup table is controlled by us\n // (NEXT_PUBLIC_CCTP_LOOKUP_TABLE_ADDRESS), so accounts loaded from it are trusted.\n const usesLookupTable = tx.message.addressTableLookups.length > 0;\n if (!usesLookupTable) {\n const usdcMint = solanaChain.usdcAddress;\n if (!usdcMint) {\n throw new Error('Cannot validate claim transaction: USDC address not found for Solana');\n }\n const usdcKey = new PublicKey(usdcMint);\n const hasUsdcMint = accountKeys.some((k) => k.equals(usdcKey));\n if (!hasUsdcMint) {\n throw new Error(\n 'Claim transaction does not reference the expected USDC mint. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n }\n};\n\ntype SolanaWalletLike = {\n chain?: string;\n getSigner: () => Promise<{ signTransaction?: (tx: unknown) => Promise<unknown> } | null>;\n};\n\nexport interface SubmitClaimWithRetryParams {\n depositId: string;\n message: string;\n attestation: string;\n sourceChain: string;\n destinationAddress: string;\n lookupTableAddress: string;\n solanaWallet: SolanaWalletLike;\n fallbackWallet: string;\n fallbackAmount: string;\n bridgeTx: string;\n attestationId: string | null;\n}\n\nconst buildSignAndSubmitClaimTx = async ({\n depositId,\n message,\n attestation,\n sourceChain,\n destinationAddress,\n lookupTableAddress,\n solanaWallet,\n}: Omit<SubmitClaimWithRetryParams, 'fallbackWallet' | 'fallbackAmount' | 'bridgeTx' | 'attestationId'>): Promise<string> => {\n if (!lookupTableAddress) {\n throw new Error('CCTP lookup table not configured (NEXT_PUBLIC_CCTP_LOOKUP_TABLE_ADDRESS)');\n }\n if (!depositId) throw new Error('Missing deposit ID for claim transaction');\n if (!solanaWallet) throw new Error('Solana wallet not connected. Please connect your wallet to finish the claim.');\n if (solanaWallet.chain && solanaWallet.chain !== 'SOL') {\n throw new Error('Connected wallet is not a Solana wallet');\n }\n\n const signer = await solanaWallet.getSigner();\n if (!signer?.signTransaction) {\n throw new Error('Connected wallet cannot sign transactions');\n }\n\n // Phase 1: Server builds the unsigned claim tx and returns canonical params\n const prepared = await prepareClaimTx(depositId, {\n message,\n attestation,\n sourceChain,\n destinationAddress,\n lookupTableAddress,\n });\n\n let tx: VersionedTransaction;\n\n if (prepared.canonicalParams) {\n // Canonical rebuild path: build tx locally from canonical params.\n // The widget never signs raw bytes from the server.\n const { buildClaimTx } = await import('@n1xyz/cctp-tx-builder');\n const canonical = prepared.canonicalParams;\n\n // Validate canonical params match what the user expects\n if (canonical.destinationAddress !== destinationAddress) {\n throw new Error('Canonical params destination address mismatch');\n }\n if (canonical.sourceChain?.toLowerCase() !== sourceChain.toLowerCase()) {\n throw new Error('Canonical params source chain mismatch');\n }\n\n tx = buildClaimTx(canonical);\n } else {\n // Legacy fallback: server didn't return canonical params, use serialized tx\n // with allowlist validation (pre-canonical security model)\n const txBytes = Buffer.from(prepared.tx, 'base64');\n tx = VersionedTransaction.deserialize(txBytes);\n\n // Validate the transaction only contains expected CCTP instructions and references USDC\n validateClaimTransaction(tx, destinationAddress);\n }\n\n // Verify the user's public key is a REQUIRED signer (index < numRequiredSignatures)\n // before signing. This prevents signing a tx where the user is just a non-signer account.\n const userKey = new PublicKey(destinationAddress);\n const preSignAccountKeys = tx.message.staticAccountKeys;\n const numRequiredSigners = tx.message.header.numRequiredSignatures;\n const userSignerIndex = preSignAccountKeys.findIndex((k) => k.equals(userKey));\n if (userSignerIndex < 0 || userSignerIndex >= numRequiredSigners) {\n throw new Error('Server-provided transaction does not include the user wallet as a required signer');\n }\n\n // Phase 2: Client signs with wallet\n const signed = await signer.signTransaction(tx as any);\n if (!(signed instanceof VersionedTransaction)) {\n throw new Error('Lookup-table claims require a VersionedTransaction');\n }\n\n // Extract user signature (reuse userKey from pre-sign validation above)\n const accountKeys = signed.message.staticAccountKeys;\n const sigIndex = accountKeys.findIndex((k) => k.equals(userKey));\n if (sigIndex < 0) {\n throw new Error('User pubkey not found in transaction account keys');\n }\n const sig = signed.signatures[sigIndex];\n if (!sig) {\n throw new Error('User signature missing after signing');\n }\n\n const userSignatureBase64 = Buffer.from(sig).toString('base64');\n const txHash = hashVersionedTransaction(signed as any);\n\n // Phase 3: Server adds fee payer signature and broadcasts\n const submission = await submitClaimTx(depositId, {\n userSignature: userSignatureBase64,\n txHash,\n });\n\n if (!submission?.tx) {\n throw new Error('Bridge Assist did not return a transaction signature');\n }\n\n return submission.tx;\n};\n\n/**\n * Submits a claim to Bridge Assist. If the deposit does not exist on the server (404),\n * it will create it and retry once. Implements retry limits to prevent infinite loops.\n */\nexport const submitClaimWithRetry = async (params: SubmitClaimWithRetryParams): Promise<string> => {\n const MAX_RETRIES = 1;\n let retryCount = 0;\n\n const attemptSubmit = async (): Promise<string> => {\n try {\n return await buildSignAndSubmitClaimTx(params);\n } catch (error) {\n // Check if this is a BridgeAssistError by name (more reliable across module boundaries)\n const errorName = error instanceof Error ? error.name : 'unknown';\n const isBridgeAssistError = error instanceof BridgeAssistError || errorName === 'BridgeAssistError';\n const errorStatus = isBridgeAssistError ? (error as any).status : undefined;\n\n // Check for 404 first (deposit doesn't exist) - this takes precedence\n const is404Error = isBridgeAssistError && errorStatus === 404;\n if (is404Error) {\n if (retryCount >= MAX_RETRIES) {\n throw new Error('Max retries exceeded: Unable to create deposit on Bridge Assist server');\n }\n\n await createBridgeDeposit({\n wallet: params.fallbackWallet,\n chain: params.sourceChain,\n solanaAddress: params.destinationAddress,\n amount: params.fallbackAmount,\n bridgeTx: params.bridgeTx,\n depositId: params.depositId,\n attestationId: params.attestationId ?? undefined,\n });\n\n retryCount++;\n return await attemptSubmit(); // Recursive retry after creating deposit\n }\n\n // If Bridge Assist temporarily unavailable, retry once with backoff\n if (isBridgeAssistError) {\n const status = typeof errorStatus === 'number' ? errorStatus : undefined;\n if ((typeof status === 'number' && status >= 500) || status == null) {\n if (retryCount >= MAX_RETRIES) {\n throw error; // Re-throw original error if max retries exceeded\n }\n\n // Attempt to refresh attestation via reattest before retrying.\n // If the claim failed due to an expired attestation, this will trigger\n // Circle's reattest API. The retry's prepareClaimTx will then pick up\n // the fresh attestation via tryRehydrateAttestation on the server.\n try {\n const { reattestDeposit } = await import('../../bridge-assist/client');\n await reattestDeposit(params.depositId);\n } catch {\n // Non-fatal — retry anyway with existing attestation\n }\n\n const retryAfterMs = ((error as any).retryAfter ?? 3) * 1000;\n await delay(Math.min(Math.max(retryAfterMs, 1000), 15_000));\n retryCount++;\n return await attemptSubmit(); // Recursive retry after server error\n }\n }\n\n // For all other errors, throw immediately\n throw error;\n }\n };\n\n return attemptSubmit();\n};\n"]}
1
+ {"version":3,"file":"claimSubmission.js","sourceRoot":"","sources":["../../../../../src/features/onboarding-flow/utils/deposit/claimSubmission.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,gEAAgE;AAChE,IAAM,oBAAoB,GAAG,6CAA6C,CAAC;AAC3E,IAAM,2BAA2B,GAAG,8CAA8C,CAAC;AAEnF;;;;;;;;;;GAUG;AACH,IAAM,wBAAwB,GAAG,UAAC,EAAwB,EAAE,kBAA0B;;IACp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,eAAe,CAAC,MAAM,CAAC,SAAS,CAAC,EAAA;;wBAAvC,SAAuC,CAAC;;;;;;wBAKpC,YAAY,GAAG,CAAC,MAAC,OAAa,CAAC,UAAU,mCAAI,CAAC,CAAC,GAAG,IAAI,CAAC;wBAC7D,qBAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,KAAM,CAAC,CAAC,EAAA;;wBAA3D,SAA2D,CAAC;wBAC5D,UAAU,EAAE,CAAC;wBACN,qBAAM,aAAa,EAAE,EAAA;6BAA5B,sBAAO,SAAqB,EAAC,CAAC,qCAAqC;;oBAIvE,0CAA0C;oBAC1C,MAAM,OAAK,CAAC;;;;aAEf,CAAC;QAEF,sBAAO,aAAa,EAAE,EAAC;;KACxB,CAAC","sourcesContent":["import { Buffer } from 'buffer';\nimport { ComputeBudgetProgram, PublicKey, SystemProgram, VersionedTransaction } from '@solana/web3.js';\nimport { BridgeAssistError } from '../../bridge-assist/types';\nimport { createBridgeDeposit, prepareClaimTx, submitClaimTx } from '../../bridge-assist';\nimport { mapChainToBridgeKit } from '../../cctp/bridgeKitClient';\nimport { hashVersionedTransaction } from '../../cctp/solanaClaim';\nimport { delay } from './solanaUtils';\n\n// Well-known Solana program IDs used in CCTP claim transactions\nconst SPL_TOKEN_PROGRAM_ID = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';\nconst ASSOCIATED_TOKEN_PROGRAM_ID = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';\n\n/**\n * Validates that a server-provided claim transaction only contains expected CCTP\n * instructions. This prevents signing a malicious transaction if the Bridge Assist\n * server is compromised or misconfigured.\n *\n * Checks:\n * 1. Every instruction targets a program in the allowlist (CCTP v1/v2, ComputeBudget,\n * SPL Token, Associated Token Account). SystemProgram instructions are validated\n * individually to ensure the user is never the source of a SOL transfer.\n * 2. The Solana USDC mint address appears in the transaction's account keys\n */\nconst validateClaimTransaction = (tx: VersionedTransaction, destinationAddress: string): void => {\n const solanaChain = mapChainToBridgeKit('solana');\n const contracts = solanaChain.cctp?.contracts;\n if (!contracts) {\n throw new Error('Cannot validate claim transaction: CCTP contracts not found for Solana');\n }\n\n // Programs unconditionally allowed (purpose-specific, not exploitable for fund drain)\n const allowedProgramIds = new Set<string>([\n contracts.v1.messageTransmitter,\n contracts.v1.tokenMessenger,\n contracts.v2.messageTransmitter,\n contracts.v2.tokenMessenger,\n ComputeBudgetProgram.programId.toBase58(),\n SPL_TOKEN_PROGRAM_ID, // USDC fee transfer\n ASSOCIATED_TOKEN_PROGRAM_ID, // optional ATA creation\n ]);\n\n const systemProgramId = SystemProgram.programId.toBase58();\n const accountKeys = tx.message.staticAccountKeys;\n const userKey = new PublicKey(destinationAddress);\n\n // Check 1: All instruction program IDs must be in the allowlist.\n // SystemProgram is NOT blanket-allowed — each SystemProgram instruction is validated\n // individually to prevent a malicious SOL transfer from the user's wallet.\n const compiledInstructions = tx.message.compiledInstructions;\n for (const ix of compiledInstructions) {\n const programKey = accountKeys[ix.programIdIndex];\n if (!programKey) {\n throw new Error('Claim transaction contains an instruction with an invalid program ID index');\n }\n const programId = programKey.toBase58();\n\n if (programId === systemProgramId) {\n // Validate SystemProgram instructions: only allow transfer (discriminator = 2)\n // where the user is NOT the source. The legitimate use is a SOL rebate FROM\n // the fee payer TO the user.\n const data = Buffer.from(ix.data);\n if (data.length < 4) {\n throw new Error(\n 'Claim transaction contains a SystemProgram instruction with invalid data. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n const discriminator = data.readUInt32LE(0);\n // SystemProgram instruction types: 0=CreateAccount, 2=Transfer, 3=CreateAccountWithSeed, etc.\n if (discriminator !== 2) {\n throw new Error(\n `Claim transaction contains an unexpected SystemProgram instruction (type ${discriminator}). ` +\n 'Transaction rejected to protect your wallet.'\n );\n }\n // For SystemProgram::Transfer: account[0] = from (signer), account[1] = to\n // The 'from' must be a signer, so its index is always within staticAccountKeys.\n const fromAccountIndex = ix.accountKeyIndexes[0];\n const fromKey = fromAccountIndex < accountKeys.length ? accountKeys[fromAccountIndex] : null;\n if (fromKey && fromKey.equals(userKey)) {\n throw new Error(\n 'Claim transaction contains a SOL transfer from the user wallet. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n continue;\n }\n\n if (!allowedProgramIds.has(programId)) {\n throw new Error(\n `Claim transaction contains an unexpected program: ${programId}. ` +\n 'Transaction rejected to protect your wallet.'\n );\n }\n }\n\n // Check 2: USDC mint must appear in the transaction's account keys.\n // Skip when address lookup tables are used — the lookup table is controlled by us\n // (NEXT_PUBLIC_CCTP_LOOKUP_TABLE_ADDRESS), so accounts loaded from it are trusted.\n const usesLookupTable = tx.message.addressTableLookups.length > 0;\n if (!usesLookupTable) {\n const usdcMint = solanaChain.usdcAddress;\n if (!usdcMint) {\n throw new Error('Cannot validate claim transaction: USDC address not found for Solana');\n }\n const usdcKey = new PublicKey(usdcMint);\n const hasUsdcMint = accountKeys.some((k) => k.equals(usdcKey));\n if (!hasUsdcMint) {\n throw new Error(\n 'Claim transaction does not reference the expected USDC mint. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n }\n};\n\ntype SolanaWalletLike = {\n chain?: string;\n getSigner: () => Promise<{ signTransaction?: (tx: unknown) => Promise<unknown> } | null>;\n};\n\nexport interface SubmitClaimWithRetryParams {\n depositId: string;\n message: string;\n attestation: string;\n sourceChain: string;\n destinationAddress: string;\n lookupTableAddress: string;\n solanaWallet: SolanaWalletLike;\n fallbackWallet: string;\n fallbackAmount: string;\n bridgeTx: string;\n attestationId: string | null;\n}\n\nconst buildSignAndSubmitClaimTx = async ({\n depositId,\n message,\n attestation,\n sourceChain,\n destinationAddress,\n lookupTableAddress,\n solanaWallet,\n}: Omit<SubmitClaimWithRetryParams, 'fallbackWallet' | 'fallbackAmount' | 'bridgeTx' | 'attestationId'>): Promise<string> => {\n if (!lookupTableAddress) {\n throw new Error('CCTP lookup table not configured (NEXT_PUBLIC_CCTP_LOOKUP_TABLE_ADDRESS)');\n }\n if (!depositId) throw new Error('Missing deposit ID for claim transaction');\n if (!solanaWallet) throw new Error('Solana wallet not connected. Please connect your wallet to finish the claim.');\n if (solanaWallet.chain && solanaWallet.chain !== 'SOL') {\n throw new Error('Connected wallet is not a Solana wallet');\n }\n\n const signer = await solanaWallet.getSigner();\n if (!signer?.signTransaction) {\n throw new Error('Connected wallet cannot sign transactions');\n }\n\n // Phase 1: Server builds the unsigned claim tx\n const prepared = await prepareClaimTx(depositId, {\n message,\n attestation,\n sourceChain,\n destinationAddress,\n lookupTableAddress,\n });\n\n // Deserialize the unsigned tx from the server\n const txBytes = Buffer.from(prepared.tx, 'base64');\n const tx = VersionedTransaction.deserialize(txBytes);\n\n // Validate the transaction only contains expected CCTP instructions and references USDC\n validateClaimTransaction(tx, destinationAddress);\n\n // Verify the user's public key is a REQUIRED signer (index < numRequiredSignatures)\n // before signing. This prevents signing a tx where the user is just a non-signer account.\n const userKey = new PublicKey(destinationAddress);\n const preSignAccountKeys = tx.message.staticAccountKeys;\n const numRequiredSigners = tx.message.header.numRequiredSignatures;\n const userSignerIndex = preSignAccountKeys.findIndex((k) => k.equals(userKey));\n if (userSignerIndex < 0 || userSignerIndex >= numRequiredSigners) {\n throw new Error('Server-provided transaction does not include the user wallet as a required signer');\n }\n\n // Phase 2: Client signs with wallet\n const signed = await signer.signTransaction(tx as any);\n if (!(signed instanceof VersionedTransaction)) {\n throw new Error('Lookup-table claims require a VersionedTransaction');\n }\n\n // Extract user signature (reuse userKey from pre-sign validation above)\n const accountKeys = signed.message.staticAccountKeys;\n const sigIndex = accountKeys.findIndex((k) => k.equals(userKey));\n if (sigIndex < 0) {\n throw new Error('User pubkey not found in transaction account keys');\n }\n const sig = signed.signatures[sigIndex];\n if (!sig) {\n throw new Error('User signature missing after signing');\n }\n\n const userSignatureBase64 = Buffer.from(sig).toString('base64');\n const txHash = hashVersionedTransaction(signed as any);\n\n // Phase 3: Server adds fee payer signature and broadcasts\n const submission = await submitClaimTx(depositId, {\n userSignature: userSignatureBase64,\n txHash,\n });\n\n if (!submission?.tx) {\n throw new Error('Bridge Assist did not return a transaction signature');\n }\n\n return submission.tx;\n};\n\n/**\n * Submits a claim to Bridge Assist. If the deposit does not exist on the server (404),\n * it will create it and retry once. Implements retry limits to prevent infinite loops.\n */\nexport const submitClaimWithRetry = async (params: SubmitClaimWithRetryParams): Promise<string> => {\n const MAX_RETRIES = 1;\n let retryCount = 0;\n\n const attemptSubmit = async (): Promise<string> => {\n try {\n return await buildSignAndSubmitClaimTx(params);\n } catch (error) {\n // Check if this is a BridgeAssistError by name (more reliable across module boundaries)\n const errorName = error instanceof Error ? error.name : 'unknown';\n const isBridgeAssistError = error instanceof BridgeAssistError || errorName === 'BridgeAssistError';\n const errorStatus = isBridgeAssistError ? (error as any).status : undefined;\n\n // Check for 404 first (deposit doesn't exist) - this takes precedence\n const is404Error = isBridgeAssistError && errorStatus === 404;\n if (is404Error) {\n if (retryCount >= MAX_RETRIES) {\n throw new Error('Max retries exceeded: Unable to create deposit on Bridge Assist server');\n }\n\n await createBridgeDeposit({\n wallet: params.fallbackWallet,\n chain: params.sourceChain,\n solanaAddress: params.destinationAddress,\n amount: params.fallbackAmount,\n bridgeTx: params.bridgeTx,\n depositId: params.depositId,\n attestationId: params.attestationId ?? undefined,\n });\n\n retryCount++;\n return await attemptSubmit(); // Recursive retry after creating deposit\n }\n\n // If Bridge Assist temporarily unavailable, retry once with backoff\n if (isBridgeAssistError) {\n const status = typeof errorStatus === 'number' ? errorStatus : undefined;\n if ((typeof status === 'number' && status >= 500) || status == null) {\n if (retryCount >= MAX_RETRIES) {\n throw error; // Re-throw original error if max retries exceeded\n }\n\n // Attempt to refresh attestation via reattest before retrying.\n // If the claim failed due to an expired attestation, this will trigger\n // Circle's reattest API. The retry's prepareClaimTx will then pick up\n // the fresh attestation via tryRehydrateAttestation on the server.\n try {\n const { reattestDeposit } = await import('../../bridge-assist/client');\n await reattestDeposit(params.depositId);\n } catch {\n // Non-fatal — retry anyway with existing attestation\n }\n\n const retryAfterMs = ((error as any).retryAfter ?? 3) * 1000;\n await delay(Math.min(Math.max(retryAfterMs, 1000), 15_000));\n retryCount++;\n return await attemptSubmit(); // Recursive retry after server error\n }\n }\n\n // For all other errors, throw immediately\n throw error;\n }\n };\n\n return attemptSubmit();\n};\n"]}
@@ -162,10 +162,9 @@ var validateBurnTransaction = function (tx, params) {
162
162
  * This avoids the Turnkey wallet needing SOL for gas fees.
163
163
  */
164
164
  export var sponsoredBurnUsdcOnSolana = function (params) { return __awaiter(void 0, void 0, void 0, function () {
165
- var withdrawalId, amount, destinationChain, destinationAddress, solanaWallet, signer_1, _a, prepareBurnTx, submitBurnTx, hashVersionedTransaction, prepared, txToSign, buildBurnTx, canonical, txBytes, txAccountKeys, numRequiredSigners, userSignerIndex, signedTx, userKey_1, accountKeys, sigIndex, sig, userSignatureBase64, txHash, result, error_1, message;
166
- var _b, _c;
167
- return __generator(this, function (_d) {
168
- switch (_d.label) {
165
+ var withdrawalId, amount, destinationChain, destinationAddress, solanaWallet, signer_1, _a, prepareBurnTx, submitBurnTx, hashVersionedTransaction, prepared, txBytes, deserializedTx, txAccountKeys, numRequiredSigners, userSignerIndex, signedTx, userKey_1, accountKeys, sigIndex, sig, userSignatureBase64, txHash, result, error_1, message;
166
+ return __generator(this, function (_b) {
167
+ switch (_b.label) {
169
168
  case 0:
170
169
  withdrawalId = params.withdrawalId, amount = params.amount, destinationChain = params.destinationChain, destinationAddress = params.destinationAddress, solanaWallet = params.solanaWallet;
171
170
  logger.info('[SolanaBurn] Starting sponsored burn', {
@@ -175,9 +174,9 @@ export var sponsoredBurnUsdcOnSolana = function (params) { return __awaiter(void
175
174
  destinationAddress: destinationAddress,
176
175
  walletAddress: solanaWallet.address,
177
176
  });
178
- _d.label = 1;
177
+ _b.label = 1;
179
178
  case 1:
180
- _d.trys.push([1, 11, , 12]);
179
+ _b.trys.push([1, 8, , 9]);
181
180
  if (!amount || parseFloat(amount) <= 0) {
182
181
  throw new Error('Invalid burn amount');
183
182
  }
@@ -189,17 +188,17 @@ export var sponsoredBurnUsdcOnSolana = function (params) { return __awaiter(void
189
188
  }
190
189
  return [4 /*yield*/, solanaWallet.getSigner()];
191
190
  case 2:
192
- signer_1 = _d.sent();
191
+ signer_1 = _b.sent();
193
192
  if (!signer_1 || !signer_1.signTransaction) {
194
193
  throw new Error('Wallet does not support transaction signing');
195
194
  }
196
195
  logger.info('[SolanaBurn] Requesting server to prepare burn tx');
197
196
  return [4 /*yield*/, import('../../bridge-assist/client')];
198
197
  case 3:
199
- _a = _d.sent(), prepareBurnTx = _a.prepareBurnTx, submitBurnTx = _a.submitBurnTx;
198
+ _a = _b.sent(), prepareBurnTx = _a.prepareBurnTx, submitBurnTx = _a.submitBurnTx;
200
199
  return [4 /*yield*/, import('../../cctp/solanaClaim')];
201
200
  case 4:
202
- hashVersionedTransaction = (_d.sent()).hashVersionedTransaction;
201
+ hashVersionedTransaction = (_b.sent()).hashVersionedTransaction;
203
202
  return [4 /*yield*/, prepareBurnTx(withdrawalId, {
204
203
  userAddress: signer_1.publicKey.toBase58(),
205
204
  amount: amount,
@@ -207,55 +206,30 @@ export var sponsoredBurnUsdcOnSolana = function (params) { return __awaiter(void
207
206
  destinationAddress: destinationAddress,
208
207
  })];
209
208
  case 5:
210
- prepared = _d.sent();
209
+ prepared = _b.sent();
211
210
  logger.info('[SolanaBurn] Server prepared burn tx', {
212
211
  blockhash: prepared.blockhash,
213
212
  lastValidBlockHeight: prepared.lastValidBlockHeight,
214
- hasCanonicalParams: !!prepared.canonicalParams,
215
213
  });
216
- txToSign = void 0;
217
- if (!prepared.canonicalParams) return [3 /*break*/, 7];
218
- return [4 /*yield*/, import('@n1xyz/cctp-tx-builder')];
219
- case 6:
220
- buildBurnTx = (_d.sent()).buildBurnTx;
221
- canonical = prepared.canonicalParams;
222
- // Validate canonical params match what user requested
223
- if (String(canonical.amount) !== String(amount)) {
224
- throw new Error("Canonical params amount mismatch: server=".concat(canonical.amount, ", expected=").concat(amount));
225
- }
226
- if (((_b = canonical.destinationAddress) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== destinationAddress.toLowerCase()) {
227
- throw new Error('Canonical params destination address mismatch');
228
- }
229
- if (((_c = canonical.destinationChain) === null || _c === void 0 ? void 0 : _c.toLowerCase()) !== destinationChain.toLowerCase()) {
230
- throw new Error('Canonical params destination chain mismatch');
231
- }
232
- if (canonical.userAddress !== signer_1.publicKey.toBase58()) {
233
- throw new Error('Canonical params user address mismatch');
234
- }
235
- txToSign = buildBurnTx(canonical);
236
- logger.info('[SolanaBurn] Rebuilt burn tx from canonical params');
237
- return [3 /*break*/, 8];
238
- case 7:
239
214
  txBytes = Buffer.from(prepared.tx, 'base64');
240
- txToSign = VersionedTransaction.deserialize(txBytes);
241
- validateBurnTransaction(txToSign, {
215
+ deserializedTx = VersionedTransaction.deserialize(txBytes);
216
+ // Validate the transaction only contains expected CCTP burn instructions,
217
+ // references the correct USDC mint, and encodes the expected amount/destination/recipient
218
+ validateBurnTransaction(deserializedTx, {
242
219
  amount: amount,
243
220
  destinationChain: destinationChain,
244
221
  destinationAddress: destinationAddress,
245
222
  });
246
- logger.info('[SolanaBurn] Using legacy tx validation (no canonical params)');
247
- _d.label = 8;
248
- case 8:
249
- txAccountKeys = txToSign.message.staticAccountKeys;
250
- numRequiredSigners = txToSign.message.header.numRequiredSignatures;
223
+ txAccountKeys = deserializedTx.message.staticAccountKeys;
224
+ numRequiredSigners = deserializedTx.message.header.numRequiredSignatures;
251
225
  userSignerIndex = txAccountKeys.findIndex(function (k) { return k.equals(signer_1.publicKey); });
252
226
  if (userSignerIndex < 0 || userSignerIndex >= numRequiredSigners) {
253
- throw new Error('Transaction does not include the user wallet as a required signer');
227
+ throw new Error('Server-provided transaction does not include the user wallet as a required signer');
254
228
  }
255
229
  logger.info('[SolanaBurn] Signing with Turnkey wallet');
256
- return [4 /*yield*/, signer_1.signTransaction(txToSign)];
257
- case 9:
258
- signedTx = _d.sent();
230
+ return [4 /*yield*/, signer_1.signTransaction(deserializedTx)];
231
+ case 6:
232
+ signedTx = _b.sent();
259
233
  if (!(signedTx instanceof VersionedTransaction)) {
260
234
  throw new Error('Expected VersionedTransaction after signing');
261
235
  }
@@ -276,8 +250,8 @@ export var sponsoredBurnUsdcOnSolana = function (params) { return __awaiter(void
276
250
  userSignature: userSignatureBase64,
277
251
  txHash: txHash,
278
252
  })];
279
- case 10:
280
- result = _d.sent();
253
+ case 7:
254
+ result = _b.sent();
281
255
  logger.info('[SolanaBurn] Sponsored burn completed', {
282
256
  txHash: result.burnTx,
283
257
  explorerUrl: result.explorerUrl,
@@ -286,8 +260,8 @@ export var sponsoredBurnUsdcOnSolana = function (params) { return __awaiter(void
286
260
  txHash: result.burnTx,
287
261
  explorerUrl: result.explorerUrl,
288
262
  }];
289
- case 11:
290
- error_1 = _d.sent();
263
+ case 8:
264
+ error_1 = _b.sent();
291
265
  logger.error('[SolanaBurn] Sponsored burn failed', {
292
266
  error: error_1,
293
267
  errorMessage: error_1 instanceof Error ? error_1.message : String(error_1),
@@ -301,7 +275,7 @@ export var sponsoredBurnUsdcOnSolana = function (params) { return __awaiter(void
301
275
  cause: error_1 instanceof Error ? error_1 : undefined,
302
276
  context: { amount: amount, destinationChain: destinationChain, destinationAddress: destinationAddress },
303
277
  });
304
- case 12: return [2 /*return*/];
278
+ case 9: return [2 /*return*/];
305
279
  }
306
280
  });
307
281
  }); };
@@ -1 +1 @@
1
- {"version":3,"file":"solanaBurnUtils.js","sourceRoot":"","sources":["../../../../../src/features/onboarding-flow/utils/withdrawal/solanaBurnUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAe,oBAAoB,EAAE,MAAM,iBAA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ACzB,MAAM,IAAI,KAAK,CAAC,0CAAmC,SAAS,CAAE,CAAC,CAAC;QAClE,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,0CAA0C,EAAE;YACvD,KAAK,EAAE,SAAS;YAChB,MAAM,QAAA;SACP,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,+CAA+C,EAAE;YAC5D,KAAK,EAAE,SAAS;YAChB,KAAK,OAAA;SACN,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { Buffer } from 'buffer';\nimport { ComputeBudgetProgram, PublicKey, SystemProgram, Transaction, VersionedTransaction } from '@solana/web3.js';\nimport { logger } from '../../../../utils/logger';\nimport { createWithdrawalError } from './errors';\nimport { BridgeKitClient, getDomain, mapChainToBridgeKit } from '../../cctp/bridgeKitClient';\nimport {\n SOLANA_ATTESTATION_TIMEOUT_MS,\n SOLANA_ATTESTATION_RETRY_BACKOFF_MS,\n} from '../../constants/withdrawal';\n\n/**\n * Validates a server-provided burn transaction before the user signs it.\n * Prevents a compromised Bridge Assist server from tricking the user into\n * signing a malicious transaction (e.g., token drain, wrong recipient).\n *\n * Checks:\n * 1. All instruction program IDs are in the expected allowlist\n * 2. The Solana USDC mint appears in the transaction's account keys\n * 3. The burn instruction targets a CCTP TokenMessenger program\n * 4. The burn amount, destination domain, and mint recipient in instruction\n * data match what the user requested\n */\nconst validateBurnTransaction = (\n tx: VersionedTransaction,\n params: {\n amount: string;\n destinationChain: string;\n destinationAddress: string;\n }\n): void => {\n const solanaChain = mapChainToBridgeKit('solana');\n const contracts = solanaChain.cctp?.contracts;\n if (!contracts) {\n throw new Error('Cannot validate burn transaction: CCTP contracts not found for Solana');\n }\n\n // Build program ID allowlist from BridgeKit chain config + well-known Solana programs\n const allowedProgramIds = new Set<string>([\n contracts.v1.messageTransmitter,\n contracts.v1.tokenMessenger,\n contracts.v2.messageTransmitter,\n contracts.v2.tokenMessenger,\n ComputeBudgetProgram.programId.toBase58(),\n SystemProgram.programId.toBase58(),\n ]);\n\n const accountKeys = tx.message.staticAccountKeys;\n const compiledInstructions = tx.message.compiledInstructions;\n\n // Check 1: All instruction program IDs must be in the allowlist\n for (const ix of compiledInstructions) {\n const programKey = accountKeys[ix.programIdIndex];\n if (!programKey) {\n throw new Error('Burn transaction contains an instruction with an invalid program ID index');\n }\n const programId = programKey.toBase58();\n if (!allowedProgramIds.has(programId)) {\n throw new Error(\n `Burn transaction contains an unexpected program: ${programId}. ` +\n 'Transaction rejected to protect your wallet.'\n );\n }\n }\n\n // Check 2: USDC mint must appear in account keys\n const usdcMint = solanaChain.usdcAddress;\n if (!usdcMint) {\n throw new Error('Cannot validate burn transaction: USDC address not found for Solana');\n }\n const usdcKey = new PublicKey(usdcMint);\n if (!accountKeys.some((k) => k.equals(usdcKey))) {\n throw new Error(\n 'Burn transaction does not reference the expected USDC mint. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n\n // Check 3: Find the burn instruction (targeting CCTP TokenMessenger)\n const tokenMessengerIds = new Set<string>([\n contracts.v1.tokenMessenger,\n contracts.v2.tokenMessenger,\n ]);\n\n const burnIx = compiledInstructions.find((ix) => {\n const programKey = accountKeys[ix.programIdIndex];\n return programKey && tokenMessengerIds.has(programKey.toBase58());\n });\n\n if (!burnIx) {\n throw new Error(\n 'Burn transaction does not contain a CCTP TokenMessenger instruction. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n\n // Check 4: Validate instruction data encodes expected parameters\n // Layout: discriminator(8) + amount(8) + destDomain(4) + mintRecipient(32) + ...\n const data = Buffer.from(burnIx.data);\n if (data.length < 52) {\n throw new Error('Burn instruction data is too short to contain expected parameters');\n }\n\n // Validate amount (bytes 8-15, u64 LE)\n const expectedAmountBaseUnits = BigInt(Math.round(parseFloat(params.amount) * 1e6));\n // Read u64 LE manually for cross-environment compatibility\n const amountLo = data.readUInt32LE(8);\n const amountHi = data.readUInt32LE(12);\n // eslint-disable-next-line no-bitwise\n const txAmount = BigInt(amountLo) + (BigInt(amountHi) << BigInt(32));\n if (txAmount !== expectedAmountBaseUnits) {\n throw new Error(\n `Burn amount mismatch: transaction contains ${txAmount} base units, ` +\n `expected ${expectedAmountBaseUnits}. Transaction rejected to protect your wallet.`\n );\n }\n\n // Validate destination domain (bytes 16-19, u32 LE)\n const destChain = mapChainToBridgeKit(params.destinationChain);\n const expectedDomain = getDomain(destChain);\n if (expectedDomain === undefined) {\n throw new Error(`Cannot validate burn: no CCTP domain for chain \"${params.destinationChain}\"`);\n }\n const txDomain = data.readUInt32LE(16);\n if (txDomain !== expectedDomain) {\n throw new Error(\n `Burn destination domain mismatch: transaction targets domain ${txDomain}, ` +\n `expected ${expectedDomain}. Transaction rejected to protect your wallet.`\n );\n }\n\n // Validate mint recipient (bytes 20-51, 32 bytes = zero-padded EVM address)\n const txMintRecipient = data.subarray(20, 52);\n const evmHex = params.destinationAddress.replace(/^0x/i, '').toLowerCase();\n const expectedRecipientHex = '0'.repeat(24) + evmHex;\n const expectedRecipientBuf = Buffer.from(expectedRecipientHex, 'hex');\n if (!txMintRecipient.equals(expectedRecipientBuf)) {\n throw new Error(\n 'Burn recipient mismatch: transaction sends to a different address than expected. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n};\n\n/**\n * Parameters for burning USDC on Solana via CCTP\n */\nexport interface SolanaBurnParams {\n amount: string;\n destinationChain: string;\n destinationAddress: string;\n solanaWallet: {\n address?: string;\n chain?: string;\n getSigner: () => Promise<{\n signTransaction: <T extends Transaction | VersionedTransaction>(tx: T) => Promise<T>;\n publicKey: PublicKey;\n }>;\n };\n rpcUrl?: string;\n}\n\n/**\n * Result of burning USDC on Solana\n */\nexport interface SolanaBurnResult {\n txHash: string;\n attestationId?: string;\n explorerUrl?: string;\n}\n\n/**\n * Burns USDC on Solana using a server-sponsored transaction.\n * The server builds the CCTP depositForBurn tx, signs it with the fee payer and\n * message account keypair, then the Turnkey wallet adds the user signature.\n * Finally the fully-signed tx is submitted back to the server for broadcast.\n *\n * This avoids the Turnkey wallet needing SOL for gas fees.\n */\nexport const sponsoredBurnUsdcOnSolana = async (params: {\n withdrawalId: string;\n amount: string;\n destinationChain: string;\n destinationAddress: string;\n solanaWallet: SolanaBurnParams['solanaWallet'];\n}): Promise<SolanaBurnResult> => {\n const {\n withdrawalId,\n amount,\n destinationChain,\n destinationAddress,\n solanaWallet,\n } = params;\n\n logger.info('[SolanaBurn] Starting sponsored burn', {\n withdrawalId,\n amount,\n destinationChain,\n destinationAddress,\n walletAddress: solanaWallet.address,\n });\n\n try {\n if (!amount || parseFloat(amount) <= 0) {\n throw new Error('Invalid burn amount');\n }\n if (!destinationAddress) {\n throw new Error('Destination address is required');\n }\n if (!solanaWallet.address) {\n throw new Error('Solana wallet not connected');\n }\n\n // Get signer from wallet\n const signer = await solanaWallet.getSigner();\n if (!signer || !signer.signTransaction) {\n throw new Error('Wallet does not support transaction signing');\n }\n\n logger.info('[SolanaBurn] Requesting server to prepare burn tx');\n\n const { prepareBurnTx, submitBurnTx } = await import('../../bridge-assist/client');\n const { hashVersionedTransaction } = await import('../../cctp/solanaClaim');\n\n // Step 1: Get canonical params from server\n const prepared = await prepareBurnTx(withdrawalId, {\n userAddress: signer.publicKey.toBase58(),\n amount,\n destinationChain,\n destinationAddress,\n });\n\n logger.info('[SolanaBurn] Server prepared burn tx', {\n blockhash: prepared.blockhash,\n lastValidBlockHeight: prepared.lastValidBlockHeight,\n hasCanonicalParams: !!prepared.canonicalParams,\n });\n\n let txToSign: VersionedTransaction;\n\n if (prepared.canonicalParams) {\n // Canonical rebuild path: build tx locally from canonical params.\n // The widget never signs raw bytes from the server.\n const { buildBurnTx } = await import('@n1xyz/cctp-tx-builder');\n const canonical = prepared.canonicalParams;\n\n // Validate canonical params match what user requested\n if (String(canonical.amount) !== String(amount)) {\n throw new Error(`Canonical params amount mismatch: server=${canonical.amount}, expected=${amount}`);\n }\n if (canonical.destinationAddress?.toLowerCase() !== destinationAddress.toLowerCase()) {\n throw new Error('Canonical params destination address mismatch');\n }\n if (canonical.destinationChain?.toLowerCase() !== destinationChain.toLowerCase()) {\n throw new Error('Canonical params destination chain mismatch');\n }\n if (canonical.userAddress !== signer.publicKey.toBase58()) {\n throw new Error('Canonical params user address mismatch');\n }\n\n txToSign = buildBurnTx(canonical);\n logger.info('[SolanaBurn] Rebuilt burn tx from canonical params');\n } else {\n // Legacy fallback: server didn't return canonical params, use serialized tx\n // with allowlist validation (pre-canonical security model)\n const txBytes = Buffer.from(prepared.tx, 'base64');\n txToSign = VersionedTransaction.deserialize(txBytes);\n\n validateBurnTransaction(txToSign, {\n amount,\n destinationChain,\n destinationAddress,\n });\n logger.info('[SolanaBurn] Using legacy tx validation (no canonical params)');\n }\n\n // Verify the user's public key is a REQUIRED signer\n const txAccountKeys = txToSign.message.staticAccountKeys;\n const numRequiredSigners = txToSign.message.header.numRequiredSignatures;\n const userSignerIndex = txAccountKeys.findIndex((k) => k.equals(signer.publicKey));\n if (userSignerIndex < 0 || userSignerIndex >= numRequiredSigners) {\n throw new Error('Transaction does not include the user wallet as a required signer');\n }\n\n logger.info('[SolanaBurn] Signing with Turnkey wallet');\n const signedTx = await signer.signTransaction(txToSign);\n\n if (!(signedTx instanceof VersionedTransaction)) {\n throw new Error('Expected VersionedTransaction after signing');\n }\n\n // Step 3: Extract user signature from the signed tx (same pattern as claim flow).\n // Turnkey's signTransaction may clear other signatures, so we extract just\n // the user's signature and send it separately. The server adds all 3 signatures.\n const userKey = signer.publicKey;\n const accountKeys = signedTx.message.staticAccountKeys;\n const sigIndex = accountKeys.findIndex((k) => k.equals(userKey));\n if (sigIndex < 0) {\n throw new Error('User pubkey not found in transaction account keys');\n }\n const sig = signedTx.signatures[sigIndex];\n if (!sig || sig.every((b) => b === 0)) {\n throw new Error('User signature missing after signing');\n }\n\n const userSignatureBase64 = Buffer.from(sig).toString('base64');\n const txHash = hashVersionedTransaction(signedTx as any);\n\n logger.info('[SolanaBurn] Submitting user signature to server');\n const result = await submitBurnTx(withdrawalId, {\n userSignature: userSignatureBase64,\n txHash,\n });\n\n logger.info('[SolanaBurn] Sponsored burn completed', {\n txHash: result.burnTx,\n explorerUrl: result.explorerUrl,\n });\n\n return {\n txHash: result.burnTx,\n explorerUrl: result.explorerUrl,\n };\n } catch (error) {\n logger.error('[SolanaBurn] Sponsored burn failed', {\n error,\n errorMessage: error instanceof Error ? error.message : String(error),\n withdrawalId,\n amount,\n destinationChain,\n destinationAddress,\n });\n\n const message = error instanceof Error ? error.message : 'Failed to burn USDC on Solana';\n throw createWithdrawalError('BRIDGE_FAILED', message, {\n cause: error instanceof Error ? error : undefined,\n context: { amount, destinationChain, destinationAddress },\n });\n }\n};\n\n/**\n * Waits for CCTP attestation from Circle's Iris API\n *\n * @param txHash - Solana transaction hash\n * @param timeoutMs - Maximum time to wait for attestation (default: 120 seconds)\n * @param retryBackoffMs - Time between retry attempts (default: 5 seconds)\n * @returns Attestation data including signature and message\n */\nexport const waitForSolanaAttestation = async (\n txHash: string,\n timeoutMs: number = SOLANA_ATTESTATION_TIMEOUT_MS,\n retryBackoffMs: number = SOLANA_ATTESTATION_RETRY_BACKOFF_MS\n): Promise<{\n attestation: string;\n message: string;\n decodedMessage?: any;\n}> => {\n logger.info('[SolanaBurn] Waiting for attestation', {\n txHash,\n timeoutMs,\n retryBackoffMs,\n });\n\n const client = new BridgeKitClient();\n const startTime = Date.now();\n let attempt = 0;\n let lastError: unknown = null;\n\n while (Date.now() - startTime < timeoutMs) {\n attempt++;\n\n try {\n logger.debug('[SolanaBurn] Fetching attestation attempt', {\n attempt,\n elapsed: Date.now() - startTime,\n txHash,\n });\n\n // Use BridgeKitClient's getAttestation method\n const attestationData = await client.getAttestation(txHash, 'solana');\n\n if (attestationData && attestationData.attestation && attestationData.message) {\n logger.info('[SolanaBurn] Attestation received', {\n txHash,\n attempt,\n elapsed: Date.now() - startTime,\n hasDecodedMessage: !!attestationData.decodedMessage,\n });\n\n return attestationData;\n }\n\n logger.debug('[SolanaBurn] Attestation not ready yet', {\n attempt,\n hasData: !!attestationData,\n hasAttestation: !!attestationData?.attestation,\n hasMessage: !!attestationData?.message,\n });\n } catch (error) {\n lastError = error;\n logger.warn('[SolanaBurn] Error fetching attestation', {\n attempt,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n\n // Wait before next attempt\n await new Promise((resolve) => setTimeout(resolve, retryBackoffMs));\n }\n\n // Timeout reached\n const errorMessage = lastError instanceof Error\n ? lastError.message\n : lastError\n ? String(lastError)\n : 'unknown error';\n\n logger.error('[SolanaBurn] Attestation timeout', {\n txHash,\n elapsed: Date.now() - startTime,\n attempts: attempt,\n lastError: errorMessage,\n });\n\n throw new Error(`Attestation timeout after ${timeoutMs}ms (${errorMessage})`);\n};\n\n/**\n * Gets the CCTP domain for a destination chain\n */\nexport const getDestinationDomain = (chainName: string): number => {\n try {\n const chain = mapChainToBridgeKit(chainName);\n const domain = getDomain(chain);\n\n if (domain === undefined) {\n throw new Error(`No CCTP domain found for chain: ${chainName}`);\n }\n\n logger.debug('[SolanaBurn] Resolved destination domain', {\n chain: chainName,\n domain,\n });\n\n return domain;\n } catch (error) {\n logger.error('[SolanaBurn] Failed to get destination domain', {\n chain: chainName,\n error,\n });\n throw error;\n }\n};\n"]}
1
+ {"version":3,"file":"solanaBurnUtils.js","sourceRoot":"","sources":["../../../../../src/features/onboarding-flow/utils/withdrawal/solanaBurnUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAe,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACpH,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,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AAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,0CAAmC,SAAS,CAAE,CAAC,CAAC;QAClE,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,0CAA0C,EAAE;YACvD,KAAK,EAAE,SAAS;YAChB,MAAM,QAAA;SACP,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,+CAA+C,EAAE;YAC5D,KAAK,EAAE,SAAS;YAChB,KAAK,OAAA;SACN,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { Buffer } from 'buffer';\nimport { ComputeBudgetProgram, PublicKey, SystemProgram, Transaction, VersionedTransaction } from '@solana/web3.js';\nimport { logger } from '../../../../utils/logger';\nimport { createWithdrawalError } from './errors';\nimport { BridgeKitClient, getDomain, mapChainToBridgeKit } from '../../cctp/bridgeKitClient';\nimport {\n SOLANA_ATTESTATION_TIMEOUT_MS,\n SOLANA_ATTESTATION_RETRY_BACKOFF_MS,\n} from '../../constants/withdrawal';\n\n/**\n * Validates a server-provided burn transaction before the user signs it.\n * Prevents a compromised Bridge Assist server from tricking the user into\n * signing a malicious transaction (e.g., token drain, wrong recipient).\n *\n * Checks:\n * 1. All instruction program IDs are in the expected allowlist\n * 2. The Solana USDC mint appears in the transaction's account keys\n * 3. The burn instruction targets a CCTP TokenMessenger program\n * 4. The burn amount, destination domain, and mint recipient in instruction\n * data match what the user requested\n */\nconst validateBurnTransaction = (\n tx: VersionedTransaction,\n params: {\n amount: string;\n destinationChain: string;\n destinationAddress: string;\n }\n): void => {\n const solanaChain = mapChainToBridgeKit('solana');\n const contracts = solanaChain.cctp?.contracts;\n if (!contracts) {\n throw new Error('Cannot validate burn transaction: CCTP contracts not found for Solana');\n }\n\n // Build program ID allowlist from BridgeKit chain config + well-known Solana programs\n const allowedProgramIds = new Set<string>([\n contracts.v1.messageTransmitter,\n contracts.v1.tokenMessenger,\n contracts.v2.messageTransmitter,\n contracts.v2.tokenMessenger,\n ComputeBudgetProgram.programId.toBase58(),\n SystemProgram.programId.toBase58(),\n ]);\n\n const accountKeys = tx.message.staticAccountKeys;\n const compiledInstructions = tx.message.compiledInstructions;\n\n // Check 1: All instruction program IDs must be in the allowlist\n for (const ix of compiledInstructions) {\n const programKey = accountKeys[ix.programIdIndex];\n if (!programKey) {\n throw new Error('Burn transaction contains an instruction with an invalid program ID index');\n }\n const programId = programKey.toBase58();\n if (!allowedProgramIds.has(programId)) {\n throw new Error(\n `Burn transaction contains an unexpected program: ${programId}. ` +\n 'Transaction rejected to protect your wallet.'\n );\n }\n }\n\n // Check 2: USDC mint must appear in account keys\n const usdcMint = solanaChain.usdcAddress;\n if (!usdcMint) {\n throw new Error('Cannot validate burn transaction: USDC address not found for Solana');\n }\n const usdcKey = new PublicKey(usdcMint);\n if (!accountKeys.some((k) => k.equals(usdcKey))) {\n throw new Error(\n 'Burn transaction does not reference the expected USDC mint. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n\n // Check 3: Find the burn instruction (targeting CCTP TokenMessenger)\n const tokenMessengerIds = new Set<string>([\n contracts.v1.tokenMessenger,\n contracts.v2.tokenMessenger,\n ]);\n\n const burnIx = compiledInstructions.find((ix) => {\n const programKey = accountKeys[ix.programIdIndex];\n return programKey && tokenMessengerIds.has(programKey.toBase58());\n });\n\n if (!burnIx) {\n throw new Error(\n 'Burn transaction does not contain a CCTP TokenMessenger instruction. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n\n // Check 4: Validate instruction data encodes expected parameters\n // Layout: discriminator(8) + amount(8) + destDomain(4) + mintRecipient(32) + ...\n const data = Buffer.from(burnIx.data);\n if (data.length < 52) {\n throw new Error('Burn instruction data is too short to contain expected parameters');\n }\n\n // Validate amount (bytes 8-15, u64 LE)\n const expectedAmountBaseUnits = BigInt(Math.round(parseFloat(params.amount) * 1e6));\n // Read u64 LE manually for cross-environment compatibility\n const amountLo = data.readUInt32LE(8);\n const amountHi = data.readUInt32LE(12);\n // eslint-disable-next-line no-bitwise\n const txAmount = BigInt(amountLo) + (BigInt(amountHi) << BigInt(32));\n if (txAmount !== expectedAmountBaseUnits) {\n throw new Error(\n `Burn amount mismatch: transaction contains ${txAmount} base units, ` +\n `expected ${expectedAmountBaseUnits}. Transaction rejected to protect your wallet.`\n );\n }\n\n // Validate destination domain (bytes 16-19, u32 LE)\n const destChain = mapChainToBridgeKit(params.destinationChain);\n const expectedDomain = getDomain(destChain);\n if (expectedDomain === undefined) {\n throw new Error(`Cannot validate burn: no CCTP domain for chain \"${params.destinationChain}\"`);\n }\n const txDomain = data.readUInt32LE(16);\n if (txDomain !== expectedDomain) {\n throw new Error(\n `Burn destination domain mismatch: transaction targets domain ${txDomain}, ` +\n `expected ${expectedDomain}. Transaction rejected to protect your wallet.`\n );\n }\n\n // Validate mint recipient (bytes 20-51, 32 bytes = zero-padded EVM address)\n const txMintRecipient = data.subarray(20, 52);\n const evmHex = params.destinationAddress.replace(/^0x/i, '').toLowerCase();\n const expectedRecipientHex = '0'.repeat(24) + evmHex;\n const expectedRecipientBuf = Buffer.from(expectedRecipientHex, 'hex');\n if (!txMintRecipient.equals(expectedRecipientBuf)) {\n throw new Error(\n 'Burn recipient mismatch: transaction sends to a different address than expected. ' +\n 'Transaction rejected to protect your wallet.'\n );\n }\n};\n\n/**\n * Parameters for burning USDC on Solana via CCTP\n */\nexport interface SolanaBurnParams {\n amount: string;\n destinationChain: string;\n destinationAddress: string;\n solanaWallet: {\n address?: string;\n chain?: string;\n getSigner: () => Promise<{\n signTransaction: <T extends Transaction | VersionedTransaction>(tx: T) => Promise<T>;\n publicKey: PublicKey;\n }>;\n };\n rpcUrl?: string;\n}\n\n/**\n * Result of burning USDC on Solana\n */\nexport interface SolanaBurnResult {\n txHash: string;\n attestationId?: string;\n explorerUrl?: string;\n}\n\n/**\n * Burns USDC on Solana using a server-sponsored transaction.\n * The server builds the CCTP depositForBurn tx, signs it with the fee payer and\n * message account keypair, then the Turnkey wallet adds the user signature.\n * Finally the fully-signed tx is submitted back to the server for broadcast.\n *\n * This avoids the Turnkey wallet needing SOL for gas fees.\n */\nexport const sponsoredBurnUsdcOnSolana = async (params: {\n withdrawalId: string;\n amount: string;\n destinationChain: string;\n destinationAddress: string;\n solanaWallet: SolanaBurnParams['solanaWallet'];\n}): Promise<SolanaBurnResult> => {\n const {\n withdrawalId,\n amount,\n destinationChain,\n destinationAddress,\n solanaWallet,\n } = params;\n\n logger.info('[SolanaBurn] Starting sponsored burn', {\n withdrawalId,\n amount,\n destinationChain,\n destinationAddress,\n walletAddress: solanaWallet.address,\n });\n\n try {\n if (!amount || parseFloat(amount) <= 0) {\n throw new Error('Invalid burn amount');\n }\n if (!destinationAddress) {\n throw new Error('Destination address is required');\n }\n if (!solanaWallet.address) {\n throw new Error('Solana wallet not connected');\n }\n\n // Get signer from wallet\n const signer = await solanaWallet.getSigner();\n if (!signer || !signer.signTransaction) {\n throw new Error('Wallet does not support transaction signing');\n }\n\n logger.info('[SolanaBurn] Requesting server to prepare burn tx');\n\n const { prepareBurnTx, submitBurnTx } = await import('../../bridge-assist/client');\n const { hashVersionedTransaction } = await import('../../cctp/solanaClaim');\n\n // Step 1: Get unsigned tx from server\n const prepared = await prepareBurnTx(withdrawalId, {\n userAddress: signer.publicKey.toBase58(),\n amount,\n destinationChain,\n destinationAddress,\n });\n\n logger.info('[SolanaBurn] Server prepared burn tx', {\n blockhash: prepared.blockhash,\n lastValidBlockHeight: prepared.lastValidBlockHeight,\n });\n\n // Step 2: Deserialize and verify the server-provided transaction\n const txBytes = Buffer.from(prepared.tx, 'base64');\n const deserializedTx = VersionedTransaction.deserialize(txBytes);\n\n // Validate the transaction only contains expected CCTP burn instructions,\n // references the correct USDC mint, and encodes the expected amount/destination/recipient\n validateBurnTransaction(deserializedTx, {\n amount,\n destinationChain,\n destinationAddress,\n });\n\n // Verify the user's public key is a REQUIRED signer in the transaction\n // (index < numRequiredSignatures), not just present somewhere in the account list.\n const txAccountKeys = deserializedTx.message.staticAccountKeys;\n const numRequiredSigners = deserializedTx.message.header.numRequiredSignatures;\n const userSignerIndex = txAccountKeys.findIndex((k) => k.equals(signer.publicKey));\n if (userSignerIndex < 0 || userSignerIndex >= numRequiredSigners) {\n throw new Error('Server-provided transaction does not include the user wallet as a required signer');\n }\n\n logger.info('[SolanaBurn] Signing with Turnkey wallet');\n const signedTx = await signer.signTransaction(deserializedTx);\n\n if (!(signedTx instanceof VersionedTransaction)) {\n throw new Error('Expected VersionedTransaction after signing');\n }\n\n // Step 3: Extract user signature from the signed tx (same pattern as claim flow).\n // Turnkey's signTransaction may clear other signatures, so we extract just\n // the user's signature and send it separately. The server adds all 3 signatures.\n const userKey = signer.publicKey;\n const accountKeys = signedTx.message.staticAccountKeys;\n const sigIndex = accountKeys.findIndex((k) => k.equals(userKey));\n if (sigIndex < 0) {\n throw new Error('User pubkey not found in transaction account keys');\n }\n const sig = signedTx.signatures[sigIndex];\n if (!sig || sig.every((b) => b === 0)) {\n throw new Error('User signature missing after signing');\n }\n\n const userSignatureBase64 = Buffer.from(sig).toString('base64');\n const txHash = hashVersionedTransaction(signedTx as any);\n\n logger.info('[SolanaBurn] Submitting user signature to server');\n const result = await submitBurnTx(withdrawalId, {\n userSignature: userSignatureBase64,\n txHash,\n });\n\n logger.info('[SolanaBurn] Sponsored burn completed', {\n txHash: result.burnTx,\n explorerUrl: result.explorerUrl,\n });\n\n return {\n txHash: result.burnTx,\n explorerUrl: result.explorerUrl,\n };\n } catch (error) {\n logger.error('[SolanaBurn] Sponsored burn failed', {\n error,\n errorMessage: error instanceof Error ? error.message : String(error),\n withdrawalId,\n amount,\n destinationChain,\n destinationAddress,\n });\n\n const message = error instanceof Error ? error.message : 'Failed to burn USDC on Solana';\n throw createWithdrawalError('BRIDGE_FAILED', message, {\n cause: error instanceof Error ? error : undefined,\n context: { amount, destinationChain, destinationAddress },\n });\n }\n};\n\n/**\n * Waits for CCTP attestation from Circle's Iris API\n *\n * @param txHash - Solana transaction hash\n * @param timeoutMs - Maximum time to wait for attestation (default: 120 seconds)\n * @param retryBackoffMs - Time between retry attempts (default: 5 seconds)\n * @returns Attestation data including signature and message\n */\nexport const waitForSolanaAttestation = async (\n txHash: string,\n timeoutMs: number = SOLANA_ATTESTATION_TIMEOUT_MS,\n retryBackoffMs: number = SOLANA_ATTESTATION_RETRY_BACKOFF_MS\n): Promise<{\n attestation: string;\n message: string;\n decodedMessage?: any;\n}> => {\n logger.info('[SolanaBurn] Waiting for attestation', {\n txHash,\n timeoutMs,\n retryBackoffMs,\n });\n\n const client = new BridgeKitClient();\n const startTime = Date.now();\n let attempt = 0;\n let lastError: unknown = null;\n\n while (Date.now() - startTime < timeoutMs) {\n attempt++;\n\n try {\n logger.debug('[SolanaBurn] Fetching attestation attempt', {\n attempt,\n elapsed: Date.now() - startTime,\n txHash,\n });\n\n // Use BridgeKitClient's getAttestation method\n const attestationData = await client.getAttestation(txHash, 'solana');\n\n if (attestationData && attestationData.attestation && attestationData.message) {\n logger.info('[SolanaBurn] Attestation received', {\n txHash,\n attempt,\n elapsed: Date.now() - startTime,\n hasDecodedMessage: !!attestationData.decodedMessage,\n });\n\n return attestationData;\n }\n\n logger.debug('[SolanaBurn] Attestation not ready yet', {\n attempt,\n hasData: !!attestationData,\n hasAttestation: !!attestationData?.attestation,\n hasMessage: !!attestationData?.message,\n });\n } catch (error) {\n lastError = error;\n logger.warn('[SolanaBurn] Error fetching attestation', {\n attempt,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n\n // Wait before next attempt\n await new Promise((resolve) => setTimeout(resolve, retryBackoffMs));\n }\n\n // Timeout reached\n const errorMessage = lastError instanceof Error\n ? lastError.message\n : lastError\n ? String(lastError)\n : 'unknown error';\n\n logger.error('[SolanaBurn] Attestation timeout', {\n txHash,\n elapsed: Date.now() - startTime,\n attempts: attempt,\n lastError: errorMessage,\n });\n\n throw new Error(`Attestation timeout after ${timeoutMs}ms (${errorMessage})`);\n};\n\n/**\n * Gets the CCTP domain for a destination chain\n */\nexport const getDestinationDomain = (chainName: string): number => {\n try {\n const chain = mapChainToBridgeKit(chainName);\n const domain = getDomain(chain);\n\n if (domain === undefined) {\n throw new Error(`No CCTP domain found for chain: ${chainName}`);\n }\n\n logger.debug('[SolanaBurn] Resolved destination domain', {\n chain: chainName,\n domain,\n });\n\n return domain;\n } catch (error) {\n logger.error('[SolanaBurn] Failed to get destination domain', {\n chain: chainName,\n error,\n });\n throw error;\n }\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n1xyz/wallet-widget",
3
- "version": "0.0.35-alpha.43",
3
+ "version": "0.0.35-alpha.44",
4
4
  "description": "React wallet widget component for N1 applications",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",