Skip to content

Commit 84110f7

Browse files
committed
refactor: types
1 parent d9d4035 commit 84110f7

File tree

4 files changed

+75
-78
lines changed

4 files changed

+75
-78
lines changed

governance/xc_admin/packages/xc_admin_common/src/programs/core/core_functions.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
PublicKey,
33
TransactionInstruction,
44
AccountInfo,
5+
Connection,
56
} from "@solana/web3.js";
67
import {
78
AccountType,
@@ -31,13 +32,14 @@ import {
3132
DownloadablePriceAccount,
3233
DownloadableProduct,
3334
PriceRawConfig,
34-
ProductRawConfig,
3535
RawConfig,
3636
ValidationResult,
37-
CoreInstructionAccounts,
3837
GetConfigParams,
3938
ProgramType,
4039
} from "../types";
40+
import { Program } from "@coral-xyz/anchor";
41+
import { PythOracle } from "@pythnetwork/client/lib/anchor";
42+
import { MessageBuffer } from "message_buffer/idl/message_buffer";
4143

4244
/**
4345
* Maximum sizes for instruction data to fit into transactions
@@ -50,6 +52,22 @@ const MAX_SIZE_UPD_PRODUCT_INSTRUCTION_DATA = 403; // upd product has one accoun
5052
*/
5153
export type SymbolsSet = Set<string>;
5254

55+
export type CoreConfigParams = {
56+
accounts: Array<{ pubkey: PublicKey; account: AccountInfo<Buffer> }>;
57+
cluster: PythCluster;
58+
};
59+
60+
/**
61+
* Core program instruction accounts needed for generateInstructions
62+
*/
63+
export interface CoreInstructionAccounts {
64+
fundingAccount: PublicKey;
65+
pythProgramClient: Program<PythOracle>;
66+
messageBufferClient?: Program<MessageBuffer>;
67+
connection?: Connection;
68+
rawConfig: RawConfig;
69+
}
70+
5371
/**
5472
* Check if an instruction's data size is within limits
5573
*/

governance/xc_admin/packages/xc_admin_common/src/programs/lazer/lazer_functions.ts

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { PythCluster } from "@pythnetwork/client";
33
import {
44
ValidationResult,
55
DownloadableProduct,
6-
LazerInstructionAccounts,
7-
LazerConfig,
86
DownloadableConfig,
9-
LazerConfigParams,
107
GetConfigParams,
118
} from "../types";
129
import { ProgramType } from "../types";
@@ -18,6 +15,51 @@ const LAZER_PROGRAM_ID = new PublicKey(
1815
"pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt",
1916
);
2017

18+
/**
19+
* Lazer-specific configuration type
20+
* TODO: Change to actual Lazer config type
21+
*/
22+
export type LazerConfig = {
23+
programType: ProgramType.PYTH_LAZER;
24+
// Make cluster optional since Lazer might not be tied to a specific cluster
25+
cluster?: PythCluster;
26+
// More generic data source instead of Solana-specific accounts
27+
feeds: LazerFeed[];
28+
// Additional metadata that might be relevant for Lazer
29+
metadata?: Record<string, unknown>;
30+
};
31+
32+
/**
33+
* Parameters for getting Lazer configuration
34+
*/
35+
export type LazerConfigParams = {
36+
// Instead of requiring Solana accounts, allow any parameters needed
37+
endpoint?: string;
38+
network?: string;
39+
options?: Record<string, unknown>;
40+
};
41+
42+
/**
43+
* Lazer program instruction accounts needed for generateInstructions
44+
*/
45+
export interface LazerInstructionAccounts {
46+
fundingAccount: PublicKey;
47+
// Lazer-specific properties
48+
lazerProgramClient?: any; // Replace with proper type when available
49+
cluster: PythCluster;
50+
additionalAccounts?: Record<string, PublicKey>;
51+
}
52+
53+
/**
54+
* Lazer feed configuration
55+
* TODO: Change to actual Lazer feed type
56+
*/
57+
export type LazerFeed = {
58+
id: string;
59+
metadata: Record<string, string | number | boolean>;
60+
// Add other feed-specific properties as needed
61+
};
62+
2163
/**
2264
* Get the program address for the given cluster
2365
*

governance/xc_admin/packages/xc_admin_common/src/programs/program_registry.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ import { PythCluster } from "@pythnetwork/client";
33
import {
44
DownloadableConfig,
55
ProgramType,
6-
RawConfig,
7-
LazerConfig,
86
ProgramConfig,
97
GetConfigParams,
10-
LazerConfigParams,
118
ValidationResult,
129
} from "./types";
1310

governance/xc_admin/packages/xc_admin_common/src/programs/types.ts

Lines changed: 10 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
import { PublicKey } from "@solana/web3.js";
2+
import { PermissionData, Product } from "@pythnetwork/client";
13
import {
2-
AccountInfo,
3-
PublicKey,
4-
TransactionInstruction,
5-
} from "@solana/web3.js";
6-
import { PermissionData, Product, PythCluster } from "@pythnetwork/client";
7-
import { Connection } from "@solana/web3.js";
8-
import { Program } from "@coral-xyz/anchor";
9-
import { PythOracle } from "@pythnetwork/client/lib/anchor";
10-
import { MessageBuffer } from "message_buffer/idl/message_buffer";
4+
LazerConfig,
5+
LazerConfigParams,
6+
LazerInstructionAccounts,
7+
} from "./lazer/lazer_functions";
8+
import {
9+
CoreConfigParams,
10+
CoreInstructionAccounts,
11+
} from "./core/core_functions";
1112
/**
1213
* Represents the different Pyth programs supported by the application.
1314
*/
@@ -69,35 +70,6 @@ export type RawConfig = {
6970
permissionAccount?: PermissionData;
7071
};
7172

72-
export type CoreConfigParams = {
73-
accounts: Array<{ pubkey: PublicKey; account: AccountInfo<Buffer> }>;
74-
cluster: PythCluster;
75-
};
76-
77-
/**
78-
* Lazer-specific configuration type
79-
* TODO: Change to actual Lazer config type
80-
*/
81-
export type LazerConfig = {
82-
programType: ProgramType.PYTH_LAZER;
83-
// Make cluster optional since Lazer might not be tied to a specific cluster
84-
cluster?: PythCluster;
85-
// More generic data source instead of Solana-specific accounts
86-
feeds: LazerFeed[];
87-
// Additional metadata that might be relevant for Lazer
88-
metadata?: Record<string, unknown>;
89-
};
90-
91-
/**
92-
* Parameters for getting Lazer configuration
93-
*/
94-
export type LazerConfigParams = {
95-
// Instead of requiring Solana accounts, allow any parameters needed
96-
endpoint?: string;
97-
network?: string;
98-
options?: Record<string, unknown>;
99-
};
100-
10173
/**
10274
* Union type for configuration parameters that can vary by program type
10375
*/
@@ -107,16 +79,6 @@ export type GetConfigParams =
10779
} & CoreConfigParams)
10880
| ({ programType: ProgramType.PYTH_LAZER } & LazerConfigParams);
10981

