-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
76 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import { z } from "zod"; | ||
import { splTokenSymbolSchema } from "./tokens"; | ||
|
||
export const getBalanceParametersSchema = z.object({ | ||
wallet: z.string().describe("The address to get the balance of"), | ||
export const getTokenMintAddressBySymbolParametersSchema = z.object({ | ||
symbol: splTokenSymbolSchema.describe("The symbol of the token to get the mint address of"), | ||
}); | ||
|
||
export const transferParametersSchema = z.object({ | ||
to: z.string().describe("The address to transfer the token to"), | ||
amount: z.string().describe("The amount of tokens to transfer"), | ||
export const getTokenBalanceByMintAddressParametersSchema = z.object({ | ||
walletAddress: z.string().describe("The address to get the balance of"), | ||
mintAddress: z.string().describe("The mint address of the token to get the balance of"), | ||
}); | ||
|
||
export const getTokenBalanceByMintAddressParametersSchema = getBalanceParametersSchema.extend({ | ||
mintAddress: z.string().describe("The mint address of the token to get the balance of"), | ||
export const transferTokenByMintAddressParametersSchema = z.object({ | ||
mintAddress: z.string().describe("The mint address of the token to transfer"), | ||
to: z.string().describe("The address to transfer the token to"), | ||
amount: z.string().describe("The amount of tokens to transfer"), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
typescript/packages/plugins/spl-token/src/utils/getTokenByMintAddress.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SPL_TOKENS, type SolanaNetwork } from "../tokens"; | ||
import { getTokensForNetwork } from "./getTokensForNetwork"; | ||
|
||
export function getTokenByMintAddress(mintAddress: string, network: SolanaNetwork) { | ||
const tokensForNetwork = getTokensForNetwork(network, SPL_TOKENS); | ||
const token = tokensForNetwork.find((token) => token.mintAddress === mintAddress); | ||
return token || null; | ||
} |
8 changes: 8 additions & 0 deletions
8
typescript/packages/plugins/spl-token/src/utils/getTokenMintAddressBySymbol.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SPL_TOKENS, type SolanaNetwork, type SplTokenSymbol } from "../tokens"; | ||
import { getTokensForNetwork } from "./getTokensForNetwork"; | ||
|
||
export function getTokenMintAddressBySymbol(symbol: SplTokenSymbol, network: SolanaNetwork) { | ||
const tokensForNetwork = getTokensForNetwork(network, SPL_TOKENS); | ||
const token = tokensForNetwork.find((token) => [token.symbol, token.symbol.toLowerCase()].includes(symbol)); | ||
return token?.mintAddress || null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters