depreceated issue

This commit is contained in:
aryan
2024-12-31 23:54:31 +05:30
parent e17e2138c4
commit f1e4fb21ac
26 changed files with 1622 additions and 1483 deletions

View File

@@ -67,6 +67,7 @@ import { BN } from "@coral-xyz/anchor";
* @property {Connection} connection - Solana RPC connection
* @property {Keypair} wallet - Wallet keypair for signing transactions
* @property {PublicKey} wallet_address - Public key of the wallet
* @property {Config} config - Configuration object
*/
export class SolanaAgentKit {
public connection: Connection;
@@ -74,15 +75,31 @@ export class SolanaAgentKit {
public wallet_address: PublicKey;
public config: Config;
/**
* @deprecated Using openai_api_key directly in constructor is deprecated.
* Please use the new constructor with Config object instead:
* @example
* const agent = new SolanaAgentKit(privateKey, rpcUrl, {
* OPENAI_API_KEY: 'your-key'
* });
*/
constructor(private_key: string, rpc_url: string, openai_api_key: string | null);
constructor(private_key: string, rpc_url: string, config: Config);
constructor(
private_key: string,
rpc_url = "https://api.mainnet-beta.solana.com",
config: Config,
rpc_url: string,
configOrKey: Config | string | null,
) {
this.connection = new Connection(rpc_url);
this.connection = new Connection(rpc_url || "https://api.mainnet-beta.solana.com");
this.wallet = Keypair.fromSecretKey(bs58.decode(private_key));
this.wallet_address = this.wallet.publicKey;
this.config = config;
// Handle both old and new patterns
if (typeof configOrKey === 'string' || configOrKey === null) {
this.config = { OPENAI_API_KEY: configOrKey || '' };
} else {
this.config = configOrKey;
}
}
// Tool methods