@arcium-hq/reader 0.9.1 → 0.9.3

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.
@@ -0,0 +1,87 @@
1
+ import * as anchor from '@coral-xyz/anchor';
2
+ import { ArciumIdlType } from '@arcium-hq/client';
3
+ import { ClusterAccount, Connection, MXEAccount, PublicKey, ArxNodeAccount, ComputationAccount, ComputationDefinitionAccount, RecoveryClusterAccount, MxeRecoveryAccount } from './types.js';
4
+ /**
5
+ * Return all MXE account addresses.
6
+ * @param conn - Solana connection object.
7
+ * @returns Array of MXE account public keys.
8
+ */
9
+ export declare function getMXEAccAddresses(conn: Connection): Promise<PublicKey[]>;
10
+ /**
11
+ * Return all Cluster account addresses.
12
+ * @param conn - Solana connection object.
13
+ * @returns Array of Cluster account public keys.
14
+ */
15
+ export declare function getClusterAccAddresses(conn: Connection): Promise<PublicKey[]>;
16
+ /**
17
+ * Return all ArxNode account addresses.
18
+ * @param conn - Solana connection object.
19
+ * @returns Array of ArxNode account public keys.
20
+ */
21
+ export declare function getArxNodeAccAddresses(conn: Connection): Promise<PublicKey[]>;
22
+ /**
23
+ * Fetch and parse an MXE account.
24
+ *
25
+ * @param arciumProgram - Anchor program instance.
26
+ * @param address - Public key of the MXE account.
27
+ * @param commitment - RPC commitment level.
28
+ * @returns Parsed MXE account data.
29
+ *
30
+ * @example
31
+ * import { getArciumProgram, getMXEAccAddress, getMXEAccInfo } from '@arcium-hq/reader';
32
+ *
33
+ * const program = getArciumProgram(provider);
34
+ * const mxeAddress = getMXEAccAddress(mxeProgramId);
35
+ * const mxeAccount = await getMXEAccInfo(program, mxeAddress);
36
+ * console.log('MXE authority:', mxeAccount.authority?.toBase58());
37
+ */
38
+ export declare function getMXEAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<MXEAccount>;
39
+ /**
40
+ * Fetch and parse a Cluster account.
41
+ * @param arciumProgram - Anchor program instance.
42
+ * @param address - Public key of the Cluster account.
43
+ * @param commitment - RPC commitment level.
44
+ * @returns Parsed ClusterAccount data.
45
+ */
46
+ export declare function getClusterAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<ClusterAccount>;
47
+ /**
48
+ * Fetch and parse a recovery cluster account.
49
+ * @param arciumProgram - Anchor program instance.
50
+ * @param address - Public key of the recovery cluster account.
51
+ * @param commitment - RPC commitment level.
52
+ * @returns Parsed RecoveryClusterAccount data.
53
+ */
54
+ export declare function getRecoveryClusterAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<RecoveryClusterAccount>;
55
+ /**
56
+ * Fetch and parse an MxeRecovery account.
57
+ * @param arciumProgram - Anchor program instance.
58
+ * @param address - Public key of the MxeRecovery account.
59
+ * @param commitment - RPC commitment level.
60
+ * @returns Parsed MxeRecoveryAccount data.
61
+ */
62
+ export declare function getMxeRecoveryAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<MxeRecoveryAccount>;
63
+ /**
64
+ * Fetch and parse an ArxNode account.
65
+ * @param arciumProgram - Anchor program instance.
66
+ * @param address - Public key of the ArxNode account.
67
+ * @param commitment - RPC commitment level.
68
+ * @returns Parsed ArxNodeAccount data.
69
+ */
70
+ export declare function getArxNodeAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<ArxNodeAccount>;
71
+ /**
72
+ * Fetch and parse a ComputationDefinition account.
73
+ * @param arciumProgram - Anchor program instance.
74
+ * @param address - Public key of the ComputationDefinition account.
75
+ * @param commitment - RPC commitment level.
76
+ * @returns Parsed ComputationDefinitionAccount data.
77
+ */
78
+ export declare function getCompDefAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<ComputationDefinitionAccount>;
79
+ /**
80
+ * Fetch and parse a Computation account.
81
+ * @param arciumProgram - Anchor program instance.
82
+ * @param address - Public key of the Computation account.
83
+ * @param commitment - RPC commitment level.
84
+ * @returns Parsed ComputationAccount data.
85
+ */
86
+ export declare function getComputationAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<ComputationAccount>;
87
+ //# sourceMappingURL=accGetters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accGetters.d.ts","sourceRoot":"","sources":["../../src/accGetters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EACH,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,4BAA4B,EAC5B,sBAAsB,EACtB,kBAAkB,EACrB,MAAM,YAAY,CAAC;AAQpB;;;;GAIG;AACH,wBAAsB,kBAAkB,CACpC,IAAI,EAAE,UAAU,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CAEtB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CACxC,IAAI,EAAE,UAAU,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CAEtB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CACxC,IAAI,EAAE,UAAU,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CAEtB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,aAAa,CAC/B,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAC5C,OAAO,EAAE,SAAS,EAClB,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,GACpC,OAAO,CAAC,UAAU,CAAC,CAErB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACnC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAC5C,OAAO,EAAE,SAAS,EAClB,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,GACpC,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC3C,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAC5C,OAAO,EAAE,SAAS,EAClB,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAEjC;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACvC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAC5C,OAAO,EAAE,SAAS,EAClB,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,GACpC,OAAO,CAAC,kBAAkB,CAAC,CAE7B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACnC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAC5C,OAAO,EAAE,SAAS,EAClB,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,GACpC,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACnC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAC5C,OAAO,EAAE,SAAS,EAClB,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,GACpC,OAAO,CAAC,4BAA4B,CAAC,CAKvC;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACvC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAC5C,OAAO,EAAE,SAAS,EAClB,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,GACpC,OAAO,CAAC,kBAAkB,CAAC,CAE7B"}
@@ -0,0 +1,41 @@
1
+ import * as anchor from '@coral-xyz/anchor';
2
+ import { ArciumEventName, ArciumEventData, Connection, PublicKey } from './types.js';
3
+ /**
4
+ * Subscribe to computation events for an MXE program.
5
+ *
6
+ * Listens for queue, execute, and finalize events via Solana log subscriptions.
7
+ *
8
+ * @param conn - Solana connection object.
9
+ * @param mxeProgramId - Public key of the MXE program to monitor.
10
+ * @param callback - Handler called for each event with event data and event name.
11
+ * @returns Subscription ID for cleanup with {@link unsubscribeComputations}.
12
+ *
13
+ * @example
14
+ * const subId = await subscribeComputations(
15
+ * connection,
16
+ * mxeProgramId,
17
+ * (event, name) => {
18
+ * if (name === 'FinalizeComputationEvent') {
19
+ * console.log('Computation finalized:', event.computationOffset.toString());
20
+ * }
21
+ * },
22
+ * );
23
+ *
24
+ * // When done, clean up the subscription
25
+ * await unsubscribeComputations(connection, subId);
26
+ */
27
+ export declare function subscribeComputations(conn: Connection, mxeProgramId: PublicKey, callback: (event: ArciumEventData, name: ArciumEventName) => void): Promise<number>;
28
+ /**
29
+ * Unsubscribe from computation events.
30
+ * @param conn - Solana connection object.
31
+ * @param subscriptionId - Subscription ID returned by {@link subscribeComputations}.
32
+ */
33
+ export declare function unsubscribeComputations(conn: Connection, subscriptionId: number): Promise<void>;
34
+ /**
35
+ * Get the computation offset from a transaction.
36
+ * @param tx - Transaction to extract the computation offset from.
37
+ * @returns Computation offset if found, otherwise undefined.
38
+ * @throws Error if multiple computation offsets are found in the transaction.
39
+ */
40
+ export declare function getComputationOffset(tx: anchor.web3.VersionedTransactionResponse): anchor.BN | undefined;
41
+ //# sourceMappingURL=computationGetters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computationGetters.d.ts","sourceRoot":"","sources":["../../src/computationGetters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACH,eAAe,EACf,eAAe,EACf,UAAU,EACV,SAAS,EACZ,MAAM,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,qBAAqB,CACvC,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,SAAS,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,KAAK,IAAI,GAClE,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CACzC,IAAI,EAAE,UAAU,EAChB,cAAc,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,4BAA4B,GAC7C,MAAM,CAAC,EAAE,GAAG,SAAS,CAkBvB"}
@@ -0,0 +1,60 @@
1
+ import { ArciumIdlType } from '@arcium-hq/client';
2
+ import * as anchor from '@coral-xyz/anchor';
3
+ import { ArciumEventName, CallbackComputationIx, PublicKey, QueueComputationIx } from './types.js';
4
+ type ArciumArxNodeAccount = ArciumIdlType['accounts']['0'];
5
+ type ArciumClusterAccount = ArciumIdlType['accounts']['2'];
6
+ type ArciumMXEAccount = ArciumIdlType['accounts']['10'];
7
+ /**
8
+ * Prefix for program data logs in Solana transaction logs.
9
+ * @constant {string}
10
+ */
11
+ export declare const PROGRAM_DATA_PREFIX = "Program data: ";
12
+ /**
13
+ * Prefix for program log messages in Solana transaction logs.
14
+ * @constant {string}
15
+ */
16
+ export declare const PROGRAM_LOG_PREFIX = "Program log: ";
17
+ /**
18
+ * Valid Arcium event names for computation lifecycle tracking.
19
+ * @constant {ArciumEventName[]}
20
+ */
21
+ export declare const ARCIUM_EVENT_NAMES: ArciumEventName[];
22
+ /**
23
+ * Discriminator for the ArxNode account type. Used to filter and identify ArxNode accounts on-chain.
24
+ */
25
+ export declare const ARX_NODE_ACC_DISCRIMINATOR: ArciumArxNodeAccount['discriminator'];
26
+ /**
27
+ * Discriminator for the Cluster account type. Used to filter and identify Cluster accounts on-chain.
28
+ */
29
+ export declare const CLUSTER_ACC_DISCRIMINATOR: ArciumClusterAccount['discriminator'];
30
+ /**
31
+ * Discriminator for the MXE account type. Used to filter and identify MXE accounts on-chain.
32
+ */
33
+ export declare const MXE_ACC_DISCRIMINATOR: ArciumMXEAccount['discriminator'];
34
+ /**
35
+ * Discriminator for the queueComputation instruction. Used to identify the queueComputation instruction in transaction data.
36
+ */
37
+ export declare const QUEUE_COMPUTATION_IX_DISCRIMINATOR: QueueComputationIx['discriminator'];
38
+ /**
39
+ * Discriminator for the callbackComputation instruction. Used to identify the callbackComputation instruction in transaction data.
40
+ */
41
+ export declare const CALLBACK_COMPUTATION_IX_DISCRIMINATOR: CallbackComputationIx['discriminator'];
42
+ /**
43
+ * The public key of the deployed Arcium program on Solana.
44
+ */
45
+ export declare const ARCIUM_PROGRAM_ID: PublicKey;
46
+ /**
47
+ * Anchor coder for encoding and decoding Arcium program instructions.
48
+ */
49
+ export declare const ARCIUM_IX_CODER: anchor.BorshInstructionCoder;
50
+ /**
51
+ * Anchor event parser for parsing Arcium program events from transaction logs.
52
+ */
53
+ export declare const ARCIUM_EVENT_CODER: anchor.EventParser;
54
+ /**
55
+ * BorshCoder instance for decoding Arcium events.
56
+ * Used directly instead of accessing EventParser's private coder property.
57
+ */
58
+ export declare const ARCIUM_BORSH_CODER: anchor.BorshCoder<string, string>;
59
+ export {};
60
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA2B,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACH,eAAe,EAAE,qBAAqB,EAAE,SAAS,EAAE,kBAAkB,EACxE,MAAM,YAAY,CAAC;AAEpB,KAAK,oBAAoB,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC;AAC3D,KAAK,oBAAoB,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC;AAC3D,KAAK,gBAAgB,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,eAAe,EAK/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,oBAAoB,CAAC,eAAe,CAAwC,CAAC;AAEtH;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,oBAAoB,CAAC,eAAe,CAA0C,CAAC;AAEvH;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,gBAAgB,CAAC,eAAe,CAAyC,CAAC;AAE9G;;GAEG;AACH,eAAO,MAAM,kCAAkC,EAAE,kBAAkB,CAAC,eAAe,CAAwC,CAAC;AAE5H;;GAEG;AACH,eAAO,MAAM,qCAAqC,EAAE,qBAAqB,CAAC,eAAe,CAAuC,CAAC;AAEjI;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAkD,CAAC;AAEnF;;GAEG;AACH,eAAO,MAAM,eAAe,8BAA2E,CAAC;AAExG;;GAEG;AACH,eAAO,MAAM,kBAAkB,oBAA2G,CAAC;AAE3I;;;GAGG;AACH,eAAO,MAAM,kBAAkB,mCAAgE,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Read-only SDK for querying Arcium network state on Solana.
3
+ *
4
+ * Key exports:
5
+ * - {@link getMXEAccInfo}, {@link getClusterAccInfo} - Account getters
6
+ * - {@link subscribeComputations} - Event monitoring
7
+ * - Types for all Arcium accounts
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export { getClusterAccAddress, getArxNodeAccAddress, getMXEAccAddress, getArciumProgram, getComputationAccAddress, getMempoolAccAddress, getClockAccAddress, getFeePoolAccAddress, getExecutingPoolAccAddress, getCompDefAccAddress, getComputationsInMempool, getMempoolPriorityFeeStats, } from '@arcium-hq/client';
12
+ export * from './accGetters.js';
13
+ export * from './computationGetters.js';
14
+ export * from './types.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACH,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Shared type aliases and utility types for the Arcium program.
3
+ * Many types are derived from the Anchor-generated IDL and are used throughout the reader package.
4
+ */
5
+ import { ArciumIdlType } from '@arcium-hq/client';
6
+ import * as anchor from '@coral-xyz/anchor';
7
+ /**
8
+ * Solana PublicKey type alias for convenience.
9
+ */
10
+ export type PublicKey = anchor.web3.PublicKey;
11
+ /**
12
+ * Solana Connection type alias for convenience.
13
+ */
14
+ export type Connection = anchor.web3.Connection;
15
+ /**
16
+ * Anchor Program type alias with generic IDL support.
17
+ */
18
+ export type Program<T extends anchor.Idl> = anchor.Program<T>;
19
+ /**
20
+ * Arcium IDL types derived from the Arcium program interface.
21
+ */
22
+ export type ArciumTypes = anchor.IdlTypes<ArciumIdlType>;
23
+ /**
24
+ * All events emitted by the Arcium program, keyed by event name.
25
+ */
26
+ export type ArciumEvent = anchor.IdlEvents<ArciumIdlType>;
27
+ /**
28
+ * Capitalized event names, matching the format as emitted by the program.
29
+ */
30
+ export type ArciumEventName = Capitalize<keyof ArciumEvent>;
31
+ /**
32
+ * Data structure for any Arcium event, as parsed from logs.
33
+ */
34
+ export type ArciumEventData = ArciumEvent[keyof ArciumEvent];
35
+ /**
36
+ * MXE (Multi-party eXecution Environment) account data structure.
37
+ */
38
+ export type MXEAccount = ArciumTypes['mxeAccount'];
39
+ /**
40
+ * Cluster account data structure containing node information.
41
+ */
42
+ export type ClusterAccount = ArciumTypes['cluster'];
43
+ /**
44
+ * Recovery cluster account data structure containing recovery peers information.
45
+ */
46
+ export type RecoveryClusterAccount = ArciumTypes['recoveryClusterAccount'];
47
+ /**
48
+ * MXE recovery account data structure tracking key recovery session state.
49
+ */
50
+ export type MxeRecoveryAccount = ArciumTypes['mxeRecoveryAccount'];
51
+ /**
52
+ * ArxNode account data structure for individual computation nodes.
53
+ */
54
+ export type ArxNodeAccount = ArciumTypes['arxNode'];
55
+ /**
56
+ * Computation account data structure tracking computation state.
57
+ */
58
+ export type ComputationAccount = ArciumTypes['computationAccount'];
59
+ /**
60
+ * Reference to a computation in a mempool or executing pool.
61
+ */
62
+ export type ComputationReference = ArciumTypes['computationReference'];
63
+ /**
64
+ * Computation definition account containing circuit configuration.
65
+ */
66
+ export type ComputationDefinitionAccount = ArciumTypes['computationDefinitionAccount'];
67
+ /**
68
+ * Queue computation instruction type from the Arcium IDL.
69
+ */
70
+ export type QueueComputationIx = ArciumIdlType['instructions']['38'];
71
+ /**
72
+ * Callback computation instruction type from the Arcium IDL.
73
+ */
74
+ export type CallbackComputationIx = ArciumIdlType['instructions']['4'];
75
+ /**
76
+ * Valid instruction names from the Arcium IDL.
77
+ */
78
+ export type ArciumInstructionName = ArciumIdlType['instructions'][number]['name'];
79
+ /**
80
+ * Status values for a computation, as defined by the Arcium protocol.
81
+ */
82
+ export type ComputationStatus = 'queued' | 'executing' | 'executed' | 'finalized' | 'failed';
83
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,MAAM,WAAW,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,WAAW,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,wBAAwB,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,sBAAsB,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,WAAW,CAAC,8BAA8B,CAAC,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAElF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcium-hq/reader",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "Reader SDK for fetching onchain data for Arcium network programs",
5
5
  "author": "Arcium",
