Skip to content

Provide helper for resolving alias ID #143

Description

@PaulRBerg

From Claude's output in new-uI:

 Fix

 1. Create shared alias computation helper

 File: portal/lib/schema/stream-alias.ts (new)

 Helper that computes the stream alias from the contract address using the SDK:

 import { sablier } from "sablier";
 import { isEvmAddress } from "@/isomorphic/schema";

 export function computeStreamAlias(
   contract: string,
   chainId: number,
   tokenId: string,
   indexerAlias: string | null | undefined,
 ): string {
   // If the indexer provided a proper alias (not address-based), use it
   if (indexerAlias) {
     const source = indexerAlias.split("-")[0] ?? "";
     if (source && !isEvmAddress(source)) {
       return indexerAlias;
     }
   }

   // Compute alias from SDK
   const contractInfo = sablier.contracts.get({
     chainId,
     contractAddress: contract.toLowerCase(),
   });

   if (contractInfo?.alias) {
     return `${contractInfo.alias}-${chainId}-${tokenId}`;
   }

   // Fallback: address-based ID
   return `${contract.toLowerCase()}-${chainId}-${tokenId}`;
 }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions