@bench.games/conviction-markets 0.1.1 → 0.1.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.
- package/dist/instructions/addMarketOption.d.ts +8 -8
- package/dist/instructions/addMarketOption.d.ts.map +1 -1
- package/dist/instructions/addMarketOption.js +6 -7
- package/dist/instructions/addMarketOption.js.map +1 -1
- package/dist/instructions/buyMarketShares.d.ts +8 -8
- package/dist/instructions/buyMarketShares.d.ts.map +1 -1
- package/dist/instructions/buyMarketShares.js +16 -25
- package/dist/instructions/buyMarketShares.js.map +1 -1
- package/dist/instructions/claimVoteTokens.d.ts +8 -8
- package/dist/instructions/claimVoteTokens.d.ts.map +1 -1
- package/dist/instructions/claimVoteTokens.js +15 -18
- package/dist/instructions/claimVoteTokens.js.map +1 -1
- package/dist/instructions/closeShareAccount.d.ts +8 -8
- package/dist/instructions/closeShareAccount.d.ts.map +1 -1
- package/dist/instructions/closeShareAccount.js +6 -7
- package/dist/instructions/closeShareAccount.js.map +1 -1
- package/dist/instructions/createMarket.d.ts +8 -8
- package/dist/instructions/createMarket.d.ts.map +1 -1
- package/dist/instructions/createMarket.js +15 -18
- package/dist/instructions/createMarket.js.map +1 -1
- package/dist/instructions/incrementOptionTally.d.ts +7 -7
- package/dist/instructions/incrementOptionTally.d.ts.map +1 -1
- package/dist/instructions/incrementOptionTally.js +6 -6
- package/dist/instructions/incrementOptionTally.js.map +1 -1
- package/dist/instructions/initShareAccount.d.ts +8 -8
- package/dist/instructions/initShareAccount.d.ts.map +1 -1
- package/dist/instructions/initShareAccount.js +7 -8
- package/dist/instructions/initShareAccount.js.map +1 -1
- package/dist/instructions/initVoteTokenAccount.d.ts +8 -8
- package/dist/instructions/initVoteTokenAccount.d.ts.map +1 -1
- package/dist/instructions/initVoteTokenAccount.js +15 -18
- package/dist/instructions/initVoteTokenAccount.js.map +1 -1
- package/dist/instructions/mintVoteTokens.d.ts +8 -8
- package/dist/instructions/mintVoteTokens.d.ts.map +1 -1
- package/dist/instructions/mintVoteTokens.js +15 -18
- package/dist/instructions/mintVoteTokens.js.map +1 -1
- package/dist/instructions/openMarket.d.ts +8 -8
- package/dist/instructions/openMarket.d.ts.map +1 -1
- package/dist/instructions/openMarket.js +6 -7
- package/dist/instructions/openMarket.js.map +1 -1
- package/dist/instructions/revealShares.d.ts +8 -8
- package/dist/instructions/revealShares.d.ts.map +1 -1
- package/dist/instructions/revealShares.js +14 -18
- package/dist/instructions/revealShares.js.map +1 -1
- package/dist/instructions/selectOption.d.ts +8 -8
- package/dist/instructions/selectOption.d.ts.map +1 -1
- package/dist/instructions/selectOption.js +6 -7
- package/dist/instructions/selectOption.js.map +1 -1
- package/dist/utils/arcium.d.ts +62 -1
- package/dist/utils/arcium.d.ts.map +1 -1
- package/dist/utils/arcium.js +92 -2
- package/dist/utils/arcium.js.map +1 -1
- package/dist/utils/encryption.d.ts +5 -9
- package/dist/utils/encryption.d.ts.map +1 -1
- package/dist/utils/encryption.js +8 -13
- package/dist/utils/encryption.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,45 +1,41 @@
|
|
|
1
1
|
import { Program } from "@coral-xyz/anchor";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { deriveVoteTokenAccountPda, deriveShareAccountPda, generateComputationOffset, ARCIUM_CLUSTER_OFFSET, getClusterAddress, } from "../utils";
|
|
2
|
+
import { PROGRAM_ID } from "../constants";
|
|
3
|
+
import { deriveShareAccountPda, generateComputationOffset, ARCIUM_CLUSTER_OFFSET, CLUSTER_ADDRESS, MXE_ADDRESS, MEMPOOL_ADDRESS, EXECUTING_POOL_ADDRESS, COMP_DEF_ADDRESSES, getComputationAccAddress, } from "../utils";
|
|
5
4
|
import IDL from "../idl/conviction_market.json";
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
6
|
+
* Builds a transaction to reveal a user's encrypted shares after staking ends
|
|
8
7
|
*
|
|
9
8
|
* Permissionless - anyone can reveal anyone's shares after the staking
|
|
10
9
|
* period ends and the winning option is selected.
|
|
11
10
|
* Updates share account with revealed amount/option and credits vote
|
|
12
11
|
* token balance back to the user.
|
|
13
12
|
*
|
|
14
|
-
* @param provider - Anchor provider for connection
|
|
13
|
+
* @param provider - Anchor provider for connection
|
|
15
14
|
* @param params - Reveal shares parameters
|
|
16
|
-
* @returns Transaction
|
|
15
|
+
* @returns Transaction to sign and send, share account PDA, and computation offset
|
|
17
16
|
*/
|
|
18
17
|
export async function revealShares(provider, params) {
|
|
19
18
|
const programId = params.programId ?? PROGRAM_ID;
|
|
20
19
|
const program = new Program(IDL, provider);
|
|
21
|
-
|
|
22
|
-
// Derive accounts
|
|
23
|
-
const [voteTokenAccountPda] = deriveVoteTokenAccountPda(params.owner, programId);
|
|
20
|
+
// Derive share account
|
|
24
21
|
const [shareAccountPda] = deriveShareAccountPda(params.owner, params.market, programId);
|
|
25
22
|
// Auto-generate computation offset
|
|
26
23
|
const computationOffset = generateComputationOffset();
|
|
27
|
-
const
|
|
24
|
+
const transaction = await program.methods
|
|
28
25
|
.revealShares(computationOffset, Array.from(params.ownerX25519Keypair.publicKey))
|
|
29
26
|
.accountsPartial({
|
|
30
27
|
owner: params.owner,
|
|
31
28
|
market: params.market,
|
|
32
29
|
computationAccount: getComputationAccAddress(ARCIUM_CLUSTER_OFFSET, computationOffset),
|
|
33
|
-
clusterAccount,
|
|
34
|
-
mxeAccount:
|
|
35
|
-
mempoolAccount:
|
|
36
|
-
executingPool:
|
|
37
|
-
compDefAccount:
|
|
30
|
+
clusterAccount: CLUSTER_ADDRESS,
|
|
31
|
+
mxeAccount: MXE_ADDRESS,
|
|
32
|
+
mempoolAccount: MEMPOOL_ADDRESS,
|
|
33
|
+
executingPool: EXECUTING_POOL_ADDRESS,
|
|
34
|
+
compDefAccount: COMP_DEF_ADDRESSES.REVEAL_SHARES,
|
|
38
35
|
})
|
|
39
|
-
.
|
|
40
|
-
.rpc({ skipPreflight: true });
|
|
36
|
+
.transaction();
|
|
41
37
|
return {
|
|
42
|
-
|
|
38
|
+
transaction,
|
|
43
39
|
shareAccountPda,
|
|
44
40
|
computationOffset,
|
|
45
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revealShares.js","sourceRoot":"","sources":["../../src/instructions/revealShares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,MAAM,mBAAmB,CAAC;AAErE,OAAO,
|
|
1
|
+
{"version":3,"file":"revealShares.js","sourceRoot":"","sources":["../../src/instructions/revealShares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,EACf,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAElB,OAAO,GAAG,MAAM,+BAA+B,CAAC;AA+BhD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAwB,EACxB,MAA0B;IAE1B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,uBAAuB;IACvB,MAAM,CAAC,eAAe,CAAC,GAAG,qBAAqB,CAC7C,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,MAAM,EACb,SAAS,CACV,CAAC;IAEF,mCAAmC;IACnC,MAAM,iBAAiB,GAAG,yBAAyB,EAAE,CAAC;IAEtD,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO;SACtC,YAAY,CACX,iBAAiB,EACjB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAChD;SACA,eAAe,CAAC;QACf,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,kBAAkB,EAAE,wBAAwB,CAC1C,qBAAqB,EACrB,iBAAiB,CAClB;QACD,cAAc,EAAE,eAAe;QAC/B,UAAU,EAAE,WAAW;QACvB,cAAc,EAAE,eAAe;QAC/B,aAAa,EAAE,sBAAsB;QACrC,cAAc,EAAE,kBAAkB,CAAC,aAAa;KACjD,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO;QACL,WAAW;QACX,eAAe;QACf,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
/**
|
|
4
4
|
* Parameters for selecting the winning option
|
|
5
5
|
*/
|
|
6
6
|
export interface SelectOptionParams {
|
|
7
7
|
/** Authority (creator or select_authority) */
|
|
8
|
-
authority:
|
|
8
|
+
authority: PublicKey;
|
|
9
9
|
/** Market PDA */
|
|
10
10
|
market: PublicKey;
|
|
11
11
|
/** Winning option index */
|
|
@@ -14,23 +14,23 @@ export interface SelectOptionParams {
|
|
|
14
14
|
programId?: PublicKey;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Result from
|
|
17
|
+
* Result from building select option transaction
|
|
18
18
|
*/
|
|
19
19
|
export interface SelectOptionResult {
|
|
20
|
-
/** Transaction
|
|
21
|
-
|
|
20
|
+
/** Transaction to sign and send */
|
|
21
|
+
transaction: Transaction;
|
|
22
22
|
/** PDA of the selected option */
|
|
23
23
|
optionPda: PublicKey;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Builds a transaction to select the winning option for a market
|
|
27
27
|
*
|
|
28
28
|
* Can be called by the market creator or designated select_authority.
|
|
29
29
|
* Automatically closes the staking period if still open.
|
|
30
30
|
*
|
|
31
|
-
* @param provider - Anchor provider for connection
|
|
31
|
+
* @param provider - Anchor provider for connection
|
|
32
32
|
* @param params - Select option parameters
|
|
33
|
-
* @returns Transaction
|
|
33
|
+
* @returns Transaction to sign and send, and option PDA
|
|
34
34
|
*/
|
|
35
35
|
export declare function selectOption(provider: AnchorProvider, params: SelectOptionParams): Promise<SelectOptionResult>;
|
|
36
36
|
//# sourceMappingURL=selectOption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectOption.d.ts","sourceRoot":"","sources":["../../src/instructions/selectOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"selectOption.d.ts","sourceRoot":"","sources":["../../src/instructions/selectOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,iCAAiC;IACjC,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAqB7B"}
|
|
@@ -3,26 +3,25 @@ import { PROGRAM_ID } from "../constants";
|
|
|
3
3
|
import { deriveOptionPda } from "../utils";
|
|
4
4
|
import IDL from "../idl/conviction_market.json";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Builds a transaction to select the winning option for a market
|
|
7
7
|
*
|
|
8
8
|
* Can be called by the market creator or designated select_authority.
|
|
9
9
|
* Automatically closes the staking period if still open.
|
|
10
10
|
*
|
|
11
|
-
* @param provider - Anchor provider for connection
|
|
11
|
+
* @param provider - Anchor provider for connection
|
|
12
12
|
* @param params - Select option parameters
|
|
13
|
-
* @returns Transaction
|
|
13
|
+
* @returns Transaction to sign and send, and option PDA
|
|
14
14
|
*/
|
|
15
15
|
export async function selectOption(provider, params) {
|
|
16
16
|
const programId = params.programId ?? PROGRAM_ID;
|
|
17
17
|
const program = new Program(IDL, provider);
|
|
18
|
-
const
|
|
18
|
+
const transaction = await program.methods
|
|
19
19
|
.selectOption(params.optionIndex)
|
|
20
20
|
.accountsPartial({
|
|
21
21
|
market: params.market,
|
|
22
22
|
})
|
|
23
|
-
.
|
|
24
|
-
.rpc();
|
|
23
|
+
.transaction();
|
|
25
24
|
const [optionPda] = deriveOptionPda(params.market, params.optionIndex, programId);
|
|
26
|
-
return {
|
|
25
|
+
return { transaction, optionPda };
|
|
27
26
|
}
|
|
28
27
|
//# sourceMappingURL=selectOption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectOption.js","sourceRoot":"","sources":["../../src/instructions/selectOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AA2BhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAwB,EACxB,MAA0B;IAE1B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,
|
|
1
|
+
{"version":3,"file":"selectOption.js","sourceRoot":"","sources":["../../src/instructions/selectOption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AA2BhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAwB,EACxB,MAA0B;IAE1B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO;SACtC,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC;SAChC,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,MAAM,CAAC,SAAS,CAAC,GAAG,eAAe,CACjC,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,WAAW,EAClB,SAAS,CACV,CAAC;IAEF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AACpC,CAAC"}
|
package/dist/utils/arcium.d.ts
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { BN } from "@coral-xyz/anchor";
|
|
3
|
+
/**
|
|
4
|
+
* Arcium cluster offset for devnet
|
|
5
|
+
*/
|
|
1
6
|
export declare const ARCIUM_CLUSTER_OFFSET = 456;
|
|
2
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Pre-computed Arcium addresses for the cluster
|
|
9
|
+
* These are constant for ARCIUM_CLUSTER_OFFSET = 456
|
|
10
|
+
*/
|
|
11
|
+
export declare const CLUSTER_ADDRESS: PublicKey;
|
|
12
|
+
export declare const MEMPOOL_ADDRESS: PublicKey;
|
|
13
|
+
export declare const EXECUTING_POOL_ADDRESS: PublicKey;
|
|
14
|
+
/**
|
|
15
|
+
* Pre-computed MXE address for the program
|
|
16
|
+
*/
|
|
17
|
+
export declare const MXE_ADDRESS: PublicKey;
|
|
18
|
+
/**
|
|
19
|
+
* Pre-computed MXE X25519 public key for encryption
|
|
20
|
+
* This is the encryption key used for MPC computations
|
|
21
|
+
*/
|
|
22
|
+
export declare const MXE_X25519_PUBKEY: Uint8Array<ArrayBuffer>;
|
|
23
|
+
/**
|
|
24
|
+
* Pre-computed computation definition addresses
|
|
25
|
+
* These are constant for the program and computation definition names
|
|
26
|
+
*/
|
|
27
|
+
export declare const COMP_DEF_ADDRESSES: {
|
|
28
|
+
readonly INIT_VOTE_TOKEN_ACCOUNT: PublicKey;
|
|
29
|
+
readonly BUY_VOTE_TOKENS: PublicKey;
|
|
30
|
+
readonly CLAIM_VOTE_TOKENS: PublicKey;
|
|
31
|
+
readonly BUY_CONVICTION_MARKET_SHARES: PublicKey;
|
|
32
|
+
readonly INIT_MARKET_SHARES: PublicKey;
|
|
33
|
+
readonly REVEAL_SHARES: PublicKey;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Returns the cluster address
|
|
37
|
+
* @deprecated Use CLUSTER_ADDRESS constant instead
|
|
38
|
+
*/
|
|
39
|
+
export declare function getClusterAddress(): PublicKey;
|
|
40
|
+
/**
|
|
41
|
+
* Derives the computation account address for a given offset
|
|
42
|
+
* This replicates the PDA derivation from Arcium's getComputationAccAddress
|
|
43
|
+
*
|
|
44
|
+
* @param clusterOffset - The cluster offset (should be ARCIUM_CLUSTER_OFFSET)
|
|
45
|
+
* @param computationOffset - The unique computation offset
|
|
46
|
+
* @returns The computation account public key
|
|
47
|
+
*/
|
|
48
|
+
export declare function getComputationAccAddress(clusterOffset: number, computationOffset: BN): PublicKey;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the MXE address for the program
|
|
51
|
+
* @deprecated Use MXE_ADDRESS constant instead
|
|
52
|
+
*/
|
|
53
|
+
export declare function getMXEAccAddress(): PublicKey;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the mempool address
|
|
56
|
+
* @deprecated Use MEMPOOL_ADDRESS constant instead
|
|
57
|
+
*/
|
|
58
|
+
export declare function getMempoolAccAddress(): PublicKey;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the executing pool address
|
|
61
|
+
* @deprecated Use EXECUTING_POOL_ADDRESS constant instead
|
|
62
|
+
*/
|
|
63
|
+
export declare function getExecutingPoolAccAddress(): PublicKey;
|
|
3
64
|
//# sourceMappingURL=arcium.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arcium.d.ts","sourceRoot":"","sources":["../../src/utils/arcium.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"arcium.d.ts","sourceRoot":"","sources":["../../src/utils/arcium.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,eAAe,WAE3B,CAAC;AACF,eAAO,MAAM,eAAe,WAE3B,CAAC;AACF,eAAO,MAAM,sBAAsB,WAElC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,WAEvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,yBAG5B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;CAmBrB,CAAC;AAEX;;;GAGG;AACH,wBAAgB,iBAAiB,cAEhC;AAcD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,EAAE,GACpB,SAAS,CAwBX;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,SAAS,CAE5C;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,SAAS,CAEhD;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,SAAS,CAEtD"}
|
package/dist/utils/arcium.js
CHANGED
|
@@ -1,6 +1,96 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Arcium cluster offset for devnet
|
|
4
|
+
*/
|
|
2
5
|
export const ARCIUM_CLUSTER_OFFSET = 456;
|
|
6
|
+
/**
|
|
7
|
+
* Pre-computed Arcium addresses for the cluster
|
|
8
|
+
* These are constant for ARCIUM_CLUSTER_OFFSET = 456
|
|
9
|
+
*/
|
|
10
|
+
export const CLUSTER_ADDRESS = new PublicKey("DzaQCyfybroycrNqE5Gk7LhSbWD2qfCics6qptBFbr95");
|
|
11
|
+
export const MEMPOOL_ADDRESS = new PublicKey("Ex7BD8o8PK1y2eXDd38Jgujj93uHygrZeWXDeGAHmHtN");
|
|
12
|
+
export const EXECUTING_POOL_ADDRESS = new PublicKey("4mcrgNZzJwwKrE3wXMHfepT8htSBmGqBzDYPJijWooog");
|
|
13
|
+
/**
|
|
14
|
+
* Pre-computed MXE address for the program
|
|
15
|
+
*/
|
|
16
|
+
export const MXE_ADDRESS = new PublicKey("9ZtprvNpFCzxuKewDRpmByWLXrxFfGZcrfY6TZTdpvGu");
|
|
17
|
+
/**
|
|
18
|
+
* Pre-computed MXE X25519 public key for encryption
|
|
19
|
+
* This is the encryption key used for MPC computations
|
|
20
|
+
*/
|
|
21
|
+
export const MXE_X25519_PUBKEY = new Uint8Array([
|
|
22
|
+
86, 128, 27, 68, 105, 225, 151, 107, 234, 191, 106, 144, 73, 64, 231, 222,
|
|
23
|
+
106, 54, 63, 75, 115, 210, 248, 234, 23, 107, 255, 189, 49, 228, 35, 32,
|
|
24
|
+
]);
|
|
25
|
+
/**
|
|
26
|
+
* Pre-computed computation definition addresses
|
|
27
|
+
* These are constant for the program and computation definition names
|
|
28
|
+
*/
|
|
29
|
+
export const COMP_DEF_ADDRESSES = {
|
|
30
|
+
INIT_VOTE_TOKEN_ACCOUNT: new PublicKey("8cJL5BUsL8RtZfZ221M787Vm5kYptFUY65HEZRnX8J6U"),
|
|
31
|
+
BUY_VOTE_TOKENS: new PublicKey("6tqXdWgxnLVn9iVgaMR5rHezWBWJNAEHYq9TLcM9Qu1B"),
|
|
32
|
+
CLAIM_VOTE_TOKENS: new PublicKey("BMbKGJUuSEf198ZNWrFfihBG5PhC6fbLeVRheYpyyzW9"),
|
|
33
|
+
BUY_CONVICTION_MARKET_SHARES: new PublicKey("7DZfQXSRViCZUyzdCxbJnTPgVJJZ4H7a2PZyLfcmp8Np"),
|
|
34
|
+
INIT_MARKET_SHARES: new PublicKey("3PoitQnNeBTDUvPBm8NRDn8tgfvK2rTBFHS2xzZv72tb"),
|
|
35
|
+
REVEAL_SHARES: new PublicKey("DUDK7NEvBXta65uqSX12TNEcNSJYoterhVB9nfkfhA8f"),
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Returns the cluster address
|
|
39
|
+
* @deprecated Use CLUSTER_ADDRESS constant instead
|
|
40
|
+
*/
|
|
3
41
|
export function getClusterAddress() {
|
|
4
|
-
return
|
|
42
|
+
return CLUSTER_ADDRESS;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Arcium program ID for PDA derivation
|
|
46
|
+
*/
|
|
47
|
+
const ARCIUM_PROGRAM_ID = new PublicKey("ARCGL1vmM2YKqmxjVV8LaD9Qi98N2CvT6jjzk6QmqLM");
|
|
48
|
+
/**
|
|
49
|
+
* Computation account seed constant
|
|
50
|
+
*/
|
|
51
|
+
const COMPUTATION_ACC_SEED = "ComputationAccount";
|
|
52
|
+
/**
|
|
53
|
+
* Derives the computation account address for a given offset
|
|
54
|
+
* This replicates the PDA derivation from Arcium's getComputationAccAddress
|
|
55
|
+
*
|
|
56
|
+
* @param clusterOffset - The cluster offset (should be ARCIUM_CLUSTER_OFFSET)
|
|
57
|
+
* @param computationOffset - The unique computation offset
|
|
58
|
+
* @returns The computation account public key
|
|
59
|
+
*/
|
|
60
|
+
export function getComputationAccAddress(clusterOffset, computationOffset) {
|
|
61
|
+
// Convert cluster offset to buffer (u32 LE)
|
|
62
|
+
const clusterOffsetBuffer = Buffer.alloc(4);
|
|
63
|
+
clusterOffsetBuffer.writeUInt32LE(clusterOffset, 0);
|
|
64
|
+
// Convert computation offset to buffer (u64 LE) using BN's toArrayLike
|
|
65
|
+
const computationOffsetBuffer = computationOffset.toArrayLike(Buffer, "le", 8);
|
|
66
|
+
// The computation account PDA is derived with seeds:
|
|
67
|
+
// ["ComputationAccount", cluster_offset_bytes, computation_offset_bytes]
|
|
68
|
+
const [computationAddress] = PublicKey.findProgramAddressSync([
|
|
69
|
+
Buffer.from(COMPUTATION_ACC_SEED),
|
|
70
|
+
clusterOffsetBuffer,
|
|
71
|
+
computationOffsetBuffer,
|
|
72
|
+
], ARCIUM_PROGRAM_ID);
|
|
73
|
+
return computationAddress;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns the MXE address for the program
|
|
77
|
+
* @deprecated Use MXE_ADDRESS constant instead
|
|
78
|
+
*/
|
|
79
|
+
export function getMXEAccAddress() {
|
|
80
|
+
return MXE_ADDRESS;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns the mempool address
|
|
84
|
+
* @deprecated Use MEMPOOL_ADDRESS constant instead
|
|
85
|
+
*/
|
|
86
|
+
export function getMempoolAccAddress() {
|
|
87
|
+
return MEMPOOL_ADDRESS;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Returns the executing pool address
|
|
91
|
+
* @deprecated Use EXECUTING_POOL_ADDRESS constant instead
|
|
92
|
+
*/
|
|
93
|
+
export function getExecutingPoolAccAddress() {
|
|
94
|
+
return EXECUTING_POOL_ADDRESS;
|
|
5
95
|
}
|
|
6
96
|
//# sourceMappingURL=arcium.js.map
|
package/dist/utils/arcium.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arcium.js","sourceRoot":"","sources":["../../src/utils/arcium.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"arcium.js","sourceRoot":"","sources":["../../src/utils/arcium.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,SAAS,CAC1C,8CAA8C,CAC/C,CAAC;AACF,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,SAAS,CAC1C,8CAA8C,CAC/C,CAAC;AACF,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,SAAS,CACjD,8CAA8C,CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,SAAS,CACtC,8CAA8C,CAC/C,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,UAAU,CAAC;IAC9C,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG;IACzE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE;CACxE,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,uBAAuB,EAAE,IAAI,SAAS,CACpC,8CAA8C,CAC/C;IACD,eAAe,EAAE,IAAI,SAAS,CAC5B,8CAA8C,CAC/C;IACD,iBAAiB,EAAE,IAAI,SAAS,CAC9B,8CAA8C,CAC/C;IACD,4BAA4B,EAAE,IAAI,SAAS,CACzC,8CAA8C,CAC/C;IACD,kBAAkB,EAAE,IAAI,SAAS,CAC/B,8CAA8C,CAC/C;IACD,aAAa,EAAE,IAAI,SAAS,CAC1B,8CAA8C,CAC/C;CACO,CAAC;AAEX;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,iBAAiB,GAAG,IAAI,SAAS,CACrC,6CAA6C,CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,aAAqB,EACrB,iBAAqB;IAErB,4CAA4C;IAC5C,MAAM,mBAAmB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5C,mBAAmB,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IAEpD,uEAAuE;IACvE,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,WAAW,CAC3D,MAAM,EACN,IAAI,EACJ,CAAC,CACF,CAAC;IAEF,qDAAqD;IACrD,yEAAyE;IACzE,MAAM,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC,sBAAsB,CAC3D;QACE,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC;QACjC,mBAAmB;QACnB,uBAAuB;KACxB,EACD,iBAAiB,CAClB,CAAC;IAEF,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,sBAAsB,CAAC;AAChC,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { RescueCipher } from "@arcium-hq/client";
|
|
2
|
-
import type { AnchorProvider } from "@coral-xyz/anchor";
|
|
3
|
-
import type { PublicKey } from "@solana/web3.js";
|
|
4
2
|
import type { X25519Keypair } from "../types";
|
|
5
3
|
/**
|
|
6
4
|
* Encryption context for working with encrypted data
|
|
@@ -12,13 +10,11 @@ export interface EncryptionContext {
|
|
|
12
10
|
x25519Keypair: X25519Keypair;
|
|
13
11
|
}
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param provider - Anchor provider
|
|
18
|
-
* @param programId - Program ID
|
|
13
|
+
* Returns the MXE X25519 public key
|
|
14
|
+
* @deprecated This is now a constant, use MXE_X25519_PUBKEY directly
|
|
19
15
|
* @returns The MXE's X25519 public key
|
|
20
16
|
*/
|
|
21
|
-
export declare function fetchMXEPublicKey(
|
|
17
|
+
export declare function fetchMXEPublicKey(): Uint8Array;
|
|
22
18
|
/**
|
|
23
19
|
* Creates an encryption context for a user
|
|
24
20
|
*
|
|
@@ -26,10 +22,10 @@ export declare function fetchMXEPublicKey(provider: AnchorProvider, programId: P
|
|
|
26
22
|
* for encryption/decryption operations.
|
|
27
23
|
*
|
|
28
24
|
* @param x25519Keypair - User's X25519 keypair
|
|
29
|
-
* @param mxePublicKey - MXE's public key (
|
|
25
|
+
* @param mxePublicKey - MXE's public key (defaults to MXE_X25519_PUBKEY if not provided)
|
|
30
26
|
* @returns Encryption context with cipher
|
|
31
27
|
*/
|
|
32
|
-
export declare function createEncryptionContext(x25519Keypair: X25519Keypair, mxePublicKey
|
|
28
|
+
export declare function createEncryptionContext(x25519Keypair: X25519Keypair, mxePublicKey?: Uint8Array): EncryptionContext;
|
|
33
29
|
/**
|
|
34
30
|
* Encrypts values for buying market shares
|
|
35
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/utils/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,YAAY,
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/utils/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,MAAM,EAAE,YAAY,CAAC;IACrB,4BAA4B;IAC5B,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,UAAU,CAE9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,aAAa,EAC5B,YAAY,GAAE,UAA8B,GAC3C,iBAAiB,CAWnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,UAAU,GAChB;IACD,gBAAgB,EAAE,UAAU,CAAC;IAC7B,wBAAwB,EAAE,UAAU,CAAC;CACtC,CAWA"}
|
package/dist/utils/encryption.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { x25519, RescueCipher
|
|
1
|
+
import { x25519, RescueCipher } from "@arcium-hq/client";
|
|
2
|
+
import { MXE_X25519_PUBKEY } from "./arcium";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @param provider - Anchor provider
|
|
6
|
-
* @param programId - Program ID
|
|
4
|
+
* Returns the MXE X25519 public key
|
|
5
|
+
* @deprecated This is now a constant, use MXE_X25519_PUBKEY directly
|
|
7
6
|
* @returns The MXE's X25519 public key
|
|
8
7
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
if (!key) {
|
|
12
|
-
throw new Error("Failed to fetch MXE public key");
|
|
13
|
-
}
|
|
14
|
-
return key;
|
|
8
|
+
export function fetchMXEPublicKey() {
|
|
9
|
+
return MXE_X25519_PUBKEY;
|
|
15
10
|
}
|
|
16
11
|
/**
|
|
17
12
|
* Creates an encryption context for a user
|
|
@@ -20,10 +15,10 @@ export async function fetchMXEPublicKey(provider, programId) {
|
|
|
20
15
|
* for encryption/decryption operations.
|
|
21
16
|
*
|
|
22
17
|
* @param x25519Keypair - User's X25519 keypair
|
|
23
|
-
* @param mxePublicKey - MXE's public key (
|
|
18
|
+
* @param mxePublicKey - MXE's public key (defaults to MXE_X25519_PUBKEY if not provided)
|
|
24
19
|
* @returns Encryption context with cipher
|
|
25
20
|
*/
|
|
26
|
-
export function createEncryptionContext(x25519Keypair, mxePublicKey) {
|
|
21
|
+
export function createEncryptionContext(x25519Keypair, mxePublicKey = MXE_X25519_PUBKEY) {
|
|
27
22
|
const sharedSecret = x25519.getSharedSecret(x25519Keypair.secretKey, mxePublicKey);
|
|
28
23
|
const cipher = new RescueCipher(sharedSecret);
|
|
29
24
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.js","sourceRoot":"","sources":["../../src/utils/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"encryption.js","sourceRoot":"","sources":["../../src/utils/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAY7C;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CACrC,aAA4B,EAC5B,eAA2B,iBAAiB;IAE5C,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CACzC,aAAa,CAAC,SAAS,EACvB,YAAY,CACb,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;IAE9C,OAAO;QACL,MAAM;QACN,aAAa;KACd,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAA0B,EAC1B,MAAc,EACd,cAAsB,EACtB,KAAiB;IAKjB,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,KAAK,CAAC,CAAC;IAE5E,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;IAED,OAAO;QACL,gBAAgB,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAChD,wBAAwB,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;KACzD,CAAC;AACJ,CAAC"}
|