diff --git a/packages/core-ts/src/routing/extract.ts b/packages/core-ts/src/routing/extract.ts index ef68d85..deb0aa7 100644 --- a/packages/core-ts/src/routing/extract.ts +++ b/packages/core-ts/src/routing/extract.ts @@ -52,7 +52,25 @@ export function extractRouting(input: RoutingInput): RoutingResult { } if (parsed.kind === "C") { + + const warnings: Warning[] = [...parsed.warnings]; + + warnings.push({ + code: "CONTRACT_SENDER_DETECTED", + severity: "warn", + message: + "Contract address detected. Contract addresses cannot be used as transaction senders.", + }); + + return { + destinationBaseAccount: null, + routingId: null, + routingSource: "none", + warnings, + }; + throw new ExtractRoutingError("Contract addresses cannot be routed"); + } if (parsed.kind === "M") { @@ -118,17 +136,15 @@ export function extractRouting(input: RoutingInput): RoutingResult { } } else if (input.memoType === "hash" || input.memoType === "return") { warnings.push({ - code: "UNSUPPORTED_MEMO_TYPE", + code: "MEMO_TEXT_UNROUTABLE", severity: "warn", message: `Memo type ${input.memoType} is not supported for routing.`, - context: { memoType: input.memoType }, }); } else if (input.memoType !== "none") { warnings.push({ - code: "UNSUPPORTED_MEMO_TYPE", + code: "MEMO_TEXT_UNROUTABLE", severity: "warn", message: `Unrecognized memo type: ${input.memoType}`, - context: { memoType: "unknown" }, }); } diff --git a/packages/core-ts/src/routing/types.ts b/packages/core-ts/src/routing/types.ts index bf6b5a3..ae263c1 100644 --- a/packages/core-ts/src/routing/types.ts +++ b/packages/core-ts/src/routing/types.ts @@ -1,5 +1,7 @@ import { ErrorCode, Warning } from "../address/types"; +export type RoutingSource = "muxed" | "memo" | "none"; + export type RoutingInput = { destination: string; memoType: string; @@ -12,18 +14,14 @@ export type KnownMemoType = "none" | "id" | "text" | "hash" | "return"; export type RoutingResult = { destinationBaseAccount: string | null; routingId: string | null; // decimal uint64 string — spec level - routingSource: "muxed" | "memo" | "none"; + routingSource: RoutingSource; warnings: Warning[]; // WarningCode only, always destinationError?: { - // ErrorCode only, when destination unparseable code: ErrorCode; message: string; }; }; -/** - * Ergonomic helper for TypeScript callers to get a BigInt from the routingId string. - */ export function routingIdAsBigInt(routingId: string | null): bigint | null { return routingId ? BigInt(routingId) : null; -} +} \ No newline at end of file