6
6
  "license": "GPL-3.0-only",
@@ -14,20 +14,21 @@
14
14
  "compile": "yarn bundle:cjs && yarn bundle:esm && yarn bundle:dts",
15
15
  "bundle:cjs": "node ../../node_modules/rollup/dist/bin/rollup --config config/rollup.config.cjs.js",
16
16
  "bundle:esm": "node ../../node_modules/rollup/dist/bin/rollup --config config/rollup.config.esm.js",
17
- "bundle:dts": "node ../../node_modules/rollup/dist/bin/rollup --config config/rollup.config.dts.js",
17
+ "bundle:dts": "tsc --emitDeclarationOnly",
18
18
  "test-single": "mocha $1 --exit"
19
19
  },
20
20
  "type": "module",
21
21
  "module": "build/index.mjs",
22
- "types": "build/index.d.ts",
22
+ "types": "build/types/index.d.ts",
23
23
  "files": [
24
24
  "build/index.cjs",
25
25
  "build/index.mjs",
26
- "build/index.d.ts"
26
+ "build/types/",
27
+ "src/"
27
28
  ],
28
29
  "exports": [
29
30
  {
30
- "types": "./build/index.d.ts",
31
+ "types": "./build/types/index.d.ts",
31
32
  "import": "./build/index.mjs",
32
33
  "require": "./build/index.cjs"
33
34
  }
@@ -49,7 +50,6 @@
49
50
  "eslint-plugin-import": "^2.31.0",
50
51
  "mocha": "^10.8.2",
51
52
  "rollup": "^4.24.0",
52
- "rollup-plugin-dts": "^6.1.1",
53
53
  "ts-node": "^10.9.2",
54
54
  "typescript": "^5.6.3",
55
55
  "typescript-eslint": "^8.15.0"
@@ -58,7 +58,7 @@
58
58
  "@coral-xyz/anchor": "^0.32.1",
59
59
  "@noble/curves": "^1.9.5",
60
60
  "@noble/hashes": "^1.7.1",
61
- "@arcium-hq/client": "0.9.1"
61
+ "@arcium-hq/client": "0.9.3"
62
62
  },
