@arcium-hq/client 0.11.1 → 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.
- package/build/index.cjs +7494 -259
- package/build/index.mjs +7490 -260
- package/build/types/constants.d.ts +5 -0
- package/build/types/constants.d.ts.map +1 -1
- package/build/types/idl/arcium.d.ts +1 -1
- package/build/types/idl/arcium_staking.d.ts +40 -0
- package/build/types/idl/arcium_staking.d.ts.map +1 -1
- package/build/types/idl/index.d.ts +12 -2
- package/build/types/idl/index.d.ts.map +1 -1
- package/build/types/onchain.d.ts +7 -0
- package/build/types/onchain.d.ts.map +1 -1
- package/build/types/pda.d.ts +12 -0
- package/build/types/pda.d.ts.map +1 -1
- package/build/types/recoveryPeers.d.ts +1 -1
- package/package.json +1 -1
- package/src/constants.ts +5 -0
- package/src/idl/arcium.json +1 -1
- package/src/idl/arcium.ts +1 -1
- package/src/idl/arcium_staking.ts +40 -0
- package/src/idl/index.ts +15 -2
- package/src/onchain.ts +27 -1
- package/src/pda.ts +23 -1
- package/src/recoveryPeers.ts +1 -1
package/build/types/pda.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ import * as anchor from '@anchor-lang/core';
|
|
|
5
5
|
* @returns Arcium program's public key.
|
|
6
6
|
*/
|
|
7
7
|
export declare function getArciumProgramId(): PublicKey;
|
|
8
|
+
/**
|
|
9
|
+
* Return the public key of the deployed Arcium staking program on Solana.
|
|
10
|
+
* @returns Arcium staking program's public key.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getArciumStakingProgramId(): PublicKey;
|
|
8
13
|
/**
|
|
9
14
|
* Derive the computation account address for a given cluster and computation offset.
|
|
10
15
|
* @param clusterOffset - Offset of the cluster this computation will be executed by.
|
|
@@ -71,6 +76,13 @@ export declare function getRecoveryClusterAccAddress(mxeProgramId: PublicKey): P
|
|
|
71
76
|
* @returns Derived MXE recovery account public key.
|
|
72
77
|
*/
|
|
73
78
|
export declare function getMxeRecoveryAccAddress(originalMxeProgramId: PublicKey): PublicKey;
|
|
79
|
+
/**
|
|
80
|
+
* Derive the staking program's MxeRecoveryStakeState PDA for an MXE program.
|
|
81
|
+
* Derived under the staking program, not the Arcium program.
|
|
82
|
+
* @param mxeProgramId - Public key of the MXE program.
|
|
83
|
+
* @returns Derived MxeRecoveryStakeState account public key.
|
|
84
|
+
*/
|
|
85
|
+
export declare function getMxeRecoveryStakeStateAccAddress(mxeProgramId: PublicKey): PublicKey;
|
|
74
86
|
/**
|
|
75
87
|
* Derive the recovery peer account address for a given recovery peer offset.
|
|
76
88
|
* @param peerOffset - Recovery peer offset as a u32 in `[0, 2^32 - 1]`.
|
package/build/types/pda.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pda.d.ts","sourceRoot":"","sources":["../../src/pda.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"pda.d.ts","sourceRoot":"","sources":["../../src/pda.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,iBAAiB,CAAC;AACvE,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AA2B5C;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,SAAS,CAE9C;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,SAAS,CAErD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,GAAG,SAAS,CAEvG;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAErE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAE3E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,SAA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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mirrors the on-chain `
|
|
2
|
+
* Mirrors the on-chain `init_mxe_part1` recovery-peer bounds before building the instruction.
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
5
|
export declare function assertValidRecoveryPeers(recoveryPeers: readonly number[]): void;
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -53,6 +53,11 @@ export const RECOVERY_CLUSTER_ACC_SEED = 'RecoveryClusterAccount';
|
|
|
53
53
|
* @constant {string}
|
|
54
54
|
*/
|
|
55
55
|
export const MXE_RECOVERY_ACC_SEED = 'MxeRecoveryAccount';
|
|
56
|
+
/**
|
|
57
|
+
* Seed for the staking program's MxeRecoveryStakeState PDA.
|
|
58
|
+
* @constant {string}
|
|
59
|
+
*/
|
|
60
|
+
export const MXE_RECOVERY_STAKE_STATE_SEED = 'MxeRecoveryStakeState';
|
|
56
61
|
/**
|
|
57
62
|
* Seed for ComputationDefinitionRaw PDA.
|
|
58
63
|
* @constant {string}
|
package/src/idl/arcium.json
CHANGED
package/src/idl/arcium.ts
CHANGED
|
@@ -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
|
|
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]`.
|
package/src/recoveryPeers.ts
CHANGED
|
@@ -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 `
|
|
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 {
|