@arcium-hq/client 0.11.0 → 0.11.2

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.
@@ -296,7 +296,7 @@ export type ArciumStaking = {
296
296
  },
297
297
  {
298
298
  "name": "mint",
299
- "address": "BoVUVSJAhob2cvM5z4JZTdS6VWRSznh3bbzQD1TFjvDP"
299
+ "address": "ARXwZkNAtzPfdcoqQiduJn8EPv9fKiDfGn2KyggyDrFs"
300
300
  },
301
301
  {
302
302
  "name": "poolAccount",
@@ -1136,7 +1136,7 @@ export type ArciumStaking = {
1136
1136
  },
1137
1137
  {
1138
1138
  "name": "mint",
1139
- "address": "BoVUVSJAhob2cvM5z4JZTdS6VWRSznh3bbzQD1TFjvDP"
1139
+ "address": "ARXwZkNAtzPfdcoqQiduJn8EPv9fKiDfGn2KyggyDrFs"
1140
1140
  },
1141
1141
  {
1142
1142
  "name": "poolAccount",
@@ -1852,38 +1852,38 @@ export type ArciumStaking = {
1852
1852
  {
1853
1853
  "kind": "const",
1854
1854
  "value": [
1855
- 160,
1856
- 125,
1857
- 200,
1858
- 55,
1859
- 211,
1860
- 178,
1861
- 66,
1855
+ 140,
1856
+ 2,
1862
1857
  27,
1863
- 149,
1864
- 22,
1865
- 219,
1866
- 191,
1867
- 28,
1868
- 218,
1869
- 171,
1858
+ 73,
1859
+ 195,
1860
+ 17,
1861
+ 0,
1862
+ 246,
1863
+ 183,
1870
1864
  113,
1871
- 92,
1872
- 216,
1873
- 236,
1874
- 165,
1875
- 124,
1876
- 20,
1877
- 89,
1878
- 205,
1879
- 119,
1880
- 106,
1881
- 175,
1882
- 166,
1883
- 185,
1884
- 155,
1885
- 69,
1886
- 242
1865
+ 43,
1866
+ 241,
1867
+ 63,
1868
+ 58,
1869
+ 114,
1870
+ 3,
1871
+ 95,
1872
+ 72,
1873
+ 247,
1874
+ 95,
1875
+ 41,
1876
+ 87,
1877
+ 67,
1878
+ 226,
1879
+ 103,
1880
+ 238,
1881
+ 224,
1882
+ 193,
1883
+ 5,
1884
+ 200,
1885
+ 127,
1886
+ 194
1887
1887
  ]
1888
1888
  }
1889
1889
  ],
@@ -2233,38 +2233,38 @@ export type ArciumStaking = {
2233
2233
  {
2234
2234
  "kind": "const",
2235
2235
  "value": [
2236
- 160,
2237
- 125,
2238
- 200,
2239
- 55,
2240
- 211,
2241
- 178,
2242
- 66,
2236
+ 140,
2237
+ 2,
2243
2238
  27,
2244
- 149,
2245
- 22,
2246
- 219,
2247
- 191,
2248
- 28,
2249
- 218,
2250
- 171,
2239
+ 73,
2240
+ 195,
2241
+ 17,
2242
+ 0,
2243
+ 246,
2244
+ 183,
2251
2245
  113,
2252
- 92,
2253
- 216,
2254
- 236,
2255
- 165,
2256
- 124,
2257
- 20,
2258
- 89,
2259
- 205,
2260
- 119,
2261
- 106,
2262
- 175,
2263
- 166,
2264
- 185,
2265
- 155,
2266
- 69,
2267
- 242
2246
+ 43,
2247
+ 241,
2248
+ 63,
2249
+ 58,
2250
+ 114,
2251
+ 3,
2252
+ 95,
2253
+ 72,
2254
+ 247,
2255
+ 95,
2256
+ 41,
2257
+ 87,
2258
+ 67,
2259
+ 226,
2260
+ 103,
2261
+ 238,
2262
+ 224,
2263
+ 193,
2264
+ 5,
2265
+ 200,
2266
+ 127,
2267
+ 194
2268
2268
  ]
2269
2269
  }
2270
2270
  ],
@@ -2502,38 +2502,38 @@ export type ArciumStaking = {
2502
2502
  {
2503
2503
  "kind": "const",
2504
2504
  "value": [
2505
- 160,
2506
- 125,
2507
- 200,
2508
- 55,
2509
- 211,
2510
- 178,
2511
- 66,
2505
+ 140,
2506
+ 2,
2512
2507
  27,
2513
- 149,
2514
- 22,
2515
- 219,
2516
- 191,
2517
- 28,
2518
- 218,
2519
- 171,
2508
+ 73,
2509
+ 195,
2510
+ 17,
2511
+ 0,
2512
+ 246,
2513
+ 183,
2520
2514
  113,
2521
- 92,
2522
- 216,
2523
- 236,
2524
- 165,
2525
- 124,
2526
- 20,
2527
- 89,
2528
- 205,
2529
- 119,
2530
- 106,
2531
- 175,
2532
- 166,
2533
- 185,
2534
- 155,
2535
- 69,
2536
- 242
2515
+ 43,
2516
+ 241,
2517
+ 63,
2518
+ 58,
2519
+ 114,
2520
+ 3,
2521
+ 95,
2522
+ 72,
2523
+ 247,
2524
+ 95,
2525
+ 41,
2526
+ 87,
2527
+ 67,
2528
+ 226,
2529
+ 103,
2530
+ 238,
2531
+ 224,
2532
+ 193,
2533
+ 5,
2534
+ 200,
2535
+ 127,
2536
+ 194
2537
2537
  ]
2538
2538
  }
2539
2539
  ],
@@ -2977,38 +2977,38 @@ export type ArciumStaking = {
2977
2977
  {
2978
2978
  "kind": "const",
2979
2979
  "value": [
2980
- 160,
2981
- 125,
2982
- 200,
2983
- 55,
2984
- 211,
2985
- 178,
2986
- 66,
2980
+ 140,
2981
+ 2,
2987
2982
  27,
2988
- 149,
2989
- 22,
2990
- 219,
2991
- 191,
2992
- 28,
2993
- 218,
2994
- 171,
2983
+ 73,
2984
+ 195,
2985
+ 17,
2986
+ 0,
2987
+ 246,
2988
+ 183,
2995
2989
  113,
2996
- 92,
2997
- 216,
2998
- 236,
2999
- 165,
3000
- 124,
3001
- 20,
3002
- 89,
3003
- 205,
3004
- 119,
3005
- 106,
3006
- 175,
3007
- 166,
3008
- 185,
3009
- 155,
3010
- 69,
3011
- 242
2990
+ 43,
2991
+ 241,
2992
+ 63,
2993
+ 58,
2994
+ 114,
2995
+ 3,
2996
+ 95,
2997
+ 72,
2998
+ 247,
2999
+ 95,
3000
+ 41,
3001
+ 87,
3002
+ 67,
3003
+ 226,
3004
+ 103,
3005
+ 238,
3006
+ 224,
3007
+ 193,
3008
+ 5,
3009
+ 200,
3010
+ 127,
3011
+ 194
3012
3012
  ]
3013
3013
  }
3014
3014
  ],
@@ -3225,7 +3225,7 @@ export type ArciumStaking = {
3225
3225
  },
3226
3226
  {
3227
3227
  "name": "mint",
3228
- "address": "BoVUVSJAhob2cvM5z4JZTdS6VWRSznh3bbzQD1TFjvDP"
3228
+ "address": "ARXwZkNAtzPfdcoqQiduJn8EPv9fKiDfGn2KyggyDrFs"
3229
3229
  },
3230
3230
  {
3231
3231
  "name": "poolAta",
@@ -3500,7 +3500,7 @@ export type ArciumStaking = {
3500
3500
  },
3501
3501
  {
3502
3502
  "name": "mint",
3503
- "address": "BoVUVSJAhob2cvM5z4JZTdS6VWRSznh3bbzQD1TFjvDP"
3503
+ "address": "ARXwZkNAtzPfdcoqQiduJn8EPv9fKiDfGn2KyggyDrFs"
3504
3504
  },
3505
3505
  {
3506
3506
  "name": "poolAccount",
@@ -3868,7 +3868,7 @@ export type ArciumStaking = {
3868
3868
  },
3869
3869
  {
3870
3870
  "name": "mint",
3871
- "address": "BoVUVSJAhob2cvM5z4JZTdS6VWRSznh3bbzQD1TFjvDP"
3871
+ "address": "ARXwZkNAtzPfdcoqQiduJn8EPv9fKiDfGn2KyggyDrFs"
3872
3872
  },
3873
3873
  {
3874
3874
  "name": "poolAccount",
@@ -4398,7 +4398,7 @@ export type ArciumStaking = {
4398
4398
  },
4399
4399
  {
4400
4400
  "name": "mint",
4401
- "address": "BoVUVSJAhob2cvM5z4JZTdS6VWRSznh3bbzQD1TFjvDP"
4401
+ "address": "ARXwZkNAtzPfdcoqQiduJn8EPv9fKiDfGn2KyggyDrFs"
4402
4402
  },
4403
4403
  {
4404
4404
  "name": "poolAccount",
@@ -4588,6 +4588,26 @@ export type ArciumStaking = {
4588
4588
  {
4589
4589
  "name": "tokenProgram",
4590
4590
  "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
4591
+ },
4592
+ {
4593
+ "name": "arxNode",
4594
+ "docs": [
4595
+ "The `ArxNode` this stake is bound to. Required (and validated against the stored binding)",
4596
+ "on withdrawals when the stake's `binding` is `Node(..)`, so we can read the node's",
4597
+ "cluster and enforce that cluster's minimum primary stake. May be omitted for deposits,",
4598
+ "unbound stakes, or recovery-peer bindings. The `Account` wrapper enforces it's owned by",
4599
+ "the arcium program."
4600
+ ],
4601
+ "optional": true
4602
+ },
4603
+ {
4604
+ "name": "mempool",
4605
+ "docs": [
4606
+ "The mempool account of the cluster the bound node is seated in (or proposed to). Required",
4607
+ "alongside `arx_node` when that node belongs to a cluster. Only its discriminator (the",
4608
+ "mempool size) is read."
4609
+ ],
4610
+ "optional": true
4591
4611
  }
4592
4612
  ],
4593
4613
  "args": [
@@ -5477,6 +5497,26 @@ export type ArciumStaking = {
5477
5497
  "code": 6034,
5478
5498
  "name": "delegatedRemovalNotMatured",
5479
5499
  "msg": "Delegated stake removal has not matured on the primary yet (finalize the primary first)"
5500
+ },
5501
+ {
5502
+ "code": 6035,
5503
+ "name": "insufficientPrimaryStake",
5504
+ "msg": "Resulting primary stake is below the minimum for the bound node's cluster mempool size"
5505
+ },
5506
+ {
5507
+ "code": 6036,
5508
+ "name": "missingNodeAccount",
5509
+ "msg": "Stake is bound to a node; the bound ArxNode account must be provided"
5510
+ },
5511
+ {
5512
+ "code": 6037,
5513
+ "name": "missingMempoolAccount",
5514
+ "msg": "Bound node is seated in a cluster; the cluster's mempool account must be provided"
5515
+ },
5516
+ {
5517
+ "code": 6038,
5518
+ "name": "invalidMempool",
5519
+ "msg": "Provided mempool account does not match the bound node's cluster"
5480
5520
  }
5481
5521
  ],
5482
5522
  "types": [
package/src/idl/index.ts CHANGED
@@ -1,20 +1,33 @@
1
1
  import { Arcium } from './arcium.js';
2
2
  import * as ARCIUM_IDL_MODULE from './arcium.json' with { type: 'json' };
3
+ import { ArciumStaking } from './arcium_staking.js';
4
+ import * as ARCIUM_STAKING_IDL_MODULE from './arcium_staking.json' with { type: 'json' };
3
5
 
4
6
  // Handle both ESM (ts-node wraps as {default: ...}) and bundled (direct) imports
5
7
  const ARCIUM_IDL = ((ARCIUM_IDL_MODULE as { default?: Arcium }).default ?? ARCIUM_IDL_MODULE) as unknown as Arcium;
8
+ const ARCIUM_STAKING_IDL = ((ARCIUM_STAKING_IDL_MODULE as { default?: ArciumStaking }).default ?? ARCIUM_STAKING_IDL_MODULE) as unknown as ArciumStaking;
6
9
 
7
10
  /**
8
11
  * The deployed address of the Arcium program, as specified in the IDL.
9
12
  */
10
13
  export const ARCIUM_ADDR = ARCIUM_IDL.address;
11
14
 
15
+ /**
16
+ * The deployed address of the Arcium staking program, as specified in the IDL.
17
+ */
18
+ export const ARCIUM_STAKING_ADDR = ARCIUM_STAKING_IDL.address;
19
+
12
20
  /**
13
21
  * The Anchor-generated IDL type for the Arcium program.
14
22
  */
15
23
  export type { Arcium as ArciumIdlType };
16
24
 
17
25
  /**
18
- * The Anchor-generated IDL JSON object for the Arcium program.
26
+ * The Anchor-generated IDL type for the Arcium staking program.
27
+ */
28
+ export type { ArciumStaking as ArciumStakingIdlType };
29
+
30
+ /**
31
+ * The Anchor-generated IDL JSON objects for the Arcium programs.
19
32
  */
20
- export { ARCIUM_IDL };
33
+ export { ARCIUM_IDL, ARCIUM_STAKING_IDL };
package/src/onchain.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import anchorPkg, { Program, AnchorProvider } from '@anchor-lang/core';
2
2
  import * as anchor from '@anchor-lang/core';
3
3
  import type { AccountInfo, ConfirmOptions, PublicKey } from '@solana/web3.js';
4
- import { ARCIUM_IDL, ArciumIdlType } from './idl/index.js';
4
+ import { ARCIUM_IDL, ARCIUM_STAKING_IDL, ArciumIdlType } from './idl/index.js';
5
5
  import { sha256 } from './cryptography/cryptography.js';
6
6
  import { Arcium } from './idl/arcium.js';
7
+ import { ArciumStaking } from './idl/arcium_staking.js';
7
8
  import {
8
9
  COMP_DEF_OFFSET_SIZE,
9
10
  DEFAULT_UPLOAD_TX_BATCH_SIZE,
@@ -18,6 +19,7 @@ import {
18
19
  getComputationAccAddress,
19
20
  getCompDefAccAddress,
20
21
  getFeePoolAccAddress,
22
+ getMxeRecoveryStakeStateAccAddress,
21
23
  getRawCircuitAccAddress,
22
24
  getLookupTableAddress,
23
25
  } from './pda.js';
@@ -607,6 +609,15 @@ export function getArciumProgram(provider: AnchorProvider): Program<Arcium> {
607
609
  return new Program(ARCIUM_IDL as unknown as Arcium, provider);
608
610
  }
609
611
 
612
+ /**
613
+ * Return an Anchor program instance for the Arcium staking program.
614
+ * @param provider - Anchor provider to use.
615
+ * @returns Anchor program instance for the Arcium staking program.
616
+ */
617
+ export function getArciumStakingProgram(provider: AnchorProvider): Program<ArciumStaking> {
618
+ return new Program(ARCIUM_STAKING_IDL as unknown as ArciumStaking, provider);
619
+ }
620
+
610
621
  /**
611
622
  * Return the public key and offset for a computation definition account, given the circuit name and MXE program ID.
612
623
  * @param circuitName - Name of the circuit.
@@ -695,6 +706,21 @@ export async function initMxePart2(
695
706
  addressLookupTable: getLookupTableAddress(mxeProgramId, lutOffset),
696
707
  })
697
708
  .transaction();
709
+
710
+ // The Arcium program requires the staking program's initMxeRecoveryStakeState to immediately
711
+ // follow initMxePart2 in the same transaction (enforced by instruction introspection), so the
712
+ // MXE always ships with the recovery-stake state its fee-drain path depends on.
713
+ const recoveryStakeStateIx = await getArciumStakingProgram(provider)
714
+ .methods.initMxeRecoveryStakeState(mxeProgramId)
715
+ .accountsPartial({
716
+ payer: provider.publicKey,
717
+ mxeRecoveryStakeState: getMxeRecoveryStakeStateAccAddress(mxeProgramId),
718
+ instructionsSysvar: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
719
+ systemProgram: anchor.web3.SystemProgram.programId,
720
+ })
721
+ .instruction();
722
+ tx.add(recoveryStakeStateIx);
723
+
698
724
  return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
699
725
  }
700
726
 
package/src/pda.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  MEMPOOL_ACC_SEED,
13
13
  MXE_ACCOUNT_SEED,
14
14
  MXE_RECOVERY_ACC_SEED,
15
+ MXE_RECOVERY_STAKE_STATE_SEED,
15
16
  OPERATOR_ACC_SEED,
16
17
  OFFSET_BUFFER_SIZE,
17
18
  POOL_ACC_SEED,
@@ -19,7 +20,7 @@ import {
19
20
  RECOVERY_CLUSTER_ACC_SEED,
20
21
  RECOVERY_PEER_ACC_SEED,
21
22
  } from './constants.js';
22
- import { ARCIUM_ADDR } from './idl/index.js';
23
+ import { ARCIUM_ADDR, ARCIUM_STAKING_ADDR } from './idl/index.js';
23
24
 
24
25
  const U64_SEED_SIZE = 8;
25
26
  const MAX_U8 = 0xff;
@@ -33,6 +34,14 @@ export function getArciumProgramId(): PublicKey {
33
34
  return new anchor.web3.PublicKey(ARCIUM_ADDR);
34
35
  }
35
36
 
37
+ /**
38
+ * Return the public key of the deployed Arcium staking program on Solana.
39
+ * @returns Arcium staking program's public key.
40
+ */
41
+ export function getArciumStakingProgramId(): PublicKey {
42
+ return new anchor.web3.PublicKey(ARCIUM_STAKING_ADDR);
43
+ }
44
+
36
45
  /**
37
46
  * Derive the computation account address for a given cluster and computation offset.
38
47
  * @param clusterOffset - Offset of the cluster this computation will be executed by.
@@ -132,6 +141,19 @@ export function getMxeRecoveryAccAddress(originalMxeProgramId: PublicKey): Publi
132
141
  return findArciumPda([stringSeed(MXE_RECOVERY_ACC_SEED), pubkeySeed(originalMxeProgramId)]);
133
142
  }
134
143
 
144
+ /**
145
+ * Derive the staking program's MxeRecoveryStakeState PDA for an MXE program.
146
+ * Derived under the staking program, not the Arcium program.
147
+ * @param mxeProgramId - Public key of the MXE program.
148
+ * @returns Derived MxeRecoveryStakeState account public key.
149
+ */
150
+ export function getMxeRecoveryStakeStateAccAddress(mxeProgramId: PublicKey): PublicKey {
151
+ return findPda(getArciumStakingProgramId(), [
152
+ stringSeed(MXE_RECOVERY_STAKE_STATE_SEED),
153
+ pubkeySeed(mxeProgramId),
154
+ ]);
155
+ }
156
+
135
157
  /**
136
158
  * Derive the recovery peer account address for a given recovery peer offset.
137
159
  * @param peerOffset - Recovery peer offset as a u32 in `[0, 2^32 - 1]`.
@@ -3,7 +3,7 @@ import { MAX_RECOVERY_PEERS, MIN_RECOVERY_PEERS } from './constants.js';
3
3
  const MAX_U32 = 0xffffffff;
4
4
 
5
5
  /**
6
- * Mirrors the on-chain `init_mxe_part2` recovery-peer bounds before building the instruction.
6
+ * Mirrors the on-chain `init_mxe_part1` recovery-peer bounds before building the instruction.
7
7
  * @internal
8
8
  */
9
9
  export function assertValidRecoveryPeers(recoveryPeers: readonly number[]): void {