63
63
  "keywords": [
64
64
  "Cryptography",
@@ -0,0 +1,188 @@
1
+ import * as anchor from '@coral-xyz/anchor';
2
+ import { ArciumIdlType } from '@arcium-hq/client';
3
+ import {
4
+ ClusterAccount,
5
+ Connection,
6
+ MXEAccount,
7
+ PublicKey,
8
+ ArxNodeAccount,
9
+ ComputationAccount,
10
+ ComputationDefinitionAccount,
11
+ RecoveryClusterAccount,
12
+ MxeRecoveryAccount,
13
+ } from './types.js';
14
+ import {
15
+ ARCIUM_PROGRAM_ID,
16
+ ARX_NODE_ACC_DISCRIMINATOR,
17
+ CLUSTER_ACC_DISCRIMINATOR,
18
+ MXE_ACC_DISCRIMINATOR,
19
+ } from './constants.js';
20
+
21
+ /**
22
+ * Return all MXE account addresses.
23
+ * @param conn - Solana connection object.
24
+ * @returns Array of MXE account public keys.
25
+ */
26
+ export async function getMXEAccAddresses(
27
+ conn: Connection,
28
+ ): Promise<PublicKey[]> {
29
+ return getArciumAccPubkeys(conn, MXE_ACC_DISCRIMINATOR);
30
+ }
31
+
32
+ /**
33
+ * Return all Cluster account addresses.
34
+ * @param conn - Solana connection object.
35
+ * @returns Array of Cluster account public keys.
36
+ */
37
+ export async function getClusterAccAddresses(
38
+ conn: Connection,
39
+ ): Promise<PublicKey[]> {
40
+ return getArciumAccPubkeys(conn, CLUSTER_ACC_DISCRIMINATOR);
41
+ }
42
+
43
+ /**
44
+ * Return all ArxNode account addresses.
45
+ * @param conn - Solana connection object.
46
+ * @returns Array of ArxNode account public keys.
47
+ */
48
+ export async function getArxNodeAccAddresses(
49
+ conn: Connection,
50
+ ): Promise<PublicKey[]> {
51
+ return getArciumAccPubkeys(conn, ARX_NODE_ACC_DISCRIMINATOR);
52
+ }
53
+
54
+ /**
55
+ * Fetch and parse an MXE account.
56
+ *
57
+ * @param arciumProgram - Anchor program instance.
58
+ * @param address - Public key of the MXE account.
59
+ * @param commitment - RPC commitment level.
60
+ * @returns Parsed MXE account data.
61
+ *
62
+ * @example
63
+ * import { getArciumProgram, getMXEAccAddress, getMXEAccInfo } from '@arcium-hq/reader';
64
+ *
65
+ * const program = getArciumProgram(provider);
66
+ * const mxeAddress = getMXEAccAddress(mxeProgramId);
67
+ * const mxeAccount = await getMXEAccInfo(program, mxeAddress);
68
+ * console.log('MXE authority:', mxeAccount.authority?.toBase58());
69
+ */
70
+ export async function getMXEAccInfo(
71
+ arciumProgram: anchor.Program<ArciumIdlType>,
72
+ address: PublicKey,
73
+ commitment?: anchor.web3.Commitment,
74
+ ): Promise<MXEAccount> {
75
+ return arciumProgram.account.mxeAccount.fetch(address, commitment);
76
+ }
77
+
78
+ /**
79
+ * Fetch and parse a Cluster account.
80
+ * @param arciumProgram - Anchor program instance.
81
+ * @param address - Public key of the Cluster account.
82
+ * @param commitment - RPC commitment level.
83
+ * @returns Parsed ClusterAccount data.
84
+ */
85
+ export async function getClusterAccInfo(
86
+ arciumProgram: anchor.Program<ArciumIdlType>,
87
+ address: PublicKey,
88
+ commitment?: anchor.web3.Commitment,
89
+ ): Promise<ClusterAccount> {
90
+ return arciumProgram.account.cluster.fetch(address, commitment);
91
+ }
92
+
93
+ /**
94
+ * Fetch and parse a recovery cluster account.
95
+ * @param arciumProgram - Anchor program instance.
96
+ * @param address - Public key of the recovery cluster account.
97
+ * @param commitment - RPC commitment level.
98
+ * @returns Parsed RecoveryClusterAccount data.
99
+ */
100
+ export async function getRecoveryClusterAccInfo(
101
+ arciumProgram: anchor.Program<ArciumIdlType>,
102
+ address: PublicKey,
103
+ commitment?: anchor.web3.Commitment,
104
+ ): Promise<RecoveryClusterAccount> {
105
+ return arciumProgram.account.recoveryClusterAccount.fetch(address, commitment);
106
+ }
107
+
108
+ /**
109
+ * Fetch and parse an MxeRecovery account.
110
+ * @param arciumProgram - Anchor program instance.
111
+ * @param address - Public key of the MxeRecovery account.
112
+ * @param commitment - RPC commitment level.
113
+ * @returns Parsed MxeRecoveryAccount data.
114
+ */
115
+ export async function getMxeRecoveryAccInfo(
116
+ arciumProgram: anchor.Program<ArciumIdlType>,
117
+ address: PublicKey,
118
+ commitment?: anchor.web3.Commitment,
119
+ ): Promise<MxeRecoveryAccount> {
120
+ return arciumProgram.account.mxeRecoveryAccount.fetch(address, commitment);
121
+ }
122
+
123
+ /**
124
+ * Fetch and parse an ArxNode account.
125
+ * @param arciumProgram - Anchor program instance.
126
+ * @param address - Public key of the ArxNode account.
127
+ * @param commitment - RPC commitment level.
128
+ * @returns Parsed ArxNodeAccount data.
129
+ */
130
+ export async function getArxNodeAccInfo(
131
+ arciumProgram: anchor.Program<ArciumIdlType>,
132
+ address: PublicKey,
133
+ commitment?: anchor.web3.Commitment,
134
+ ): Promise<ArxNodeAccount> {
135
+ return arciumProgram.account.arxNode.fetch(address, commitment);
136
+ }
137
+
138
+ /**
139
+ * Fetch and parse a ComputationDefinition account.
140
+ * @param arciumProgram - Anchor program instance.
141
+ * @param address - Public key of the ComputationDefinition account.
142
+ * @param commitment - RPC commitment level.
143
+ * @returns Parsed ComputationDefinitionAccount data.
144
+ */
145
+ export async function getCompDefAccInfo(
146
+ arciumProgram: anchor.Program<ArciumIdlType>,
147
+ address: PublicKey,
148
+ commitment?: anchor.web3.Commitment,
149
+ ): Promise<ComputationDefinitionAccount> {
150
+ return arciumProgram.account.computationDefinitionAccount.fetch(
151
+ address,
152
+ commitment,
153
+ );
154
+ }
155
+
156
+ /**
157
+ * Fetch and parse a Computation account.
158
+ * @param arciumProgram - Anchor program instance.
159
+ * @param address - Public key of the Computation account.
160
+ * @param commitment - RPC commitment level.
161
+ * @returns Parsed ComputationAccount data.
162
+ */
163
+ export async function getComputationAccInfo(
164
+ arciumProgram: anchor.Program<ArciumIdlType>,
165
+ address: PublicKey,
166
+ commitment?: anchor.web3.Commitment,
167
+ ): Promise<ComputationAccount> {
168
+ return arciumProgram.account.computationAccount.fetch(address, commitment);
169
+ }
170
+
171
+ async function getArciumAccPubkeys(
172
+ conn: Connection,
173
+ discriminator: number[],
174
+ ): Promise<PublicKey[]> {
175
+ const accs = await conn.getProgramAccounts(ARCIUM_PROGRAM_ID, {
176
+ dataSlice: { offset: 0, length: 0 },
177
+ filters: [
178
+ {
179
+ memcmp: {
180
+ offset: 0,
181
+ encoding: 'base64',
182
+ bytes: Buffer.from(discriminator).toString('base64'),
183
+ },
184
+ },
185
+ ],
186
+ });
187
+ return accs.map((acc) => acc.pubkey);
188
+ }
@@ -0,0 +1,156 @@
1
+ import * as anchor from '@coral-xyz/anchor';
2
+ import {
3
+ ArciumEventName,
4
+ ArciumEventData,
5
+ Connection,
6
+ PublicKey,
7
+ } from './types.js';
8
+ import { ARCIUM_BORSH_CODER, PROGRAM_DATA_PREFIX, PROGRAM_LOG_PREFIX, ARCIUM_EVENT_NAMES } from './constants.js';
9
+
10
+ /**
11
+ * Subscribe to computation events for an MXE program.
12
+ *
13
+ * Listens for queue, execute, and finalize events via Solana log subscriptions.
14
+ *
15
+ * @param conn - Solana connection object.
16
+ * @param mxeProgramId - Public key of the MXE program to monitor.
17
+ * @param callback - Handler called for each event with event data and event name.
18
+ * @returns Subscription ID for cleanup with {@link unsubscribeComputations}.
19
+ *
20
+ * @example
21
+ * const subId = await subscribeComputations(
22
+ * connection,
23
+ * mxeProgramId,
24
+ * (event, name) => {
25
+ * if (name === 'FinalizeComputationEvent') {
26
+ * console.log('Computation finalized:', event.computationOffset.toString());
27
+ * }
28
+ * },
29
+ * );
30
+ *
31
+ * // When done, clean up the subscription
32
+ * await unsubscribeComputations(connection, subId);
33
+ */
34
+ export async function subscribeComputations(
35
+ conn: Connection,
36
+ mxeProgramId: PublicKey,
37
+ callback: (event: ArciumEventData, name: ArciumEventName) => void,
38
+ ): Promise<number> {
39
+ return conn.onLogs(mxeProgramId, (logs) => {
40
+ const events = getComputationEventsFromLogs(logs.logs);
41
+ for (const event of events) {
42
+ callback(event.event, event.name);
43
+ }
44
+ });
45
+ }
46
+
47
+ /**
48
+ * Unsubscribe from computation events.
49
+ * @param conn - Solana connection object.
50
+ * @param subscriptionId - Subscription ID returned by {@link subscribeComputations}.
51
+ */
52
+ export async function unsubscribeComputations(
53
+ conn: Connection,
54
+ subscriptionId: number,
55
+ ): Promise<void> {
56
+ conn.removeOnLogsListener(subscriptionId);
57
+ }
58
+
59
+ /**
60
+ * Get the computation offset from a transaction.
61
+ * @param tx - Transaction to extract the computation offset from.
62
+ * @returns Computation offset if found, otherwise undefined.
63
+ * @throws Error if multiple computation offsets are found in the transaction.
64
+ */
65
+ export function getComputationOffset(
66
+ tx: anchor.web3.VersionedTransactionResponse,
67
+ ): anchor.BN | undefined {
68
+ const events = getComputationEventsFromLogs(tx.meta?.logMessages ?? []);
69
+ if (events.length === 0) {
70
+ return undefined;
71
+ }
72
+
73
+ const computationOffsets = events.map((e) => e.event.computationOffset);
74
+ const computationOffset = computationOffsets[0];
75
+
76
+ if (computationOffsets.some((offset) => !offset.eq(computationOffset))) {
77
+ throw new Error(
78
+ `Multiple computation offsets found in computation: ${JSON.stringify(
79
+ computationOffsets,
80
+ )}`,
81
+ );
82
+ }
83
+
84
+ return computationOffset;
85
+ }
86
+
87
+ /**
88
+ * Get the events related to Arcium computations from a transaction's logs.
89
+ *
90
+ * Note: This implements a direct decode approach instead of using Anchor's EventParser.parseLogs().
91
+ *
92
+ * BREAKING CHANGE IN ANCHOR v0.32.0 (PR #3657, commit 34b6d19):
93
+ * EventParser.parseLogs was hardened to prevent malicious log injection attacks. It now:
94
+ * 1. Requires the first log to match "Program X invoke [1]" (root invocation)
95
+ * 2. Pre-seeds the execution stack with program X from the first log
96
+ * 3. Only parses events when execution.program() === EventParser.programId
97
+ *
98
+ * This breaks our use case:
99
+ * - We subscribe to MXE program logs via conn.onLogs(mxeProgramId, ...) in {@link subscribeComputations}
100
+ * - But we need to parse Arcium events emitted during MXE→Arcium CPI calls
101
+ * - When MXE is the root program, execution.program() = MXE_PROGRAM_ID
102
+ * - EventParser expects execution.program() = ARCIUM_PROGRAM_ID
103
+ * - Result: All Arcium events are silently skipped
104
+ *
105
+ * Our discriminator-based approach:
106
+ * - Scans all logs for "Program data:" and "Program log:" prefixes
107
+ * - Uses event discriminators to identify valid Arcium events (no program context check)
108
+ * - Works regardless of which program is root or subscription target
109
+ * - Handles both MXE→Arcium and Arcium→MXE CPI patterns
110
+ *
111
+ * @param logs - Logs to get the events from.
112
+ * @returns Array of parsed Arcium computation events.
113
+ */
114
+ function getComputationEventsFromLogs(
115
+ logs: string[],
116
+ ): { event: ArciumEventData; name: ArciumEventName }[] {
117
+ const events: Array<{ name: string; data: Record<string, unknown> }> = [];
118
+
119
+ // Scan all event logs and rely on discriminators to identify valid Arcium events.
120
+ // This works for both MXE→Arcium CPI and Arcium→MXE CPI transactions.
121
+ for (const log of logs) {
122
+ if (log.startsWith(PROGRAM_DATA_PREFIX)) {
123
+ const eventData = log.slice(PROGRAM_DATA_PREFIX.length);
124
+ const decoded = ARCIUM_BORSH_CODER.events.decode(eventData);
125
+
126
+ if (decoded && ARCIUM_EVENT_NAMES.includes(decoded.name as ArciumEventName)) {
127
+ events.push(decoded);
128
+ }
129
+ }
130
+ else if (log.startsWith(PROGRAM_LOG_PREFIX)) {
131
+ const eventData = log.slice(PROGRAM_LOG_PREFIX.length);
132
+ const decoded = ARCIUM_BORSH_CODER.events.decode(eventData);
133
+
134
+ if (decoded && ARCIUM_EVENT_NAMES.includes(decoded.name as ArciumEventName)) {
135
+ events.push(decoded);
136
+ }
137
+ }
138
+ }
139
+
140
+ // Map to existing return format
141
+ return events.map((e) => {
142
+ const eventData: ArciumEventData = {
143
+ computationOffset: e.data.computation_offset,
144
+ ...(e.data as object),
145
+ } as ArciumEventData;
146
+
147
+ if (e.data.mxe_program_id) {
148
+ eventData.mxeProgramId = e.data.mxe_program_id as PublicKey;
149
+ }
150
+
151
+ return {
152
+ event: eventData,
153
+ name: e.name as ArciumEventName,
154
+ };
155
+ });
156
+ }
@@ -0,0 +1,78 @@
1
+ import { ArciumIdlType, ARCIUM_IDL, ARCIUM_ADDR } from '@arcium-hq/client';
2
+ import * as anchor from '@coral-xyz/anchor';
3
+ import {
4
+ ArciumEventName, CallbackComputationIx, PublicKey, QueueComputationIx,
5
+ } from './types.js';
6
+
7
+ type ArciumArxNodeAccount = ArciumIdlType['accounts']['0'];
8
+ type ArciumClusterAccount = ArciumIdlType['accounts']['2'];
9
+ type ArciumMXEAccount = ArciumIdlType['accounts']['10'];
10
+
11
+ /**
12
+ * Prefix for program data logs in Solana transaction logs.
13
+ * @constant {string}
14
+ */
15
+ export const PROGRAM_DATA_PREFIX = 'Program data: ';
16
+
17
+ /**
18
+ * Prefix for program log messages in Solana transaction logs.
19
+ * @constant {string}
20
+ */
21
+ export const PROGRAM_LOG_PREFIX = 'Program log: ';
22
+
23
+ /**
24
+ * Valid Arcium event names for computation lifecycle tracking.
25
+ * @constant {ArciumEventName[]}
26
+ */
27
+ export const ARCIUM_EVENT_NAMES: ArciumEventName[] = [
28
+ 'QueueComputationEvent',
29
+ 'InitComputationEvent',
30
+ 'CallbackComputationEvent',
31
+ 'FinalizeComputationEvent',
32
+ ];
33
+
34
+ /**
35
+ * Discriminator for the ArxNode account type. Used to filter and identify ArxNode accounts on-chain.
36
+ */
37
+ export const ARX_NODE_ACC_DISCRIMINATOR: ArciumArxNodeAccount['discriminator'] = [2, 207, 122, 223, 93, 97, 231, 199];
38
+
39
+ /**
40
+ * Discriminator for the Cluster account type. Used to filter and identify Cluster accounts on-chain.
41
+ */
42
+ export const CLUSTER_ACC_DISCRIMINATOR: ArciumClusterAccount['discriminator'] = [236, 225, 118, 228, 173, 106, 18, 60];
43
+
44
+ /**
45
+ * Discriminator for the MXE account type. Used to filter and identify MXE accounts on-chain.
46
+ */
47
+ export const MXE_ACC_DISCRIMINATOR: ArciumMXEAccount['discriminator'] = [103, 26, 85, 250, 179, 159, 17, 117];
48
+
49
+ /**
50
+ * Discriminator for the queueComputation instruction. Used to identify the queueComputation instruction in transaction data.
51
+ */
52
+ export const QUEUE_COMPUTATION_IX_DISCRIMINATOR: QueueComputationIx['discriminator'] = [1, 149, 103, 13, 102, 227, 93, 164];
53
+
54
+ /**
55
+ * Discriminator for the callbackComputation instruction. Used to identify the callbackComputation instruction in transaction data.
56
+ */
57
+ export const CALLBACK_COMPUTATION_IX_DISCRIMINATOR: CallbackComputationIx['discriminator'] = [11, 224, 42, 236, 0, 154, 74, 163];
58
+
59
+ /**
60
+ * The public key of the deployed Arcium program on Solana.
61
+ */
62
+ export const ARCIUM_PROGRAM_ID: PublicKey = new anchor.web3.PublicKey(ARCIUM_ADDR);
63
+
64
+ /**
65
+ * Anchor coder for encoding and decoding Arcium program instructions.
66
+ */
67
+ export const ARCIUM_IX_CODER = new anchor.BorshInstructionCoder(ARCIUM_IDL as unknown as ArciumIdlType);
68
+
69
+ /**
70
+ * Anchor event parser for parsing Arcium program events from transaction logs.
71
+ */
72
+ export const ARCIUM_EVENT_CODER = new anchor.EventParser(ARCIUM_PROGRAM_ID, new anchor.BorshCoder(ARCIUM_IDL as unknown as ArciumIdlType));
73
+
74
+ /**
75
+ * BorshCoder instance for decoding Arcium events.
76
+ * Used directly instead of accessing EventParser's private coder property.
77
+ */
78
+ export const ARCIUM_BORSH_CODER = new anchor.BorshCoder(ARCIUM_IDL as unknown as ArciumIdlType);
package/src/index.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Read-only SDK for querying Arcium network state on Solana.
3
+ *
4
+ * Key exports:
5
+ * - {@link getMXEAccInfo}, {@link getClusterAccInfo} - Account getters
6
+ * - {@link subscribeComputations} - Event monitoring
7
+ * - Types for all Arcium accounts
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export {
12
+ getClusterAccAddress,
13
+ getArxNodeAccAddress,
14
+ getMXEAccAddress,
15
+ getArciumProgram,
16
+ getComputationAccAddress,
17
+ getMempoolAccAddress,
18
+ getClockAccAddress,
19
+ getFeePoolAccAddress,
20
+ getExecutingPoolAccAddress,
21
+ getCompDefAccAddress,
22
+ getComputationsInMempool,
23
+ getMempoolPriorityFeeStats,
24
+ } from '@arcium-hq/client';
25
+
26
+ export * from './accGetters.js';
27
+ export * from './computationGetters.js';
28
+ export * from './types.js';
package/src/types.ts ADDED
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Shared type aliases and utility types for the Arcium program.
3
+ * Many types are derived from the Anchor-generated IDL and are used throughout the reader package.
4
+ */
5
+ import { ArciumIdlType } from '@arcium-hq/client';
6
+ import * as anchor from '@coral-xyz/anchor';
7
+
8
+ /**
9
+ * Solana PublicKey type alias for convenience.
10
+ */
11
+ export type PublicKey = anchor.web3.PublicKey;
12
+
13
+ /**
14
+ * Solana Connection type alias for convenience.
15
+ */
16
+ export type Connection = anchor.web3.Connection;
17
+
18
+ /**
19
+ * Anchor Program type alias with generic IDL support.
20
+ */
21
+ export type Program<T extends anchor.Idl> = anchor.Program<T>;
22
+
23
+ /**
24
+ * Arcium IDL types derived from the Arcium program interface.
25
+ */
26
+ export type ArciumTypes = anchor.IdlTypes<ArciumIdlType>;
27
+
28
+ /**
29
+ * All events emitted by the Arcium program, keyed by event name.
30
+ */
31
+ export type ArciumEvent = anchor.IdlEvents<ArciumIdlType>;
32
+
33
+ /**
34
+ * Capitalized event names, matching the format as emitted by the program.
35
+ */
36
+ export type ArciumEventName = Capitalize<keyof ArciumEvent>;
37
+
38
+ /**
39
+ * Data structure for any Arcium event, as parsed from logs.
40
+ */
41
+ export type ArciumEventData = ArciumEvent[keyof ArciumEvent];
42
+
43
+ /**
44
+ * MXE (Multi-party eXecution Environment) account data structure.
45
+ */
46
+ export type MXEAccount = ArciumTypes['mxeAccount'];
47
+
48
+ /**
49
+ * Cluster account data structure containing node information.
50
+ */
51
+ export type ClusterAccount = ArciumTypes['cluster'];
52
+
53
+ /**
54
+ * Recovery cluster account data structure containing recovery peers information.
55
+ */
56
+ export type RecoveryClusterAccount = ArciumTypes['recoveryClusterAccount'];
57
+
58
+ /**
59
+ * MXE recovery account data structure tracking key recovery session state.
60
+ */
61
+ export type MxeRecoveryAccount = ArciumTypes['mxeRecoveryAccount'];
62
+
63
+ /**
64
+ * ArxNode account data structure for individual computation nodes.
65
+ */
66
+ export type ArxNodeAccount = ArciumTypes['arxNode'];
67
+
68
+ /**
69
+ * Computation account data structure tracking computation state.
70
+ */
71
+ export type ComputationAccount = ArciumTypes['computationAccount'];
72
+
73
+ /**
74
+ * Reference to a computation in a mempool or executing pool.
75
+ */
76
+ export type ComputationReference = ArciumTypes['computationReference'];
77
+
78
+ /**
79
+ * Computation definition account containing circuit configuration.
80
+ */
81
+ export type ComputationDefinitionAccount = ArciumTypes['computationDefinitionAccount'];
82
+
83
+ /**
84
+ * Queue computation instruction type from the Arcium IDL.
85
+ */
86
+ export type QueueComputationIx = ArciumIdlType['instructions']['38'];
87
+
88
+ /**
89
+ * Callback computation instruction type from the Arcium IDL.
90
+ */
91
+ export type CallbackComputationIx = ArciumIdlType['instructions']['4'];
92
+
93
+ /**
94
+ * Valid instruction names from the Arcium IDL.
95
+ */
96
+ export type ArciumInstructionName = ArciumIdlType['instructions'][number]['name'];
97
+
98
+ /**
99
+ * Status values for a computation, as defined by the Arcium protocol.
100
+ */
101
+ export type ComputationStatus = 'queued' | 'executing' | 'executed' | 'finalized' | 'failed';
package/build/index.d.ts DELETED
@@ -1,211 +0,0 @@
1
- import { ArciumIdlType } from '@arcium-hq/client';
2
- export { getArciumProgram, getArxNodeAccAddress, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getFeePoolAccAddress, getMXEAccAddress, getMempoolAccAddress, getMempoolPriorityFeeStats } from '@arcium-hq/client';
3
- import * as anchor from '@coral-xyz/anchor';
4
-
5
- /**
6
- * Shared type aliases and utility types for the Arcium program.
7
- * Many types are derived from the Anchor-generated IDL and are used throughout the reader package.
8
- */
9
-
10
- /**
11
- * Solana PublicKey type alias for convenience.
12
- */
13
- type PublicKey = anchor.web3.PublicKey;
14
- /**
15
- * Solana Connection type alias for convenience.
16
- */
17
- type Connection = anchor.web3.Connection;
18
- /**
19
- * Anchor Program type alias with generic IDL support.
20
- */
21
- type Program<T extends anchor.Idl> = anchor.Program<T>;
22
- /**
23
- * Arcium IDL types derived from the Arcium program interface.
24
- */
25
- type ArciumTypes = anchor.IdlTypes<ArciumIdlType>;
26
- /**
27
- * All events emitted by the Arcium program, keyed by event name.
28
- */
29
- type ArciumEvent = anchor.IdlEvents<ArciumIdlType>;
30
- /**
31
- * Capitalized event names, matching the format as emitted by the program.
32
- */
33
- type ArciumEventName = Capitalize<keyof ArciumEvent>;
34
- /**
35
- * Data structure for any Arcium event, as parsed from logs.
36
- */
37
- type ArciumEventData = ArciumEvent[keyof ArciumEvent];
38
- /**
39
- * MXE (Multi-party eXecution Environment) account data structure.
40
- */
41
- type MXEAccount = ArciumTypes['mxeAccount'];
42
- /**
43
- * Cluster account data structure containing node information.
44
- */
45
- type ClusterAccount = ArciumTypes['cluster'];
46
- /**
47
- * Recovery cluster account data structure containing recovery peers information.
48
- */
49
- type RecoveryClusterAccount = ArciumTypes['recoveryClusterAccount'];
50
- /**
51
- * MXE recovery account data structure tracking key recovery session state.
52
- */
53
- type MxeRecoveryAccount = ArciumTypes['mxeRecoveryAccount'];
54
- /**
55
- * ArxNode account data structure for individual computation nodes.
56
- */
57
- type ArxNodeAccount = ArciumTypes['arxNode'];
58
- /**
59
- * Computation account data structure tracking computation state.
60
- */
61
- type ComputationAccount = ArciumTypes['computationAccount'];
62
- /**
63
- * Reference to a computation in a mempool or executing pool.
64
- */
65
- type ComputationReference = ArciumTypes['computationReference'];
66
- /**
67
- * Computation definition account containing circuit configuration.
68
- */
69
- type ComputationDefinitionAccount = ArciumTypes['computationDefinitionAccount'];
70
- /**
71
- * Queue computation instruction type from the Arcium IDL.
72
- */
73
- type QueueComputationIx = ArciumIdlType['instructions']['38'];
74
- /**
75
- * Callback computation instruction type from the Arcium IDL.
76
- */
77
- type CallbackComputationIx = ArciumIdlType['instructions']['4'];
78
- /**
79
- * Valid instruction names from the Arcium IDL.
80
- */
81
- type ArciumInstructionName = ArciumIdlType['instructions'][number]['name'];
82
- /**
83
- * Status values for a computation, as defined by the Arcium protocol.
84
- */
85
- type ComputationStatus = 'queued' | 'executing' | 'executed' | 'finalized' | 'failed';
86
-
87
- /**
88
- * Return all MXE account addresses.
89
- * @param conn - Solana connection object.
90
- * @returns Array of MXE account public keys.
91
- */
92
- declare function getMXEAccAddresses(conn: Connection): Promise<PublicKey[]>;
93
- /**
94
- * Return all Cluster account addresses.
95
- * @param conn - Solana connection object.
96
- * @returns Array of Cluster account public keys.
97
- */
98
- declare function getClusterAccAddresses(conn: Connection): Promise<PublicKey[]>;
99
- /**
100
- * Return all ArxNode account addresses.
101
- * @param conn - Solana connection object.
102
- * @returns Array of ArxNode account public keys.
103
- */
104
- declare function getArxNodeAccAddresses(conn: Connection): Promise<PublicKey[]>;
105
- /**
106
- * Fetch and parse an MXE account.
107
- *
108
- * @param arciumProgram - Anchor program instance.
109
- * @param address - Public key of the MXE account.
110
- * @param commitment - RPC commitment level.
111
- * @returns Parsed MXE account data.
112
- *
113
- * @example
114
- * import { getArciumProgram, getMXEAccAddress, getMXEAccInfo } from '@arcium-hq/reader';
115
- *
116
- * const program = getArciumProgram(provider);
117
- * const mxeAddress = getMXEAccAddress(mxeProgramId);
118
- * const mxeAccount = await getMXEAccInfo(program, mxeAddress);
119
- * console.log('MXE authority:', mxeAccount.authority?.toBase58());
120
- */
121
- declare function getMXEAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<MXEAccount>;
122
- /**
123
- * Fetch and parse a Cluster account.
124
- * @param arciumProgram - Anchor program instance.
125
- * @param address - Public key of the Cluster account.
126
- * @param commitment - RPC commitment level.
127
- * @returns Parsed ClusterAccount data.
128
- */
129
- declare function getClusterAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<ClusterAccount>;
130
- /**
131
- * Fetch and parse a recovery cluster account.
132
- * @param arciumProgram - Anchor program instance.
133
- * @param address - Public key of the recovery cluster account.
134
- * @param commitment - RPC commitment level.
135
- * @returns Parsed RecoveryClusterAccount data.
136
- */
137
- declare function getRecoveryClusterAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<RecoveryClusterAccount>;
138
- /**
139
- * Fetch and parse an MxeRecovery account.
140
- * @param arciumProgram - Anchor program instance.
141
- * @param address - Public key of the MxeRecovery account.
142
- * @param commitment - RPC commitment level.
143
- * @returns Parsed MxeRecoveryAccount data.
144
- */
145
- declare function getMxeRecoveryAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<MxeRecoveryAccount>;
146
- /**
147
- * Fetch and parse an ArxNode account.
148
- * @param arciumProgram - Anchor program instance.
149
- * @param address - Public key of the ArxNode account.
150
- * @param commitment - RPC commitment level.
151
- * @returns Parsed ArxNodeAccount data.
152
- */
153
- declare function getArxNodeAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<ArxNodeAccount>;
154
- /**
155
- * Fetch and parse a ComputationDefinition account.
156
- * @param arciumProgram - Anchor program instance.
157
- * @param address - Public key of the ComputationDefinition account.
158
- * @param commitment - RPC commitment level.
159
- * @returns Parsed ComputationDefinitionAccount data.
160
- */
161
- declare function getCompDefAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<ComputationDefinitionAccount>;
162
- /**
163
- * Fetch and parse a Computation account.
164
- * @param arciumProgram - Anchor program instance.
165
- * @param address - Public key of the Computation account.
166
- * @param commitment - RPC commitment level.
167
- * @returns Parsed ComputationAccount data.
168
- */
169
- declare function getComputationAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<ComputationAccount>;
170
-
171
- /**
172
- * Subscribe to computation events for an MXE program.
173
- *
174
- * Listens for queue, execute, and finalize events via Solana log subscriptions.
175
- *
176
- * @param conn - Solana connection object.
177
- * @param mxeProgramId - Public key of the MXE program to monitor.
178
- * @param callback - Handler called for each event with event data and event name.
179
- * @returns Subscription ID for cleanup with {@link unsubscribeComputations}.
180
- *
181
- * @example
182
- * const subId = await subscribeComputations(
183
- * connection,
184
- * mxeProgramId,
185
- * (event, name) => {
186
- * if (name === 'FinalizeComputationEvent') {
187
- * console.log('Computation finalized:', event.computationOffset.toString());
188
- * }
189
- * },
190
- * );
191
- *
192
- * // When done, clean up the subscription
193
- * await unsubscribeComputations(connection, subId);
194
- */
195
- declare function subscribeComputations(conn: Connection, mxeProgramId: PublicKey, callback: (event: ArciumEventData, name: ArciumEventName) => void): Promise<number>;
196
- /**
197
- * Unsubscribe from computation events.
198
- * @param conn - Solana connection object.
199
- * @param subscriptionId - Subscription ID returned by {@link subscribeComputations}.
200
- */
201
- declare function unsubscribeComputations(conn: Connection, subscriptionId: number): Promise<void>;
202
- /**
203
- * Get the computation offset from a transaction.
204
- * @param tx - Transaction to extract the computation offset from.
205
- * @returns Computation offset if found, otherwise undefined.
206
- * @throws Error if multiple computation offsets are found in the transaction.
207
- */
208
- declare function getComputationOffset(tx: anchor.web3.VersionedTransactionResponse): anchor.BN | undefined;
209
-
210
- export { getArxNodeAccAddresses, getArxNodeAccInfo, getClusterAccAddresses, getClusterAccInfo, getCompDefAccInfo, getComputationAccInfo, getComputationOffset, getMXEAccAddresses, getMXEAccInfo, getMxeRecoveryAccInfo, getRecoveryClusterAccInfo, subscribeComputations, unsubscribeComputations };
211
- export type { ArciumEvent, ArciumEventData, ArciumEventName, ArciumInstructionName, ArciumTypes, ArxNodeAccount, CallbackComputationIx, ClusterAccount, ComputationAccount, ComputationDefinitionAccount, ComputationReference, ComputationStatus, Connection, MXEAccount, MxeRecoveryAccount, Program, PublicKey, QueueComputationIx, RecoveryClusterAccount };