@arcium-hq/reader 0.4.0 → 0.5.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 +5 -5
- package/build/index.cjs +37 -57
- package/build/index.d.ts +44 -12
- package/build/index.mjs +30 -57
- package/package.json +3 -6
package/README.md
CHANGED
|
@@ -18,12 +18,12 @@ pnpm add @arcium-hq/reader
|
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
20
|
import * as anchor from "@coral-xyz/anchor";
|
|
21
|
-
import {
|
|
21
|
+
import { getArciumProgram } from "@arcium-hq/reader";
|
|
22
22
|
|
|
23
23
|
// Setup connection (no wallet required)
|
|
24
24
|
const connection = new anchor.web3.Connection("https://api.mainnet-beta.solana.com");
|
|
25
25
|
const provider = new anchor.AnchorProvider(connection, null, {});
|
|
26
|
-
const arciumProgram =
|
|
26
|
+
const arciumProgram = getArciumProgram(provider);
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
### 2. Query Account Information
|
|
@@ -288,6 +288,6 @@ if (tx) {
|
|
|
288
288
|
|
|
289
289
|
## API Reference
|
|
290
290
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
291
|
+
- **[API Reference](https://ts.arcium.com/api)** - Complete API documentation
|
|
292
|
+
- **[Developer Docs](https://docs.arcium.com/developers/js-client-library)** - Guides and tutorials
|
|
293
|
+
- **[Examples](https://github.com/arcium-hq/examples)** - Code examples
|
package/build/index.cjs
CHANGED
|
@@ -22,7 +22,26 @@ function _interopNamespaceDefault(e) {
|
|
|
22
22
|
|
|
23
23
|
var anchor__namespace = /*#__PURE__*/_interopNamespaceDefault(anchor);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Prefix for program data logs in Solana transaction logs.
|
|
27
|
+
* @constant {string}
|
|
28
|
+
*/
|
|
29
|
+
const PROGRAM_DATA_PREFIX = 'Program data: ';
|
|
30
|
+
/**
|
|
31
|
+
* Prefix for program log messages in Solana transaction logs.
|
|
32
|
+
* @constant {string}
|
|
33
|
+
*/
|
|
34
|
+
const PROGRAM_LOG_PREFIX = 'Program log: ';
|
|
35
|
+
/**
|
|
36
|
+
* Valid Arcium event names for computation lifecycle tracking.
|
|
37
|
+
* @constant {ArciumEventName[]}
|
|
38
|
+
*/
|
|
39
|
+
const ARCIUM_EVENT_NAMES = [
|
|
40
|
+
'QueueComputationEvent',
|
|
41
|
+
'InitComputationEvent',
|
|
42
|
+
'CallbackComputationEvent',
|
|
43
|
+
'FinalizeComputationEvent',
|
|
44
|
+
];
|
|
26
45
|
/**
|
|
27
46
|
* Discriminator for the ArxNode account type. Used to filter and identify ArxNode accounts on-chain.
|
|
28
47
|
*/
|
|
@@ -38,7 +57,7 @@ const MXE_ACC_DISCRIMINATOR = [103, 26, 85, 250, 179, 159, 17, 117];
|
|
|
38
57
|
/**
|
|
39
58
|
* The public key of the deployed Arcium program on Solana.
|
|
40
59
|
*/
|
|
41
|
-
const ARCIUM_PROGRAM_ID = new anchor__namespace.web3.PublicKey(
|
|
60
|
+
const ARCIUM_PROGRAM_ID = new anchor__namespace.web3.PublicKey(client.ARCIUM_ADDR);
|
|
42
61
|
/**
|
|
43
62
|
* Anchor coder for encoding and decoding Arcium program instructions.
|
|
44
63
|
*/
|
|
@@ -117,40 +136,6 @@ async function getArxNodeAccInfo(arciumProgram, address, commitment) {
|
|
|
117
136
|
async function getCompDefAccInfo(arciumProgram, address, commitment) {
|
|
118
137
|
return arciumProgram.account.computationDefinitionAccount.fetch(address, commitment);
|
|
119
138
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Returns all computation references in the mempool for a given account.
|
|
122
|
-
* Only non-stake computations are included.
|
|
123
|
-
* @param arciumProgram - The Anchor program instance.
|
|
124
|
-
* @param address - The public key of the mempool account.
|
|
125
|
-
* @returns Array of ComputationReference objects.
|
|
126
|
-
*/
|
|
127
|
-
async function getComputationsInMempool(arciumProgram, address) {
|
|
128
|
-
const mempool = await client.getMempoolAccData(arciumProgram.provider, address);
|
|
129
|
-
const startIndex = mempool.inner.computations.startIndex;
|
|
130
|
-
const length = mempool.inner.computations.length;
|
|
131
|
-
const elems = mempool.inner.computations.elems;
|
|
132
|
-
function isValid(validBits, idx) {
|
|
133
|
-
const byte = idx >>> 3;
|
|
134
|
-
const bit = idx & 7;
|
|
135
|
-
if (byte >= validBits.length) {
|
|
136
|
-
// This should never happen, so we'll want to know about it
|
|
137
|
-
throw new Error(`isValid: byte ${byte} >= validBits.length ${validBits.length}`);
|
|
138
|
-
}
|
|
139
|
-
return (validBits[byte] & (1 << bit)) !== 0;
|
|
140
|
-
}
|
|
141
|
-
// Handle circular buffer wraparound
|
|
142
|
-
const refs = [];
|
|
143
|
-
for (let i = 0; i < length; i++) {
|
|
144
|
-
const idx = (startIndex + i) % elems.length;
|
|
145
|
-
// Only save non-stake computations
|
|
146
|
-
if (isValid(mempool.inner.computations.validBits, idx)) {
|
|
147
|
-
refs.push(...elems[idx].entries);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return refs
|
|
151
|
-
.flat()
|
|
152
|
-
.filter((ref) => !isNullRef(ref));
|
|
153
|
-
}
|
|
154
139
|
/**
|
|
155
140
|
* Fetches and parses a given Computation account.
|
|
156
141
|
* @param arciumProgram - The Anchor program instance.
|
|
@@ -176,19 +161,7 @@ async function getArciumAccPubkeys(conn, discriminator) {
|
|
|
176
161
|
});
|
|
177
162
|
return accs.map((acc) => acc.pubkey);
|
|
178
163
|
}
|
|
179
|
-
function isNullRef(ref) {
|
|
180
|
-
const bigZero = new anchor__namespace.BN(0);
|
|
181
|
-
return (ref.computationDefinitionOffset === 0
|
|
182
|
-
&& ref.computationOffset === bigZero
|
|
183
|
-
&& ref.priorityFee === bigZero);
|
|
184
|
-
}
|
|
185
164
|
|
|
186
|
-
const ArciumEventNames = [
|
|
187
|
-
'QueueComputationEvent',
|
|
188
|
-
'InitComputationEvent',
|
|
189
|
-
'CallbackComputationEvent',
|
|
190
|
-
'FinalizeComputationEvent',
|
|
191
|
-
];
|
|
192
165
|
/**
|
|
193
166
|
* Subscribes to computation-related events for a given MXE program ID.
|
|
194
167
|
* @param conn - The Solana connection object.
|
|
@@ -262,17 +235,17 @@ function getComputationEventsFromLogs(logs) {
|
|
|
262
235
|
// Scan all event logs and rely on discriminators to identify valid Arcium events.
|
|
263
236
|
// This works for both MXE→Arcium CPI and Arcium→MXE CPI transactions.
|
|
264
237
|
for (const log of logs) {
|
|
265
|
-
if (log.startsWith(
|
|
266
|
-
const eventData = log.slice(
|
|
238
|
+
if (log.startsWith(PROGRAM_DATA_PREFIX)) {
|
|
239
|
+
const eventData = log.slice(PROGRAM_DATA_PREFIX.length);
|
|
267
240
|
const decoded = ARCIUM_BORSH_CODER.events.decode(eventData);
|
|
268
|
-
if (decoded &&
|
|
241
|
+
if (decoded && ARCIUM_EVENT_NAMES.includes(decoded.name)) {
|
|
269
242
|
events.push(decoded);
|
|
270
243
|
}
|
|
271
244
|
}
|
|
272
|
-
else if (log.startsWith(
|
|
273
|
-
const eventData = log.slice(
|
|
245
|
+
else if (log.startsWith(PROGRAM_LOG_PREFIX)) {
|
|
246
|
+
const eventData = log.slice(PROGRAM_LOG_PREFIX.length);
|
|
274
247
|
const decoded = ARCIUM_BORSH_CODER.events.decode(eventData);
|
|
275
|
-
if (decoded &&
|
|
248
|
+
if (decoded && ARCIUM_EVENT_NAMES.includes(decoded.name)) {
|
|
276
249
|
events.push(decoded);
|
|
277
250
|
}
|
|
278
251
|
}
|
|
@@ -293,9 +266,9 @@ function getComputationEventsFromLogs(logs) {
|
|
|
293
266
|
});
|
|
294
267
|
}
|
|
295
268
|
|
|
296
|
-
Object.defineProperty(exports, "
|
|
269
|
+
Object.defineProperty(exports, "getArciumProgram", {
|
|
297
270
|
enumerable: true,
|
|
298
|
-
get: function () { return client.
|
|
271
|
+
get: function () { return client.getArciumProgram; }
|
|
299
272
|
});
|
|
300
273
|
Object.defineProperty(exports, "getArxNodeAccAddress", {
|
|
301
274
|
enumerable: true,
|
|
@@ -317,6 +290,10 @@ Object.defineProperty(exports, "getComputationAccAddress", {
|
|
|
317
290
|
enumerable: true,
|
|
318
291
|
get: function () { return client.getComputationAccAddress; }
|
|
319
292
|
});
|
|
293
|
+
Object.defineProperty(exports, "getComputationsInMempool", {
|
|
294
|
+
enumerable: true,
|
|
295
|
+
get: function () { return client.getComputationsInMempool; }
|
|
296
|
+
});
|
|
320
297
|
Object.defineProperty(exports, "getExecutingPoolAccAddress", {
|
|
321
298
|
enumerable: true,
|
|
322
299
|
get: function () { return client.getExecutingPoolAccAddress; }
|
|
@@ -333,6 +310,10 @@ Object.defineProperty(exports, "getMempoolAccAddress", {
|
|
|
333
310
|
enumerable: true,
|
|
334
311
|
get: function () { return client.getMempoolAccAddress; }
|
|
335
312
|
});
|
|
313
|
+
Object.defineProperty(exports, "getMempoolPriorityFeeStats", {
|
|
314
|
+
enumerable: true,
|
|
315
|
+
get: function () { return client.getMempoolPriorityFeeStats; }
|
|
316
|
+
});
|
|
336
317
|
exports.getArxNodeAccAddresses = getArxNodeAccAddresses;
|
|
337
318
|
exports.getArxNodeAccInfo = getArxNodeAccInfo;
|
|
338
319
|
exports.getClusterAccAddresses = getClusterAccAddresses;
|
|
@@ -340,7 +321,6 @@ exports.getClusterAccInfo = getClusterAccInfo;
|
|
|
340
321
|
exports.getCompDefAccInfo = getCompDefAccInfo;
|
|
341
322
|
exports.getComputationAccInfo = getComputationAccInfo;
|
|
342
323
|
exports.getComputationOffset = getComputationOffset;
|
|
343
|
-
exports.getComputationsInMempool = getComputationsInMempool;
|
|
344
324
|
exports.getMXEAccAddresses = getMXEAccAddresses;
|
|
345
325
|
exports.getMXEAccInfo = getMXEAccInfo;
|
|
346
326
|
exports.subscribeComputations = subscribeComputations;
|
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArciumIdlType } from '@arcium-hq/client';
|
|
2
|
-
export {
|
|
2
|
+
export { getArciumProgram, getArxNodeAccAddress, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getFeePoolAccAddress, getMXEAccAddress, getMempoolAccAddress, getMempoolPriorityFeeStats } from '@arcium-hq/client';
|
|
3
3
|
import * as anchor from '@coral-xyz/anchor';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -7,9 +7,21 @@ import * as anchor from '@coral-xyz/anchor';
|
|
|
7
7
|
* Many types are derived from the Anchor-generated IDL and are used throughout the reader package.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Solana PublicKey type alias for convenience.
|
|
12
|
+
*/
|
|
10
13
|
type PublicKey = anchor.web3.PublicKey;
|
|
14
|
+
/**
|
|
15
|
+
* Solana Connection type alias for convenience.
|
|
16
|
+
*/
|
|
11
17
|
type Connection = anchor.web3.Connection;
|
|
18
|
+
/**
|
|
19
|
+
* Anchor Program type alias with generic IDL support.
|
|
20
|
+
*/
|
|
12
21
|
type Program<T extends anchor.Idl> = anchor.Program<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Arcium IDL types derived from the Arcium program interface.
|
|
24
|
+
*/
|
|
13
25
|
type ArciumTypes = anchor.IdlTypes<ArciumIdlType>;
|
|
14
26
|
/**
|
|
15
27
|
* All events emitted by the Arcium program, keyed by event name.
|
|
@@ -23,14 +35,42 @@ type ArciumEventName = Capitalize<keyof ArciumEvent>;
|
|
|
23
35
|
* Data structure for any Arcium event, as parsed from logs.
|
|
24
36
|
*/
|
|
25
37
|
type ArciumEventData = ArciumEvent[keyof ArciumEvent];
|
|
38
|
+
/**
|
|
39
|
+
* MXE (Multi-party eXecution Environment) account data structure.
|
|
40
|
+
*/
|
|
26
41
|
type MXEAccount = ArciumTypes['mxeAccount'];
|
|
42
|
+
/**
|
|
43
|
+
* Cluster account data structure containing node information.
|
|
44
|
+
*/
|
|
27
45
|
type ClusterAccount = ArciumTypes['cluster'];
|
|
46
|
+
/**
|
|
47
|
+
* ArxNode account data structure for individual computation nodes.
|
|
48
|
+
*/
|
|
28
49
|
type ArxNodeAccount = ArciumTypes['arxNode'];
|
|
50
|
+
/**
|
|
51
|
+
* Computation account data structure tracking computation state.
|
|
52
|
+
*/
|
|
29
53
|
type ComputationAccount = ArciumTypes['computationAccount'];
|
|
54
|
+
/**
|
|
55
|
+
* Reference to a computation in a mempool or executing pool.
|
|
56
|
+
*/
|
|
30
57
|
type ComputationReference = ArciumTypes['computationReference'];
|
|
58
|
+
/**
|
|
59
|
+
* Computation definition account containing circuit configuration.
|
|
60
|
+
*/
|
|
31
61
|
type ComputationDefinitionAccount = ArciumTypes['computationDefinitionAccount'];
|
|
32
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Queue computation instruction type from the Arcium IDL.
|
|
64
|
+
*/
|
|
65
|
+
type QueueComputationIx = ArciumIdlType['instructions']['26'];
|
|
66
|
+
/**
|
|
67
|
+
* Callback computation instruction type from the Arcium IDL.
|
|
68
|
+
*/
|
|
33
69
|
type CallbackComputationIx = ArciumIdlType['instructions']['3'];
|
|
70
|
+
/**
|
|
71
|
+
* Valid instruction names from the Arcium IDL.
|
|
72
|
+
*/
|
|
73
|
+
type ArciumInstructionName = ArciumIdlType['instructions'][number]['name'];
|
|
34
74
|
/**
|
|
35
75
|
* Status values for a computation, as defined by the Arcium protocol.
|
|
36
76
|
*/
|
|
@@ -86,14 +126,6 @@ declare function getArxNodeAccInfo(arciumProgram: anchor.Program<ArciumIdlType>,
|
|
|
86
126
|
* @returns The ComputationDefinitionAccount object.
|
|
87
127
|
*/
|
|
88
128
|
declare function getCompDefAccInfo(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey, commitment?: anchor.web3.Commitment): Promise<ComputationDefinitionAccount>;
|
|
89
|
-
/**
|
|
90
|
-
* Returns all computation references in the mempool for a given account.
|
|
91
|
-
* Only non-stake computations are included.
|
|
92
|
-
* @param arciumProgram - The Anchor program instance.
|
|
93
|
-
* @param address - The public key of the mempool account.
|
|
94
|
-
* @returns Array of ComputationReference objects.
|
|
95
|
-
*/
|
|
96
|
-
declare function getComputationsInMempool(arciumProgram: anchor.Program<ArciumIdlType>, address: PublicKey): Promise<ComputationReference[]>;
|
|
97
129
|
/**
|
|
98
130
|
* Fetches and parses a given Computation account.
|
|
99
131
|
* @param arciumProgram - The Anchor program instance.
|
|
@@ -125,5 +157,5 @@ declare function unsubscribeComputations(conn: Connection, subscriptionId: numbe
|
|
|
125
157
|
*/
|
|
126
158
|
declare function getComputationOffset(tx: anchor.web3.VersionedTransactionResponse): anchor.BN | undefined;
|
|
127
159
|
|
|
128
|
-
export { getArxNodeAccAddresses, getArxNodeAccInfo, getClusterAccAddresses, getClusterAccInfo, getCompDefAccInfo, getComputationAccInfo, getComputationOffset,
|
|
129
|
-
export type { ArciumEvent, ArciumEventData, ArciumEventName, ArciumTypes, ArxNodeAccount, CallbackComputationIx, ClusterAccount, ComputationAccount, ComputationDefinitionAccount, ComputationReference, ComputationStatus, Connection, MXEAccount, Program, PublicKey, QueueComputationIx };
|
|
160
|
+
export { getArxNodeAccAddresses, getArxNodeAccInfo, getClusterAccAddresses, getClusterAccInfo, getCompDefAccInfo, getComputationAccInfo, getComputationOffset, getMXEAccAddresses, getMXEAccInfo, subscribeComputations, unsubscribeComputations };
|
|
161
|
+
export type { ArciumEvent, ArciumEventData, ArciumEventName, ArciumInstructionName, ArciumTypes, ArxNodeAccount, CallbackComputationIx, ClusterAccount, ComputationAccount, ComputationDefinitionAccount, ComputationReference, ComputationStatus, Connection, MXEAccount, Program, PublicKey, QueueComputationIx };
|
package/build/index.mjs
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { ARCIUM_ADDR, ARCIUM_IDL } from '@arcium-hq/client';
|
|
2
|
+
export { getArciumProgram, getArxNodeAccAddress, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getFeePoolAccAddress, getMXEAccAddress, getMempoolAccAddress, getMempoolPriorityFeeStats } from '@arcium-hq/client';
|
|
3
3
|
import * as anchor from '@coral-xyz/anchor';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Prefix for program data logs in Solana transaction logs.
|
|
7
|
+
* @constant {string}
|
|
8
|
+
*/
|
|
9
|
+
const PROGRAM_DATA_PREFIX = 'Program data: ';
|
|
10
|
+
/**
|
|
11
|
+
* Prefix for program log messages in Solana transaction logs.
|
|
12
|
+
* @constant {string}
|
|
13
|
+
*/
|
|
14
|
+
const PROGRAM_LOG_PREFIX = 'Program log: ';
|
|
15
|
+
/**
|
|
16
|
+
* Valid Arcium event names for computation lifecycle tracking.
|
|
17
|
+
* @constant {ArciumEventName[]}
|
|
18
|
+
*/
|
|
19
|
+
const ARCIUM_EVENT_NAMES = [
|
|
20
|
+
'QueueComputationEvent',
|
|
21
|
+
'InitComputationEvent',
|
|
22
|
+
'CallbackComputationEvent',
|
|
23
|
+
'FinalizeComputationEvent',
|
|
24
|
+
];
|
|
6
25
|
/**
|
|
7
26
|
* Discriminator for the ArxNode account type. Used to filter and identify ArxNode accounts on-chain.
|
|
8
27
|
*/
|
|
@@ -18,7 +37,7 @@ const MXE_ACC_DISCRIMINATOR = [103, 26, 85, 250, 179, 159, 17, 117];
|
|
|
18
37
|
/**
|
|
19
38
|
* The public key of the deployed Arcium program on Solana.
|
|
20
39
|
*/
|
|
21
|
-
const ARCIUM_PROGRAM_ID = new anchor.web3.PublicKey(
|
|
40
|
+
const ARCIUM_PROGRAM_ID = new anchor.web3.PublicKey(ARCIUM_ADDR);
|
|
22
41
|
/**
|
|
23
42
|
* Anchor coder for encoding and decoding Arcium program instructions.
|
|
24
43
|
*/
|
|
@@ -97,40 +116,6 @@ async function getArxNodeAccInfo(arciumProgram, address, commitment) {
|
|
|
97
116
|
async function getCompDefAccInfo(arciumProgram, address, commitment) {
|
|
98
117
|
return arciumProgram.account.computationDefinitionAccount.fetch(address, commitment);
|
|
99
118
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Returns all computation references in the mempool for a given account.
|
|
102
|
-
* Only non-stake computations are included.
|
|
103
|
-
* @param arciumProgram - The Anchor program instance.
|
|
104
|
-
* @param address - The public key of the mempool account.
|
|
105
|
-
* @returns Array of ComputationReference objects.
|
|
106
|
-
*/
|
|
107
|
-
async function getComputationsInMempool(arciumProgram, address) {
|
|
108
|
-
const mempool = await getMempoolAccData(arciumProgram.provider, address);
|
|
109
|
-
const startIndex = mempool.inner.computations.startIndex;
|
|
110
|
-
const length = mempool.inner.computations.length;
|
|
111
|
-
const elems = mempool.inner.computations.elems;
|
|
112
|
-
function isValid(validBits, idx) {
|
|
113
|
-
const byte = idx >>> 3;
|
|
114
|
-
const bit = idx & 7;
|
|
115
|
-
if (byte >= validBits.length) {
|
|
116
|
-
// This should never happen, so we'll want to know about it
|
|
117
|
-
throw new Error(`isValid: byte ${byte} >= validBits.length ${validBits.length}`);
|
|
118
|
-
}
|
|
119
|
-
return (validBits[byte] & (1 << bit)) !== 0;
|
|
120
|
-
}
|
|
121
|
-
// Handle circular buffer wraparound
|
|
122
|
-
const refs = [];
|
|
123
|
-
for (let i = 0; i < length; i++) {
|
|
124
|
-
const idx = (startIndex + i) % elems.length;
|
|
125
|
-
// Only save non-stake computations
|
|
126
|
-
if (isValid(mempool.inner.computations.validBits, idx)) {
|
|
127
|
-
refs.push(...elems[idx].entries);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return refs
|
|
131
|
-
.flat()
|
|
132
|
-
.filter((ref) => !isNullRef(ref));
|
|
133
|
-
}
|
|
134
119
|
/**
|
|
135
120
|
* Fetches and parses a given Computation account.
|
|
136
121
|
* @param arciumProgram - The Anchor program instance.
|
|
@@ -156,19 +141,7 @@ async function getArciumAccPubkeys(conn, discriminator) {
|
|
|
156
141
|
});
|
|
157
142
|
return accs.map((acc) => acc.pubkey);
|
|
158
143
|
}
|
|
159
|
-
function isNullRef(ref) {
|
|
160
|
-
const bigZero = new anchor.BN(0);
|
|
161
|
-
return (ref.computationDefinitionOffset === 0
|
|
162
|
-
&& ref.computationOffset === bigZero
|
|
163
|
-
&& ref.priorityFee === bigZero);
|
|
164
|
-
}
|
|
165
144
|
|
|
166
|
-
const ArciumEventNames = [
|
|
167
|
-
'QueueComputationEvent',
|
|
168
|
-
'InitComputationEvent',
|
|
169
|
-
'CallbackComputationEvent',
|
|
170
|
-
'FinalizeComputationEvent',
|
|
171
|
-
];
|
|
172
145
|
/**
|
|
173
146
|
* Subscribes to computation-related events for a given MXE program ID.
|
|
174
147
|
* @param conn - The Solana connection object.
|
|
@@ -242,17 +215,17 @@ function getComputationEventsFromLogs(logs) {
|
|
|
242
215
|
// Scan all event logs and rely on discriminators to identify valid Arcium events.
|
|
243
216
|
// This works for both MXE→Arcium CPI and Arcium→MXE CPI transactions.
|
|
244
217
|
for (const log of logs) {
|
|
245
|
-
if (log.startsWith(
|
|
246
|
-
const eventData = log.slice(
|
|
218
|
+
if (log.startsWith(PROGRAM_DATA_PREFIX)) {
|
|
219
|
+
const eventData = log.slice(PROGRAM_DATA_PREFIX.length);
|
|
247
220
|
const decoded = ARCIUM_BORSH_CODER.events.decode(eventData);
|
|
248
|
-
if (decoded &&
|
|
221
|
+
if (decoded && ARCIUM_EVENT_NAMES.includes(decoded.name)) {
|
|
249
222
|
events.push(decoded);
|
|
250
223
|
}
|
|
251
224
|
}
|
|
252
|
-
else if (log.startsWith(
|
|
253
|
-
const eventData = log.slice(
|
|
225
|
+
else if (log.startsWith(PROGRAM_LOG_PREFIX)) {
|
|
226
|
+
const eventData = log.slice(PROGRAM_LOG_PREFIX.length);
|
|
254
227
|
const decoded = ARCIUM_BORSH_CODER.events.decode(eventData);
|
|
255
|
-
if (decoded &&
|
|
228
|
+
if (decoded && ARCIUM_EVENT_NAMES.includes(decoded.name)) {
|
|
256
229
|
events.push(decoded);
|
|
257
230
|
}
|
|
258
231
|
}
|
|
@@ -273,4 +246,4 @@ function getComputationEventsFromLogs(logs) {
|
|
|
273
246
|
});
|
|
274
247
|
}
|
|
275
248
|
|
|
276
|
-
export { getArxNodeAccAddresses, getArxNodeAccInfo, getClusterAccAddresses, getClusterAccInfo, getCompDefAccInfo, getComputationAccInfo, getComputationOffset,
|
|
249
|
+
export { getArxNodeAccAddresses, getArxNodeAccInfo, getClusterAccAddresses, getClusterAccInfo, getCompDefAccInfo, getComputationAccInfo, getComputationOffset, getMXEAccAddresses, getMXEAccInfo, subscribeComputations, unsubscribeComputations };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcium-hq/reader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|
|
@@ -31,10 +31,7 @@
|
|
|
31
31
|
"require": "./build/index.cjs"
|
|
32
32
|
}
|
|
33
33
|
],
|
|
34
|
-
"
|
|
35
|
-
"type": "git",
|
|
36
|
-
"url": "https://github.com/arcium-hq/arcium-tooling.git"
|
|
37
|
-
},
|
|
34
|
+
"homepage": "https://ts.arcium.com",
|
|
38
35
|
"devDependencies": {
|
|
39
36
|
"@rollup/plugin-json": "^6.1.0",
|
|
40
37
|
"@rollup/plugin-typescript": "^12.1.1",
|
|
@@ -60,7 +57,7 @@
|
|
|
60
57
|
"@coral-xyz/anchor": "^0.32.1",
|
|
61
58
|
"@noble/curves": "^1.9.5",
|
|
62
59
|
"@noble/hashes": "^1.7.1",
|
|
63
|
-
"@arcium-hq/client": "0.
|
|
60
|
+
"@arcium-hq/client": "0.5.0"
|
|
64
61
|
},
|
|
65
62
|
"keywords": [
|
|
66
63
|
"Cryptography",
|