From b51bfc338149840f05d1c7d51bb3251d7f61d34c Mon Sep 17 00:00:00 2001 From: MD JUBER QURAISHI Date: Thu, 26 Mar 2026 22:29:42 +0530 Subject: [PATCH 1/2] feat: define RoutingSource string literal union --- packages/core-ts/src/routing/types.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/core-ts/src/routing/types.ts b/packages/core-ts/src/routing/types.ts index bf6b5a3c..ae263c19 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 From d9d54efecd1f1e4c9f1a34fc4daca0d56fbee990 Mon Sep 17 00:00:00 2001 From: MD JUBER QURAISHI Date: Thu, 26 Mar 2026 23:01:30 +0530 Subject: [PATCH 2/2] fix: add contract-sender warning for C-address in extractRouting --- packages/core-ts/src/routing/extract.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/core-ts/src/routing/extract.ts b/packages/core-ts/src/routing/extract.ts index 029d55a1..7ae0a697 100644 --- a/packages/core-ts/src/routing/extract.ts +++ b/packages/core-ts/src/routing/extract.ts @@ -21,18 +21,20 @@ 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: [ - { - code: "INVALID_DESTINATION", - severity: "error", - message: "C address is not a valid destination", - context: { destinationKind: "C" }, - }, - ], + warnings, }; } @@ -99,17 +101,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" }, }); }