mirror of
https://github.com/Brotocol-xyz/bro-sdk.git
synced 2026-04-30 12:21:57 +08:00
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:
@@ -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": [
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user