@ottocode/ai-sdk 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/auth.ts +4 -3
- package/src/balance.ts +4 -4
- package/src/catalog.ts +1497 -0
- package/src/index.ts +5 -1
- package/src/setu.ts +9 -4
- package/src/types.ts +1 -1
package/package.json
CHANGED
package/src/auth.ts
CHANGED
|
@@ -9,8 +9,8 @@ export interface WalletContext {
|
|
|
9
9
|
privateKeyBytes: Uint8Array;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export function createWalletContext(auth: SetuAuth): WalletContext {
|
|
13
|
-
const privateKeyBytes = bs58.decode(auth.privateKey);
|
|
12
|
+
export function createWalletContext(auth: Required<SetuAuth>): WalletContext {
|
|
13
|
+
const privateKeyBytes = bs58.decode(auth.privateKey!);
|
|
14
14
|
const keypair = Keypair.fromSecretKey(privateKeyBytes);
|
|
15
15
|
const walletAddress = keypair.publicKey.toBase58();
|
|
16
16
|
return { keypair, walletAddress, privateKeyBytes };
|
|
@@ -32,7 +32,8 @@ export function buildWalletHeaders(ctx: WalletContext): Record<string, string> {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export function getPublicKeyFromPrivate(privateKey
|
|
35
|
+
export function getPublicKeyFromPrivate(privateKey?: string): string | null {
|
|
36
|
+
if (!privateKey) return null;
|
|
36
37
|
try {
|
|
37
38
|
const privateKeyBytes = bs58.decode(privateKey);
|
|
38
39
|
const keypair = Keypair.fromSecretKey(privateKeyBytes);
|
package/src/balance.ts
CHANGED
|
@@ -13,11 +13,11 @@ function trimTrailingSlash(url: string) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export async function fetchBalance(
|
|
16
|
-
auth: SetuAuth
|
|
16
|
+
auth: Required<SetuAuth>,
|
|
17
17
|
baseURL?: string,
|
|
18
18
|
): Promise<BalanceResponse | null> {
|
|
19
19
|
try {
|
|
20
|
-
const privateKeyBytes = bs58.decode(auth.privateKey);
|
|
20
|
+
const privateKeyBytes = bs58.decode(auth.privateKey!);
|
|
21
21
|
const keypair = Keypair.fromSecretKey(privateKeyBytes);
|
|
22
22
|
const walletAddress = keypair.publicKey.toBase58();
|
|
23
23
|
const url = trimTrailingSlash(baseURL ?? DEFAULT_BASE_URL);
|
|
@@ -60,11 +60,11 @@ export async function fetchBalance(
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
export async function fetchWalletUsdcBalance(
|
|
63
|
-
auth: SetuAuth
|
|
63
|
+
auth: Required<SetuAuth>,
|
|
64
64
|
network: 'mainnet' | 'devnet' = 'mainnet',
|
|
65
65
|
): Promise<WalletUsdcBalance | null> {
|
|
66
66
|
try {
|
|
67
|
-
const privateKeyBytes = bs58.decode(auth.privateKey);
|
|
67
|
+
const privateKeyBytes = bs58.decode(auth.privateKey!);
|
|
68
68
|
const keypair = Keypair.fromSecretKey(privateKeyBytes);
|
|
69
69
|
const walletAddress = keypair.publicKey.toBase58();
|
|
70
70
|
const rpcUrl = network === 'devnet' ? 'https://api.devnet.solana.com' : DEFAULT_RPC_URL;
|