Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 26 additions & 24 deletions typescript/create-onchain-agent/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import {
EVMNetwork,
Network,
SVMNetwork,
WalletProviderChoice,
AgentkitRouteConfiguration,
Framework,
Template,
} from "./types";

export const EVM_NETWORKS: EVMNetwork[] = [
import { AgentkitRouteConfiguration } from "./types";

export const EVM_NETWORKS = [
"base-mainnet",
"base-sepolia",
"ethereum-mainnet",
Expand All @@ -19,20 +11,26 @@ export const EVM_NETWORKS: EVMNetwork[] = [
"optimism-sepolia",
"polygon-mainnet",
"polygon-mumbai",
];
] as const;

export const SVM_NETWORKS: SVMNetwork[] = ["solana-mainnet", "solana-devnet", "solana-testnet"];
export type EVMNetwork = (typeof EVM_NETWORKS)[number];

const CDP_SUPPORTED_EVM_WALLET_PROVIDERS: WalletProviderChoice[] = [
"CDP",
"SmartWallet",
"Viem",
"Privy",
];
const SVM_WALLET_PROVIDERS: WalletProviderChoice[] = ["SolanaKeypair", "Privy"];
export const NON_CDP_SUPPORTED_EVM_WALLET_PROVIDERS: WalletProviderChoice[] = ["Viem", "Privy"];
export const SVM_NETWORKS = ["solana-mainnet", "solana-devnet", "solana-testnet"] as const;

export type SVMNetwork = (typeof SVM_NETWORKS)[number];

export type Network = EVMNetwork | SVMNetwork;

export const NetworkToWalletProviders: Record<Network, WalletProviderChoice[]> = {
const CDP_SUPPORTED_EVM_WALLET_PROVIDERS = ["CDP", "SmartWallet", "Viem", "Privy"] as const;
const SVM_WALLET_PROVIDERS = ["SolanaKeypair", "Privy"] as const;
export const NON_CDP_SUPPORTED_EVM_WALLET_PROVIDERS = ["Viem", "Privy"] as const;

export type WalletProviderChoice =
| (typeof CDP_SUPPORTED_EVM_WALLET_PROVIDERS)[number]
| (typeof SVM_WALLET_PROVIDERS)[number]
| (typeof NON_CDP_SUPPORTED_EVM_WALLET_PROVIDERS)[number];

export const NetworkToWalletProviders: Record<Network, readonly WalletProviderChoice[]> = {
"arbitrum-mainnet": CDP_SUPPORTED_EVM_WALLET_PROVIDERS,
"arbitrum-sepolia": NON_CDP_SUPPORTED_EVM_WALLET_PROVIDERS,
"base-mainnet": CDP_SUPPORTED_EVM_WALLET_PROVIDERS,
Expand Down Expand Up @@ -157,9 +155,13 @@ export const AgentkitRouteConfigurations: Record<
},
};

export const Frameworks: Framework[] = ["Langchain", "Vercel AI SDK"];
export const Frameworks = ["Langchain", "Vercel AI SDK"] as const;

export type Framework = (typeof Frameworks)[number];

export const Templates = ["next"] as const;

export const Templates: Template[] = ["next"];
export type Template = (typeof Templates)[number];

export const FrameworkToTemplates: Record<Framework, Template[]> = {
Langchain: ["next"],
Expand Down
29 changes: 9 additions & 20 deletions typescript/create-onchain-agent/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
export type EVMNetwork =
| "ethereum-mainnet"
| "ethereum-sepolia"
| "polygon-mainnet"
| "polygon-mumbai"
| "base-mainnet"
| "base-sepolia"
| "arbitrum-mainnet"
| "arbitrum-sepolia"
| "optimism-mainnet"
| "optimism-sepolia";

export type SVMNetwork = "solana-mainnet" | "solana-devnet" | "solana-testnet";

export type Network = EVMNetwork | SVMNetwork;

export type WalletProviderChoice = "CDP" | "Viem" | "Privy" | "SolanaKeypair" | "SmartWallet";
import { Network } from "./constants";

export type AgentkitRouteConfiguration = {
env: {
Expand All @@ -33,6 +17,11 @@ export type NetworkSelection = {
rpcUrl?: string;
};

export type Framework = "Langchain" | "Vercel AI SDK";

export type Template = "next";
export type {
EVMNetwork,
SVMNetwork,
Network,
WalletProviderChoice,
Framework,
Template,
} from "./constants";
2 changes: 1 addition & 1 deletion typescript/create-onchain-agent/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function detectPackageManager(): string {
* @param {Network} [network] - The optional network to get wallet providers for.
* @returns {WalletProviderChoice[]} An array of wallet providers for the specified network.
*/
export const getWalletProviders = (network?: Network): WalletProviderChoice[] => {
export const getWalletProviders = (network?: Network): readonly WalletProviderChoice[] => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed since const assertion marks values as readonly

if (network) {
return NetworkToWalletProviders[network];
}
Expand Down