@arcium-hq/reader 0.9.6 → 0.10.0

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/README.md CHANGED
@@ -1,292 +1,68 @@
1
- # Arcium Reader SDK
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/arcium-hq/.github/refs/heads/main/profile/arcium.svg" alt="Arcium" width="200"/>
2
3
 
3
- The Arcium Reader SDK is a TypeScript library for passively observing and querying the Arcium network state. It provides read-only access to account data, computation tracking, and event monitoring without requiring a wallet or signer.
4
+ <h1>@arcium-hq/reader</h1>
4
5
 
5
- ## Installation
6
-
7
- ```bash
8
- npm install @arcium-hq/reader
9
- # or
10
- yarn add @arcium-hq/reader
11
- # or
12
- pnpm add @arcium-hq/reader
13
- ```
14
-
15
- ## Quick Start
16
-
17
- ### 1. Setup
18
-
19
- ```typescript
20
- import * as anchor from "@coral-xyz/anchor";
21
- import { getArciumProgram } from "@arcium-hq/reader";
22
-
23
- // Setup connection (no wallet required)
24
- const connection = new anchor.web3.Connection("https://api.mainnet-beta.solana.com");
25
- const provider = new anchor.AnchorProvider(connection, null, {});
26
- const arciumProgram = getArciumProgram(provider);
27
- ```
28
-
29
- ### 2. Query Account Information
30
-
31
- ```typescript
32
- import {
33
- getMXEAccAddresses,
34
- getMXEAccInfo,
35
- getClusterAccAddresses,
36
- getClusterAccInfo,
37
- } from "@arcium-hq/reader";
6
+ <p>Read-only TypeScript SDK for querying Arcium network state.</p>
38
7
 
39
- // Get all MXE accounts
40
- const mxeAddresses = await getMXEAccAddresses(connection);
41
- console.log(`Found ${mxeAddresses.length} MXE accounts`);
8
+ [![npm](https://img.shields.io/npm/v/@arcium-hq/reader)](https://www.npmjs.com/package/@arcium-hq/reader)
42
9
 
43
- // Get detailed information for first MXE
44
- if (mxeAddresses.length > 0) {
45
- const mxeInfo = await getMXEAccInfo(arciumProgram, mxeAddresses[0]);
46
- console.log("MXE Info:", {
47
- authority: mxeInfo.authority,
48
- cluster: mxeInfo.cluster,
49
- computationDefinitions: mxeInfo.computationDefinitions.length,
50
- });
51
- }
52
- ```
53
-
54
- ### 3. Monitor Computations
55
-
56
- ```typescript
57
- import { subscribeComputations } from "@arcium-hq/reader";
58
-
59
- // Subscribe to computation events for an MXE program
60
- const mxeProgramId = new anchor.web3.PublicKey("YOUR_MXE_PROGRAM_ID");
61
-
62
- const subscriptionId = await subscribeComputations(
63
- connection,
64
- mxeProgramId,
65
- (eventData, eventName) => {
66
- console.log(`Event: ${eventName}`, eventData);
67
- }
68
- );
69
- ```
70
-
71
- ## Account Types and Queries
72
-
73
- ### MXE (Multi-party eXecution Environment) Accounts
74
-
75
- MXE accounts represent execution environments for secure computations.
10
+ **[API Docs](https://ts.arcium.com/api)** | **[Developer Docs](https://docs.arcium.com/developers/js-client-library)**
76
11
 
77
- ```typescript
78
- import { getMXEAccAddresses, getMXEAccInfo } from "@arcium-hq/reader";
12
+ </div>
79
13
 
80
- // Get all MXE account addresses
81
- const mxeAddresses = await getMXEAccAddresses(connection);
82
-
83
- // Fetch detailed MXE information
84
- for (const address of mxeAddresses) {
85
- const mxeInfo = await getMXEAccInfo(arciumProgram, address);
86
-
87
- console.log("MXE Account:", {
88
- address: address.toBase58(),
89
- authority: mxeInfo.authority?.toBase58(),
90
- cluster: mxeInfo.cluster,
91
- x25519KeySet: 'set' in mxeInfo.x25519Pubkey,
92
- computationDefinitions: mxeInfo.computationDefinitions,
93
- fallbackClusters: mxeInfo.fallbackClusters,
94
- });
95
- }
96
- ```
97
-
98
- ### Cluster Accounts
99
-
100
- Cluster accounts manage collections of ARX nodes that execute computations.
101
-
102
- ```typescript
103
- import { getClusterAccAddresses, getClusterAccInfo } from "@arcium-hq/reader";
104
-
105
- // Get all cluster addresses
106
- const clusterAddresses = await getClusterAccAddresses(connection);
107
-
108
- // Analyze cluster information
109
- for (const address of clusterAddresses) {
110
- const clusterInfo = await getClusterAccInfo(arciumProgram, address);
111
-
112
- console.log("Cluster:", {
113
- address: address.toBase58(),
114
- nodeCount: clusterInfo.nodes.length,
115
- mxeCount: clusterInfo.mxes.length,
116
- threshold: clusterInfo.threshold,
117
- state: clusterInfo.state,
118
- });
119
- }
120
- ```
14
+ ## When To Use
121
15
 
122
- ### ArxNode Accounts
16
+ - Listing MXE, cluster, and ARX node accounts
17
+ - Fetching typed account state from the Arcium program
18
+ - Monitoring computation activity without writing transactions
123
19
 
124
- ArxNode accounts represent individual computation nodes in the network.
20
+ ## Requirements
125
21
 
126
- ```typescript
127
- import { getArxNodeAccAddresses, getArxNodeAccInfo } from "@arcium-hq/reader";
22
+ - Node.js `20.18+`
23
+ - `@anchor-lang/core` `^0.32.1`
128
24
 
129
- // Get all ARX node addresses
130
- const arxNodeAddresses = await getArxNodeAccAddresses(connection);
131
-
132
- // Get node information
133
- for (const address of arxNodeAddresses) {
134
- const nodeInfo = await getArxNodeAccInfo(arciumProgram, address);
135
-
136
- console.log("ARX Node:", {
137
- address: address.toBase58(),
138
- authority: nodeInfo.authority?.toBase58(),
139
- clusterMemberships: nodeInfo.clusterMemberships,
140
- encryptionPubkey: Buffer.from(nodeInfo.encryptionPubkey).toString('hex'),
141
- });
142
- }
143
- ```
144
-
145
- ### Computation Definition Accounts
146
-
147
- Track available computation definitions and their configurations.
148
-
149
- ```typescript
150
- import { getCompDefAccInfo, getCompDefAccAddress } from "@arcium-hq/reader";
151
-
152
- // Get computation definition for a specific circuit
153
- const mxeProgramId = new anchor.web3.PublicKey("YOUR_MXE_PROGRAM_ID");
154
- const compDefOffset = 0; // Your computation definition offset
155
- const compDefAddress = getCompDefAccAddress(mxeProgramId, compDefOffset);
156
- const compDefInfo = await getCompDefAccInfo(arciumProgram, compDefAddress);
157
-
158
- console.log("Computation Definition:", {
159
- finalizationAuthority: compDefInfo.finalizationAuthority?.toBase58(),
160
- finalizesDuringCallback: compDefInfo.finalizeDuringCallback,
161
- cuAmount: compDefInfo.cuAmount.toString(),
162
- circuitSource: compDefInfo.circuitSource,
163
- });
164
- ```
165
-
166
- ### Computation Accounts
167
-
168
- Monitor individual computation instances and their status.
169
-
170
- ```typescript
171
- import { getComputationAccInfo, getComputationAccAddress } from "@arcium-hq/reader";
172
-
173
- // Get computation account info
174
- const clusterOffset = 0; // Your cluster offset
175
- const computationOffset = new anchor.BN("123456789");
176
- const computationAddress = getComputationAccAddress(clusterOffset, computationOffset);
177
- const computationInfo = await getComputationAccInfo(arciumProgram, computationAddress);
25
+ ## Installation
178
26
 
179
- console.log("Computation:", {
180
- status: computationInfo.status,
181
- arguments: computationInfo.arguments,
182
- results: computationInfo.results,
183
- submitter: computationInfo.submitter.toBase58(),
184
- });
27
+ ```bash
28
+ npm install @arcium-hq/reader @anchor-lang/core
185
29
  ```
186
30
 
187
- ## Mempool Analysis
31
+ ## Quick Start
188
32
 
189
- Analyze pending computations in the network's memory pools.
33
+ A wallet-less `AnchorProvider` is sufficient since this SDK never signs transactions.
190
34
 
191
- ```typescript
35
+ ```ts
192
36
  import {
193
- getComputationsInMempool,
194
- getMempoolAccAddress
195
- } from "@arcium-hq/reader";
196
-
197
- // Get mempool for a cluster (use your cluster offset)
198
- const clusterOffset = 0; // Your cluster offset
199
- const mempoolAddress = getMempoolAccAddress(clusterOffset);
200
- const pendingComputations = await getComputationsInMempool(arciumProgram, mempoolAddress);
201
-
202
- console.log(`Found ${pendingComputations.length} pending computations:`);
203
-
204
- for (const compRef of pendingComputations) {
205
- console.log("Pending Computation:", {
206
- computationOffset: compRef.computationOffset.toString(),
207
- priorityFee: compRef.priorityFee.toString(),
208
- computationDefinitionOffset: compRef.computationDefinitionOffset,
209
- });
210
- }
211
- ```
212
-
213
- ## Event Monitoring
214
-
215
- ### Real-time Event Subscription
216
-
217
- Monitor computation lifecycle events in real-time:
218
-
219
- ```typescript
220
- import {
221
- subscribeComputations,
222
- unsubscribeComputations,
223
- ArciumEventData,
224
- ArciumEventName
37
+ getArciumProgram,
38
+ getClusterAccAddresses,
39
+ getMXEAccAddresses,
40
+ getMXEAccInfo,
225
41
  } from "@arcium-hq/reader";
226
42
 
227
- const eventLog: Array<{event: ArciumEventData, name: ArciumEventName, timestamp: Date}> = [];
228
-
229
- // Subscribe to events
230
- const subscriptionId = await subscribeComputations(
231
- connection,
232
- mxeProgramId,
233
- (eventData, eventName) => {
234
- eventLog.push({
235
- event: eventData,
236
- name: eventName,
237
- timestamp: new Date()
238
- });
239
-
240
- console.log(`[${eventName}] Computation ${eventData.computationOffset.toString()}`);
241
-
242
- // Handle specific event types
243
- switch (eventName) {
244
- case 'QueueComputationEvent':
245
- console.log(" → Computation queued for execution");
246
- break;
247
- case 'InitComputationEvent':
248
- console.log(" → Computation execution started");
249
- break;
250
- case 'CallbackComputationEvent':
251
- console.log(" → Computation callback received");
252
- break;
253
- case 'FinalizeComputationEvent':
254
- console.log(" → Computation finalized");
255
- break;
256
- }
257
- }
258
- );
259
-
260
- console.log(`Subscribed to events with ID: ${subscriptionId}`);
261
-
262
- // Later, unsubscribe
263
- // await unsubscribeComputations(connection, subscriptionId);
43
+ // `provider` is an `AnchorProvider` you've already constructed.
44
+ const program = getArciumProgram(provider);
45
+ const mxes = await getMXEAccAddresses(provider.connection);
46
+ const clusters = await getClusterAccAddresses(provider.connection);
47
+ const firstMxe = await getMXEAccInfo(program, mxes[0]);
264
48
  ```
265
49
 
266
- ### Transaction Analysis
50
+ ## Main Exports
267
51
 
268
- Extract computation events from transaction logs:
52
+ | Area | Description |
53
+ |------|-------------|
54
+ | Account discovery | `getMXEAccAddresses`, `getClusterAccAddresses`, `getArxNodeAccAddresses` |
55
+ | Account fetching | `getMXEAccInfo`, `getClusterAccInfo`, `getCompDefAccInfo`, `getComputationAccInfo` |
56
+ | PDA helpers | Re-exported from `@arcium-hq/client` for convenient read flows |
57
+ | Types | Typed account models for Arcium state |
269
58
 
270
- ```typescript
271
- import { getComputationOffset } from "@arcium-hq/reader";
59
+ ## Notes
272
60
 
273
- // Analyze a specific transaction
274
- const txSignature = "YOUR_TRANSACTION_SIGNATURE";
275
- const tx = await connection.getTransaction(txSignature, {
276
- commitment: "confirmed",
277
- maxSupportedTransactionVersion: 0
278
- });
279
-
280
- if (tx) {
281
- const computationOffset = getComputationOffset(tx);
282
- if (computationOffset) {
283
- console.log(`Transaction contains computation: ${computationOffset.toString()}`);
284
- }
285
- }
286
- ```
61
+ - `@arcium-hq/reader` is read-only; use [`@arcium-hq/client`](https://www.npmjs.com/package/@arcium-hq/client) for encryption and write flows.
62
+ - The package re-exports several PDA helpers from the client SDK.
287
63
 
288
- ## API Reference
64
+ ## See Also
289
65
 
290
- - **[API Reference](https://ts.arcium.com/api)** - Complete API documentation
291
- - **[Developer Docs](https://docs.arcium.com/developers/js-client-library)** - Guides and tutorials
292
- - **[Examples](https://github.com/arcium-hq/examples)** - Code examples
66
+ - [`@arcium-hq/client`](https://www.npmjs.com/package/@arcium-hq/client)
67
+ - [API Docs](https://ts.arcium.com/api)
68
+ - [Developer Docs](https://docs.arcium.com/developers/js-client-library)
package/build/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var client = require('@arcium-hq/client');
4
- var anchor = require('@coral-xyz/anchor');
4
+ var anchor = require('@anchor-lang/core');
5
5
 
6
6
  function _interopNamespaceDefault(e) {
7
7
  var n = Object.create(null);
package/build/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ARCIUM_ADDR, ARCIUM_IDL } from '@arcium-hq/client';
2
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';
3
+ import * as anchor from '@anchor-lang/core';
4
4
 
5
5
  /**
6
6
  * Prefix for program data logs in Solana transaction logs.
@@ -1,4 +1,4 @@
1
- import * as anchor from '@coral-xyz/anchor';
1
+ import * as anchor from '@anchor-lang/core';
2
2
  import { ArciumIdlType } from '@arcium-hq/client';
3
3
  import { ClusterAccount, Connection, MXEAccount, PublicKey, ArxNodeAccount, ComputationAccount, ComputationDefinitionAccount, RecoveryClusterAccount, MxeRecoveryAccount } from './types.js';
4
4
  /**
@@ -1,5 +1,5 @@
1
- import * as anchor from '@coral-xyz/anchor';
2
- import { ArciumEventName, ArciumEventData, Connection, PublicKey } from './types.js';
1
+ import * as anchor from '@anchor-lang/core';
2
+ import { ArciumEventName, ComputationEventData, Connection, PublicKey } from './types.js';
3
3
  /**
4
4
  * Subscribe to computation events for an MXE program.
5
5
  *
@@ -24,7 +24,7 @@ import { ArciumEventName, ArciumEventData, Connection, PublicKey } from './types
24
24
  * // When done, clean up the subscription
25
25
  * await unsubscribeComputations(connection, subId);
26
26
  */
27
- export declare function subscribeComputations(conn: Connection, mxeProgramId: PublicKey, callback: (event: ArciumEventData, name: ArciumEventName) => void): Promise<number>;
27
+ export declare function subscribeComputations(conn: Connection, mxeProgramId: PublicKey, callback: (event: ComputationEventData, name: ArciumEventName) => void): Promise<number>;
28
28
  /**
29
29
  * Unsubscribe from computation events.
30
30
  * @param conn - Solana connection object.
@@ -1 +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"}
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,oBAAoB,EACpB,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,oBAAoB,EAAE,IAAI,EAAE,eAAe,KAAK,IAAI,GACvE,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"}
@@ -1,9 +1,12 @@
1
1
  import { ArciumIdlType } from '@arcium-hq/client';
2
- import * as anchor from '@coral-xyz/anchor';
2
+ import * as anchor from '@anchor-lang/core';
3
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'];
4
+ type FindAccount<Name extends string> = Extract<ArciumIdlType['accounts'][number], {
5
+ name: Name;
6
+ }>;
7
+ type ArciumArxNodeAccount = FindAccount<'arxNode'>;
8
+ type ArciumClusterAccount = FindAccount<'cluster'>;
9
+ type ArciumMXEAccount = FindAccount<'mxeAccount'>;
7
10
  /**
8
11
  * Prefix for program data logs in Solana transaction logs.
9
12
  * @constant {string}
@@ -1 +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,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9G;;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"}
@@ -3,7 +3,7 @@
3
3
  * Many types are derived from the Anchor-generated IDL and are used throughout the reader package.
4
4
  */
5
5
  import { ArciumIdlType } from '@arcium-hq/client';
6
- import * as anchor from '@coral-xyz/anchor';
6
+ import * as anchor from '@anchor-lang/core';
7
7
  /**
8
8
  * Solana PublicKey type alias for convenience.
9
9
  */
@@ -20,6 +20,13 @@ export type Program<T extends anchor.Idl> = anchor.Program<T>;
20
20
  * Arcium IDL types derived from the Arcium program interface.
21
21
  */
22
22
  export type ArciumTypes = anchor.IdlTypes<ArciumIdlType>;
23
+ /**
24
+ * Finds an instruction type from the Arcium IDL by name,
25
+ * avoiding fragile hardcoded numeric indices.
26
+ */
27
+ export type FindInstruction<Name extends string> = Extract<ArciumIdlType['instructions'][number], {
28
+ name: Name;
29
+ }>;
23
30
  /**
24
31
  * All events emitted by the Arcium program, keyed by event name.
25
32
  */
@@ -32,6 +39,14 @@ export type ArciumEventName = Capitalize<keyof ArciumEvent>;
32
39
  * Data structure for any Arcium event, as parsed from logs.
33
40
  */
34
41
  export type ArciumEventData = ArciumEvent[keyof ArciumEvent];
42
+ /**
43
+ * Computation event names that all have computationOffset field.
44
+ */
45
+ export type ComputationEventName = 'queueComputationEvent' | 'initComputationEvent' | 'callbackComputationEvent' | 'finalizeComputationEvent';
46
+ /**
47
+ * Data structure for computation events (events that have computationOffset).
48
+ */
49
+ export type ComputationEventData = ArciumEvent[ComputationEventName];
35
50
  /**
36
51
  * MXE (Multi-party eXecution Environment) account data structure.
37
52
  */
@@ -67,11 +82,11 @@ export type ComputationDefinitionAccount = ArciumTypes['computationDefinitionAcc
67
82
  /**
68
83
  * Queue computation instruction type from the Arcium IDL.
69
84
  */
70
- export type QueueComputationIx = ArciumIdlType['instructions']['38'];
85
+ export type QueueComputationIx = FindInstruction<'queueComputation'>;
71
86
  /**
72
87
  * Callback computation instruction type from the Arcium IDL.
73
88
  */
74
- export type CallbackComputationIx = ArciumIdlType['instructions']['4'];
89
+ export type CallbackComputationIx = FindInstruction<'callbackComputation'>;
75
90
  /**
76
91
  * Valid instruction names from the Arcium IDL.
77
92
  */
@@ -1 +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,CA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AC,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,eAAe,CAAC,kBAAkB,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAC,qBAAqB,CAAC,CAAC;AAE3E;;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.6",
3
+ "version": "0.10.0",
4
4
  "description": "Reader SDK for fetching onchain data for Arcium network programs",
5
5
  "author": "Arcium",
6
6
  "license": "GPL-3.0-only",
@@ -55,10 +55,10 @@
55
55
  "typescript-eslint": "^8.15.0"
56
56
  },
57
57
  "dependencies": {
58
- "@coral-xyz/anchor": "^0.32.1",
58
+ "@anchor-lang/core": "^1.0.1",
59
59
  "@noble/curves": "^1.9.5",
60
60
  "@noble/hashes": "^1.7.1",
61
- "@arcium-hq/client": "0.9.6"
61
+ "@arcium-hq/client": "0.10.0"
62
62
  },
63
63
  "keywords": [
64
64
  "Cryptography",
package/src/accGetters.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as anchor from '@coral-xyz/anchor';
1
+ import * as anchor from '@anchor-lang/core';
2
2
  import { ArciumIdlType } from '@arcium-hq/client';
3
3
  import {
4
4
  ClusterAccount,
@@ -1,7 +1,7 @@
1
- import * as anchor from '@coral-xyz/anchor';
1
+ import * as anchor from '@anchor-lang/core';
2
2
  import {
3
3
  ArciumEventName,
4
- ArciumEventData,
4
+ ComputationEventData,
5
5
  Connection,
6
6
  PublicKey,
7
7
  } from './types.js';
@@ -34,7 +34,7 @@ import { ARCIUM_BORSH_CODER, PROGRAM_DATA_PREFIX, PROGRAM_LOG_PREFIX, ARCIUM_EVE
34
34
  export async function subscribeComputations(
35
35
  conn: Connection,
36
36
  mxeProgramId: PublicKey,
37
- callback: (event: ArciumEventData, name: ArciumEventName) => void,
37
+ callback: (event: ComputationEventData, name: ArciumEventName) => void,
38
38
  ): Promise<number> {
39
39
  return conn.onLogs(mxeProgramId, (logs) => {
40
40
  const events = getComputationEventsFromLogs(logs.logs);
@@ -113,7 +113,7 @@ export function getComputationOffset(
113
113
  */
114
114
  function getComputationEventsFromLogs(
115
115
  logs: string[],
116
- ): { event: ArciumEventData; name: ArciumEventName }[] {
116
+ ): { event: ComputationEventData; name: ArciumEventName }[] {
117
117
  const events: Array<{ name: string; data: Record<string, unknown> }> = [];
118
118
 
119
119
  // Scan all event logs and rely on discriminators to identify valid Arcium events.
@@ -139,10 +139,10 @@ function getComputationEventsFromLogs(
139
139
 
140
140
  // Map to existing return format
141
141
  return events.map((e) => {
142
- const eventData: ArciumEventData = {
142
+ const eventData: ComputationEventData = {
143
143
  computationOffset: e.data.computation_offset,
144
144
  ...(e.data as object),
145
- } as ArciumEventData;
145
+ } as ComputationEventData;
146
146
 
147
147
  if (e.data.mxe_program_id) {
148
148
  eventData.mxeProgramId = e.data.mxe_program_id as PublicKey;
package/src/constants.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { ArciumIdlType, ARCIUM_IDL, ARCIUM_ADDR } from '@arcium-hq/client';
2
- import * as anchor from '@coral-xyz/anchor';
2
+ import * as anchor from '@anchor-lang/core';
3
3
  import {
4
4
  ArciumEventName, CallbackComputationIx, PublicKey, QueueComputationIx,
5
5
  } from './types.js';
6
6
 
7
- type ArciumArxNodeAccount = ArciumIdlType['accounts']['0'];
8
- type ArciumClusterAccount = ArciumIdlType['accounts']['2'];
9
- type ArciumMXEAccount = ArciumIdlType['accounts']['10'];
7
+ type FindAccount<Name extends string> = Extract<ArciumIdlType['accounts'][number], { name: Name }>;
8
+ type ArciumArxNodeAccount = FindAccount<'arxNode'>;
9
+ type ArciumClusterAccount = FindAccount<'cluster'>;
10
+ type ArciumMXEAccount = FindAccount<'mxeAccount'>;
10
11
 
11
12
  /**
12
13
  * Prefix for program data logs in Solana transaction logs.
package/src/types.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Many types are derived from the Anchor-generated IDL and are used throughout the reader package.
4
4
  */
5
5
  import { ArciumIdlType } from '@arcium-hq/client';
6
- import * as anchor from '@coral-xyz/anchor';
6
+ import * as anchor from '@anchor-lang/core';
7
7
 
8
8
  /**
9
9
  * Solana PublicKey type alias for convenience.
@@ -25,6 +25,12 @@ export type Program<T extends anchor.Idl> = anchor.Program<T>;
25
25
  */
26
26
  export type ArciumTypes = anchor.IdlTypes<ArciumIdlType>;
27
27
 
28
+ /**
29
+ * Finds an instruction type from the Arcium IDL by name,
30
+ * avoiding fragile hardcoded numeric indices.
31
+ */
32
+ export type FindInstruction<Name extends string> = Extract<ArciumIdlType['instructions'][number], { name: Name }>;
33
+
28
34
  /**
29
35
  * All events emitted by the Arcium program, keyed by event name.
30
36
  */
@@ -40,6 +46,16 @@ export type ArciumEventName = Capitalize<keyof ArciumEvent>;
40
46
  */
41
47
  export type ArciumEventData = ArciumEvent[keyof ArciumEvent];
42
48
 
49
+ /**
50
+ * Computation event names that all have computationOffset field.
51
+ */
52
+ export type ComputationEventName = 'queueComputationEvent' | 'initComputationEvent' | 'callbackComputationEvent' | 'finalizeComputationEvent';
53
+
54
+ /**
55
+ * Data structure for computation events (events that have computationOffset).
56
+ */
57
+ export type ComputationEventData = ArciumEvent[ComputationEventName];
58
+
43
59
  /**
44
60
  * MXE (Multi-party eXecution Environment) account data structure.
45
61
  */
@@ -83,12 +99,12 @@ export type ComputationDefinitionAccount = ArciumTypes['computationDefinitionAcc
83
99
  /**
84
100
  * Queue computation instruction type from the Arcium IDL.
85
101
  */
86
- export type QueueComputationIx = ArciumIdlType['instructions']['38'];
102
+ export type QueueComputationIx = FindInstruction<'queueComputation'>;
87
103
 
88
104
  /**
89
105
  * Callback computation instruction type from the Arcium IDL.
90
106
  */
91
- export type CallbackComputationIx = ArciumIdlType['instructions']['4'];
107
+ export type CallbackComputationIx = FindInstruction<'callbackComputation'>;
92
108
 
93
109
  /**
94
110
  * Valid instruction names from the Arcium IDL.