refactor: move Solana-Stacks token mapping to lowlevelUnstableInfos

- Move solanaTokenToStacksToken and stacksTokenToSolanaTokens from BroSDK to lowlevelUnstableInfos
- Follows the same pattern as EVM, Meta, and Tron token mapping functions
- Removes these functions from the stable SDK API and places them in the experimental API
- Improves API stability by making token mapping functions part of the unstable API

Generated with [Claude Code](https://claude.ai/claude-code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
Kyle Fang
2025-10-27 18:59:51 +08:00
parent e5938c840a
commit 4d999ed48a
3 changed files with 22 additions and 45 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@brotocol-xyz/bro-sdk",
"version": "0.5.1-solana.44",
"version": "0.5.1-solana.45",
"description": "Brotocol js SDK",
"packageManager": "pnpm@9.9.0",
"keywords": [

View File

@@ -121,10 +121,6 @@ import { SDKGlobalContext } from "./sdkUtils/types.internal"
import { DumpableCache, getCacheInside } from "./utils/DumpableCache"
import { isNotNull } from "./utils/typeHelpers"
import { SwapRoute } from "./utils/SwapRouteHelpers"
import {
solanaTokenToCorrespondingStacksToken,
solanaTokenFromCorrespondingStacksToken,
} from "./solanaUtils/peggingHelpers"
import { isSupportedTronRoute } from "./tronUtils/peggingHelpers"
import { isSupportedSolanaRoute } from "./solanaUtils/peggingHelpers"
import { getSolanaSupportedRoutes } from "./solanaUtils/getSolanaSupportedRoutes"
@@ -1185,46 +1181,7 @@ export class BroSDK {
return runesIdToRunesToken(this.sdkContext, chain, id)
}
/**
* This function retrieves the Stacks token ID corresponding to a given Solana token on a specific Solana chain.
* It queries the list of supported Solana tokens for the specified chain and returns the corresponding Stacks token.
*
* @param chain - The Solana chain to search in (must be a Solana chain like `solana-mainnet` or `solana-testnet`).
* @param token - The Solana token ID to look up.
*
* @returns A promise that resolves with the corresponding Stacks token ID if found,
* or `undefined` if the token is not supported or the chain is invalid.
*/
async solanaTokenToStacksToken(
chain: ChainId,
token: KnownTokenId.SolanaToken,
): Promise<undefined | KnownTokenId.StacksToken> {
if (!KnownChainId.isSolanaChain(chain)) return
return solanaTokenToCorrespondingStacksToken(this.sdkContext, chain, token)
}
/**
* This function retrieves all Solana tokens corresponding to a given Stacks token on a specific Solana chain.
* It queries the list of supported Solana tokens for the specified chain and returns all matching Solana tokens.
*
* @param chain - The Solana chain to search in (must be a Solana chain like `solana-mainnet` or `solana-testnet`).
* @param token - The Stacks token ID to look up.
*
* @returns A promise that resolves with an array of corresponding Solana token IDs if found,
* or an empty array if no matches are found or the chain is invalid.
*/
async stacksTokenToSolanaTokens(
chain: ChainId,
token: KnownTokenId.StacksToken,
): Promise<KnownTokenId.SolanaToken[]> {
if (!KnownChainId.isSolanaChain(chain)) return []
return solanaTokenFromCorrespondingStacksToken(
this.sdkContext,
chain,
token,
)
}
/**
* Retrieves the `KnownTokenId.SolanaToken` associated with a given Solana token address
* on a specific Solana blockchain.

View File

@@ -18,6 +18,10 @@ import {
tronTokenToCorrespondingStacksToken,
tronTokenFromCorrespondingStacksToken,
} from "./tronUtils/peggingHelpers"
import {
solanaTokenToCorrespondingStacksToken,
solanaTokenFromCorrespondingStacksToken,
} from "./solanaUtils/peggingHelpers"
import { KnownChainId, KnownTokenId } from "./utils/types/knownIds"
import { StacksContractAddress } from "./sdkUtils/types"
import { SDKGlobalContext } from "./sdkUtils/types.internal"
@@ -213,3 +217,19 @@ export const stacksTokenToTronTokens = async (
): Promise<KnownTokenId.TronToken[]> => {
return tronTokenFromCorrespondingStacksToken(getSDKContext(sdk), chain, token)
}
export const solanaTokenToStacksToken = async (
sdk: import("./BroSDK").BroSDK,
chain: KnownChainId.SolanaChain,
token: KnownTokenId.SolanaToken,
): Promise<undefined | KnownTokenId.StacksToken> => {
return solanaTokenToCorrespondingStacksToken(getSDKContext(sdk), chain, token)
}
export const stacksTokenToSolanaTokens = async (
sdk: import("./BroSDK").BroSDK,
chain: KnownChainId.SolanaChain,
token: KnownTokenId.StacksToken,
): Promise<KnownTokenId.SolanaToken[]> => {
return solanaTokenFromCorrespondingStacksToken(getSDKContext(sdk), chain, token)
}