110-
/**
111-
* Lazer feed configuration
112-
* TODO: Change to actual Lazer feed type
113-
*/
114-
export type LazerFeed = {
115-
id: string;
116-
metadata: Record<string, string | number | boolean>;
117-
// Add other feed-specific properties as needed
118-
};
119-
12082
/**
12183
* Type for downloadable price account configuration
12284
*/
@@ -147,28 +109,6 @@ export type DownloadableConfig = Record<string, DownloadableProduct>;
147109
*/
148110
export type ProgramConfig = RawConfig | LazerConfig;
149111

150-
/**
151-
* Core program instruction accounts needed for generateInstructions
152-
*/
153-
export interface CoreInstructionAccounts {
154-
fundingAccount: PublicKey;
155-
pythProgramClient: Program<PythOracle>;
156-
messageBufferClient?: Program<MessageBuffer>;
157-
connection?: Connection;
158-
rawConfig: RawConfig;
159-
}
160-
161-
/**
162-
* Lazer program instruction accounts needed for generateInstructions
163-
*/
164-
export interface LazerInstructionAccounts {
165-
fundingAccount: PublicKey;
166-
// Lazer-specific properties
167-
lazerProgramClient?: any; // Replace with proper type when available
168-
cluster: PythCluster;
169-
additionalAccounts?: Record<string, PublicKey>;
170-
}
171-
172112
/**
173113
* Union type for program instruction accounts
174114
*/

0 commit comments

Comments
 (0)