@bench.games/conviction-markets 0.1.0 → 0.1.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/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 +9 -11
- 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 +8 -9
- 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 +8 -9
- 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 +8 -9
- 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 +8 -9
- 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 +6 -7
- 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/keypairs.d.ts +6 -0
- package/dist/utils/keypairs.d.ts.map +1 -1
- package/dist/utils/keypairs.js +11 -0
- package/dist/utils/keypairs.js.map +1 -1
- package/package.json +21 -21
|
@@ -2,26 +2,26 @@ import { Program } from "@coral-xyz/anchor";
|
|
|
2
2
|
import { PROGRAM_ID } from "../constants";
|
|
3
3
|
import IDL from "../idl/conviction_market.json";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Builds a transaction to increment the tally for an option after shares are revealed
|
|
6
6
|
*
|
|
7
7
|
* This is permissionless - anyone can call it for any revealed share account.
|
|
8
8
|
* Calculates conviction score (amount * time-in-market) and adds it to the
|
|
9
9
|
* option's total. Each share account can only increment once.
|
|
10
10
|
*
|
|
11
|
-
* @param provider - Anchor provider for connection
|
|
11
|
+
* @param provider - Anchor provider for connection
|
|
12
12
|
* @param params - Increment option tally parameters
|
|
13
|
-
* @returns Transaction
|
|
13
|
+
* @returns Transaction to sign and send
|
|
14
14
|
*/
|
|
15
15
|
export async function incrementOptionTally(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
|
.incrementOptionTally(params.optionIndex)
|
|
20
20
|
.accountsPartial({
|
|
21
21
|
market: params.market,
|
|
22
22
|
owner: params.owner,
|
|
23
23
|
})
|
|
24
|
-
.
|
|
25
|
-
return {
|
|
24
|
+
.transaction();
|
|
25
|
+
return { transaction };
|
|
26
26
|
}
|
|
27
27
|
//# sourceMappingURL=incrementOptionTally.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incrementOptionTally.js","sourceRoot":"","sources":["../../src/instructions/incrementOptionTally.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAyBhD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAwB,EACxB,MAAkC;IAElC,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":"incrementOptionTally.js","sourceRoot":"","sources":["../../src/instructions/incrementOptionTally.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAyBhD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAwB,EACxB,MAAkC;IAElC,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,oBAAoB,CAAC,MAAM,CAAC,WAAW,CAAC;SACxC,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -1,34 +1,34 @@
|
|
|
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 initializing a share account
|
|
5
5
|
*/
|
|
6
6
|
export interface InitShareAccountParams {
|
|
7
7
|
/** User creating the share account */
|
|
8
|
-
signer:
|
|
8
|
+
signer: PublicKey;
|
|
9
9
|
/** Market PDA to create share account for */
|
|
10
10
|
market: PublicKey;
|
|
11
11
|
/** Optional program ID (defaults to PROGRAM_ID) */
|
|
12
12
|
programId?: PublicKey;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Result from
|
|
15
|
+
* Result from building init share account transaction
|
|
16
16
|
*/
|
|
17
17
|
export interface InitShareAccountResult {
|
|
18
|
-
/** Transaction
|
|
19
|
-
|
|
18
|
+
/** Transaction to sign and send */
|
|
19
|
+
transaction: Transaction;
|
|
20
20
|
/** PDA of the created share account */
|
|
21
21
|
shareAccountPda: PublicKey;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Builds a transaction to initialize a share account for a user in a specific market
|
|
25
25
|
*
|
|
26
26
|
* This must be called before buying shares. The share account will
|
|
27
27
|
* store the user's encrypted position (shares + selected option).
|
|
28
28
|
*
|
|
29
|
-
* @param provider - Anchor provider for connection
|
|
29
|
+
* @param provider - Anchor provider for connection
|
|
30
30
|
* @param params - Init share account parameters
|
|
31
|
-
* @returns Transaction
|
|
31
|
+
* @returns Transaction to sign and send, and share account PDA
|
|
32
32
|
*/
|
|
33
33
|
export declare function initShareAccount(provider: AnchorProvider, params: InitShareAccountParams): Promise<InitShareAccountResult>;
|
|
34
34
|
//# sourceMappingURL=initShareAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initShareAccount.d.ts","sourceRoot":"","sources":["../../src/instructions/initShareAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAiB,KAAK,
|
|
1
|
+
{"version":3,"file":"initShareAccount.d.ts","sourceRoot":"","sources":["../../src/instructions/initShareAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAiB,KAAK,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM7E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,sCAAsC;IACtC,MAAM,EAAE,SAAS,CAAC;IAClB,6CAA6C;IAC7C,MAAM,EAAE,SAAS,CAAC;IAClB,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,uCAAuC;IACvC,eAAe,EAAE,SAAS,CAAC;CAC5B;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,sBAAsB,CAAC,CA0BjC"}
|
|
@@ -4,30 +4,29 @@ import { PROGRAM_ID } from "../constants";
|
|
|
4
4
|
import { deriveShareAccountPda, generateNonce, nonceToU128 } from "../utils";
|
|
5
5
|
import IDL from "../idl/conviction_market.json";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Builds a transaction to initialize a share account for a user in a specific market
|
|
8
8
|
*
|
|
9
9
|
* This must be called before buying shares. The share account will
|
|
10
10
|
* store the user's encrypted position (shares + selected option).
|
|
11
11
|
*
|
|
12
|
-
* @param provider - Anchor provider for connection
|
|
12
|
+
* @param provider - Anchor provider for connection
|
|
13
13
|
* @param params - Init share account parameters
|
|
14
|
-
* @returns Transaction
|
|
14
|
+
* @returns Transaction to sign and send, and share account PDA
|
|
15
15
|
*/
|
|
16
16
|
export async function initShareAccount(provider, params) {
|
|
17
17
|
const programId = params.programId ?? PROGRAM_ID;
|
|
18
18
|
const program = new Program(IDL, provider);
|
|
19
|
-
const [shareAccountPda] = deriveShareAccountPda(params.signer
|
|
19
|
+
const [shareAccountPda] = deriveShareAccountPda(params.signer, params.market, programId);
|
|
20
20
|
// Generate random nonce for encrypted state
|
|
21
21
|
const nonce = generateNonce();
|
|
22
22
|
const nonceBN = nonceToU128(nonce);
|
|
23
|
-
const
|
|
23
|
+
const transaction = await program.methods
|
|
24
24
|
.initShareAccount(nonceBN)
|
|
25
25
|
.accountsPartial({
|
|
26
26
|
market: params.market,
|
|
27
27
|
systemProgram: SystemProgram.programId,
|
|
28
28
|
})
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
return { signature, shareAccountPda };
|
|
29
|
+
.transaction();
|
|
30
|
+
return { transaction, shareAccountPda };
|
|
32
31
|
}
|
|
33
32
|
//# sourceMappingURL=initShareAccount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initShareAccount.js","sourceRoot":"","sources":["../../src/instructions/initShareAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"initShareAccount.js","sourceRoot":"","sources":["../../src/instructions/initShareAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,aAAa,EAA+B,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAyBhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAwB,EACxB,MAA8B;IAE9B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,CAAC,eAAe,CAAC,GAAG,qBAAqB,CAC7C,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,MAAM,EACb,SAAS,CACV,CAAC;IAEF,4CAA4C;IAC5C,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAEnC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO;SACtC,gBAAgB,CAAC,OAAO,CAAC;SACzB,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,aAAa,EAAE,aAAa,CAAC,SAAS;KACvC,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import { BN, type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import { type
|
|
2
|
+
import { type PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
import type { X25519Keypair } from "../types";
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for initializing a vote token account
|
|
6
6
|
*/
|
|
7
7
|
export interface InitVoteTokenAccountParams {
|
|
8
8
|
/** User creating the vote token account */
|
|
9
|
-
signer:
|
|
9
|
+
signer: PublicKey;
|
|
10
10
|
/** User's X25519 keypair for encryption */
|
|
11
11
|
userX25519Keypair: X25519Keypair;
|
|
12
12
|
/** Optional program ID (defaults to PROGRAM_ID) */
|
|
13
13
|
programId?: PublicKey;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Result from
|
|
16
|
+
* Result from building init vote token account transaction
|
|
17
17
|
*/
|
|
18
18
|
export interface InitVoteTokenAccountResult {
|
|
19
|
-
/** Transaction
|
|
20
|
-
|
|
19
|
+
/** Transaction to sign and send */
|
|
20
|
+
transaction: Transaction;
|
|
21
21
|
/** PDA of the created vote token account */
|
|
22
22
|
voteTokenAccountPda: PublicKey;
|
|
23
23
|
/** Computation offset (pass to awaitComputationFinalization) */
|
|
24
24
|
computationOffset: BN;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Builds a transaction to initialize a vote token account via encrypted computation
|
|
28
28
|
*
|
|
29
29
|
* Sets up the encrypted balance state for a user. Must be called before
|
|
30
30
|
* minting vote tokens.
|
|
31
31
|
*
|
|
32
|
-
* @param provider - Anchor provider for connection
|
|
32
|
+
* @param provider - Anchor provider for connection
|
|
33
33
|
* @param params - Init vote token account parameters
|
|
34
|
-
* @returns Transaction
|
|
34
|
+
* @returns Transaction to sign and send, vote token account PDA, and computation offset
|
|
35
35
|
*/
|
|
36
36
|
export declare function initVoteTokenAccount(provider: AnchorProvider, params: InitVoteTokenAccountParams): Promise<InitVoteTokenAccountResult>;
|
|
37
37
|
//# sourceMappingURL=initVoteTokenAccount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initVoteTokenAccount.d.ts","sourceRoot":"","sources":["../../src/instructions/initVoteTokenAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAiB,KAAK,
|
|
1
|
+
{"version":3,"file":"initVoteTokenAccount.d.ts","sourceRoot":"","sources":["../../src/instructions/initVoteTokenAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAiB,KAAK,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAkB7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,2CAA2C;IAC3C,MAAM,EAAE,SAAS,CAAC;IAClB,2CAA2C;IAC3C,iBAAiB,EAAE,aAAa,CAAC;IACjC,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,4CAA4C;IAC5C,mBAAmB,EAAE,SAAS,CAAC;IAC/B,gEAAgE;IAChE,iBAAiB,EAAE,EAAE,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,0BAA0B,CAAC,CAoDrC"}
|
|
@@ -5,29 +5,29 @@ import { PROGRAM_ID, COMP_DEF_OFFSETS } from "../constants";
|
|
|
5
5
|
import { deriveVoteTokenAccountPda, generateComputationOffset, generateNonce, nonceToU128, ARCIUM_CLUSTER_OFFSET, getClusterAddress, } from "../utils";
|
|
6
6
|
import IDL from "../idl/conviction_market.json";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Builds a transaction to initialize a vote token account via encrypted computation
|
|
9
9
|
*
|
|
10
10
|
* Sets up the encrypted balance state for a user. Must be called before
|
|
11
11
|
* minting vote tokens.
|
|
12
12
|
*
|
|
13
|
-
* @param provider - Anchor provider for connection
|
|
13
|
+
* @param provider - Anchor provider for connection
|
|
14
14
|
* @param params - Init vote token account parameters
|
|
15
|
-
* @returns Transaction
|
|
15
|
+
* @returns Transaction to sign and send, vote token account PDA, and computation offset
|
|
16
16
|
*/
|
|
17
17
|
export async function initVoteTokenAccount(provider, params) {
|
|
18
18
|
const programId = params.programId ?? PROGRAM_ID;
|
|
19
19
|
const program = new Program(IDL, provider);
|
|
20
20
|
const clusterAccount = getClusterAddress();
|
|
21
21
|
// Derive vote token account PDA
|
|
22
|
-
const [voteTokenAccountPda] = deriveVoteTokenAccountPda(params.signer
|
|
22
|
+
const [voteTokenAccountPda] = deriveVoteTokenAccountPda(params.signer, programId);
|
|
23
23
|
// Auto-generate computation offset and nonce
|
|
24
24
|
const computationOffset = generateComputationOffset();
|
|
25
25
|
const nonce = generateNonce();
|
|
26
26
|
const nonceBN = nonceToU128(nonce);
|
|
27
|
-
const
|
|
27
|
+
const transaction = await program.methods
|
|
28
28
|
.initVoteTokenAccount(computationOffset, Array.from(params.userX25519Keypair.publicKey), nonceBN)
|
|
29
29
|
.accountsPartial({
|
|
30
|
-
signer: params.signer
|
|
30
|
+
signer: params.signer,
|
|
31
31
|
voteTokenAccount: voteTokenAccountPda,
|
|
32
32
|
computationAccount: getComputationAccAddress(ARCIUM_CLUSTER_OFFSET, computationOffset),
|
|
33
33
|
clusterAccount,
|
|
@@ -37,10 +37,9 @@ export async function initVoteTokenAccount(provider, params) {
|
|
|
37
37
|
compDefAccount: getCompDefAccAddress(programId, Buffer.from(getCompDefAccOffset(COMP_DEF_OFFSETS.INIT_VOTE_TOKEN_ACCOUNT)).readUInt32LE()),
|
|
38
38
|
systemProgram: SystemProgram.programId,
|
|
39
39
|
})
|
|
40
|
-
.
|
|
41
|
-
.rpc({ skipPreflight: false });
|
|
40
|
+
.transaction();
|
|
42
41
|
return {
|
|
43
|
-
|
|
42
|
+
transaction,
|
|
44
43
|
voteTokenAccountPda,
|
|
45
44
|
computationOffset,
|
|
46
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initVoteTokenAccount.js","sourceRoot":"","sources":["../../src/instructions/initVoteTokenAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"initVoteTokenAccount.js","sourceRoot":"","sources":["../../src/instructions/initVoteTokenAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAA+B,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB,OAAO,GAAG,MAAM,+BAA+B,CAAC;AA2BhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAwB,EACxB,MAAkC;IAElC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAE3C,gCAAgC;IAChC,MAAM,CAAC,mBAAmB,CAAC,GAAG,yBAAyB,CACrD,MAAM,CAAC,MAAM,EACb,SAAS,CACV,CAAC;IAEF,6CAA6C;IAC7C,MAAM,iBAAiB,GAAG,yBAAyB,EAAE,CAAC;IACtD,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAEnC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO;SACtC,oBAAoB,CACnB,iBAAiB,EACjB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAC9C,OAAO,CACR;SACA,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,gBAAgB,EAAE,mBAAmB;QACrC,kBAAkB,EAAE,wBAAwB,CAC1C,qBAAqB,EACrB,iBAAiB,CAClB;QACD,cAAc;QACd,UAAU,EAAE,gBAAgB,CAAC,SAAS,CAAC;QACvC,cAAc,EAAE,oBAAoB,CAAC,qBAAqB,CAAC;QAC3D,aAAa,EAAE,0BAA0B,CAAC,qBAAqB,CAAC;QAChE,cAAc,EAAE,oBAAoB,CAClC,SAAS,EACT,MAAM,CAAC,IAAI,CACT,mBAAmB,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAC9D,CAAC,YAAY,EAAE,CACjB;QACD,aAAa,EAAE,aAAa,CAAC,SAAS;KACvC,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO;QACL,WAAW;QACX,mBAAmB;QACnB,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BN, type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import { type
|
|
2
|
+
import { type PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
import type { X25519Keypair } from "../types";
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for minting vote tokens
|
|
6
6
|
*/
|
|
7
7
|
export interface MintVoteTokensParams {
|
|
8
8
|
/** User minting tokens (pays SOL) */
|
|
9
|
-
signer:
|
|
9
|
+
signer: PublicKey;
|
|
10
10
|
/** User's X25519 keypair for encryption */
|
|
11
11
|
userX25519Keypair: X25519Keypair;
|
|
12
12
|
/** Number of vote tokens to mint */
|
|
@@ -15,26 +15,26 @@ export interface MintVoteTokensParams {
|
|
|
15
15
|
programId?: PublicKey;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Result from
|
|
18
|
+
* Result from building mint vote tokens transaction
|
|
19
19
|
*/
|
|
20
20
|
export interface MintVoteTokensResult {
|
|
21
|
-
/** Transaction
|
|
22
|
-
|
|
21
|
+
/** Transaction to sign and send */
|
|
22
|
+
transaction: Transaction;
|
|
23
23
|
/** PDA of the vote token account */
|
|
24
24
|
voteTokenAccountPda: PublicKey;
|
|
25
25
|
/** Computation offset (pass to awaitComputationFinalization) */
|
|
26
26
|
computationOffset: BN;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Builds a transaction to mint vote tokens by paying SOL
|
|
30
30
|
*
|
|
31
31
|
* Users buy vote tokens which can be used to purchase market shares.
|
|
32
32
|
* Each token costs PRICE_PER_VOTE_TOKEN_LAMPORTS (0.001 SOL).
|
|
33
33
|
* Uses MPC to update the encrypted balance.
|
|
34
34
|
*
|
|
35
|
-
* @param provider - Anchor provider for connection
|
|
35
|
+
* @param provider - Anchor provider for connection
|
|
36
36
|
* @param params - Mint vote tokens parameters
|
|
37
|
-
* @returns Transaction
|
|
37
|
+
* @returns Transaction to sign and send, vote token account PDA, and computation offset
|
|
38
38
|
*/
|
|
39
39
|
export declare function mintVoteTokens(provider: AnchorProvider, params: MintVoteTokensParams): Promise<MintVoteTokensResult>;
|
|
40
40
|
//# sourceMappingURL=mintVoteTokens.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mintVoteTokens.d.ts","sourceRoot":"","sources":["../../src/instructions/mintVoteTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAiB,KAAK,
|
|
1
|
+
{"version":3,"file":"mintVoteTokens.d.ts","sourceRoot":"","sources":["../../src/instructions/mintVoteTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAiB,KAAK,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAgB7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,MAAM,EAAE,SAAS,CAAC;IAClB,2CAA2C;IAC3C,iBAAiB,EAAE,aAAa,CAAC;IACjC,oCAAoC;IACpC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC;IACpB,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,oCAAoC;IACpC,mBAAmB,EAAE,SAAS,CAAC;IAC/B,gEAAgE;IAChE,iBAAiB,EAAE,EAAE,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAsD/B"}
|
|
@@ -5,30 +5,30 @@ import { PROGRAM_ID, COMP_DEF_OFFSETS } from "../constants";
|
|
|
5
5
|
import { deriveVoteTokenAccountPda, generateComputationOffset, ARCIUM_CLUSTER_OFFSET, getClusterAddress, } from "../utils";
|
|
6
6
|
import IDL from "../idl/conviction_market.json";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Builds a transaction to mint vote tokens by paying SOL
|
|
9
9
|
*
|
|
10
10
|
* Users buy vote tokens which can be used to purchase market shares.
|
|
11
11
|
* Each token costs PRICE_PER_VOTE_TOKEN_LAMPORTS (0.001 SOL).
|
|
12
12
|
* Uses MPC to update the encrypted balance.
|
|
13
13
|
*
|
|
14
|
-
* @param provider - Anchor provider for connection
|
|
14
|
+
* @param provider - Anchor provider for connection
|
|
15
15
|
* @param params - Mint vote tokens parameters
|
|
16
|
-
* @returns Transaction
|
|
16
|
+
* @returns Transaction to sign and send, vote token account PDA, and computation offset
|
|
17
17
|
*/
|
|
18
18
|
export async function mintVoteTokens(provider, params) {
|
|
19
19
|
const programId = params.programId ?? PROGRAM_ID;
|
|
20
20
|
const program = new Program(IDL, provider);
|
|
21
21
|
const clusterAccount = getClusterAddress();
|
|
22
22
|
// Derive vote token account PDA
|
|
23
|
-
const [voteTokenAccountPda] = deriveVoteTokenAccountPda(params.signer
|
|
23
|
+
const [voteTokenAccountPda] = deriveVoteTokenAccountPda(params.signer, programId);
|
|
24
24
|
// Auto-generate computation offset
|
|
25
25
|
const computationOffset = generateComputationOffset();
|
|
26
26
|
// Convert amount to BN
|
|
27
27
|
const amountBN = typeof params.amount === "number" ? new BN(params.amount) : params.amount;
|
|
28
|
-
const
|
|
28
|
+
const transaction = await program.methods
|
|
29
29
|
.mintVoteTokens(computationOffset, Array.from(params.userX25519Keypair.publicKey), amountBN)
|
|
30
30
|
.accountsPartial({
|
|
31
|
-
signer: params.signer
|
|
31
|
+
signer: params.signer,
|
|
32
32
|
voteTokenAccount: voteTokenAccountPda,
|
|
33
33
|
computationAccount: getComputationAccAddress(ARCIUM_CLUSTER_OFFSET, computationOffset),
|
|
34
34
|
clusterAccount,
|
|
@@ -38,10 +38,9 @@ export async function mintVoteTokens(provider, params) {
|
|
|
38
38
|
compDefAccount: getCompDefAccAddress(programId, Buffer.from(getCompDefAccOffset(COMP_DEF_OFFSETS.BUY_VOTE_TOKENS)).readUInt32LE()),
|
|
39
39
|
systemProgram: SystemProgram.programId,
|
|
40
40
|
})
|
|
41
|
-
.
|
|
42
|
-
.rpc({ skipPreflight: true });
|
|
41
|
+
.transaction();
|
|
43
42
|
return {
|
|
44
|
-
|
|
43
|
+
transaction,
|
|
45
44
|
voteTokenAccountPda,
|
|
46
45
|
computationOffset,
|
|
47
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mintVoteTokens.js","sourceRoot":"","sources":["../../src/instructions/mintVoteTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"mintVoteTokens.js","sourceRoot":"","sources":["../../src/instructions/mintVoteTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,aAAa,EAA+B,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB,OAAO,GAAG,MAAM,+BAA+B,CAAC;AA6BhD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAwB,EACxB,MAA4B;IAE5B,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAE3C,gCAAgC;IAChC,MAAM,CAAC,mBAAmB,CAAC,GAAG,yBAAyB,CACrD,MAAM,CAAC,MAAM,EACb,SAAS,CACV,CAAC;IAEF,mCAAmC;IACnC,MAAM,iBAAiB,GAAG,yBAAyB,EAAE,CAAC;IAEtD,uBAAuB;IACvB,MAAM,QAAQ,GACZ,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAE5E,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO;SACtC,cAAc,CACb,iBAAiB,EACjB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAC9C,QAAQ,CACT;SACA,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,gBAAgB,EAAE,mBAAmB;QACrC,kBAAkB,EAAE,wBAAwB,CAC1C,qBAAqB,EACrB,iBAAiB,CAClB;QACD,cAAc;QACd,UAAU,EAAE,gBAAgB,CAAC,SAAS,CAAC;QACvC,cAAc,EAAE,oBAAoB,CAAC,qBAAqB,CAAC;QAC3D,aAAa,EAAE,0BAA0B,CAAC,qBAAqB,CAAC;QAChE,cAAc,EAAE,oBAAoB,CAClC,SAAS,EACT,MAAM,CAAC,IAAI,CACT,mBAAmB,CAAC,gBAAgB,CAAC,eAAe,CAAC,CACtD,CAAC,YAAY,EAAE,CACjB;QACD,aAAa,EAAE,aAAa,CAAC,SAAS;KACvC,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO;QACL,WAAW;QACX,mBAAmB;QACnB,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BN, type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
/**
|
|
4
4
|
* Parameters for opening a market
|
|
5
5
|
*/
|
|
6
6
|
export interface OpenMarketParams {
|
|
7
7
|
/** Market creator (must be the original creator) */
|
|
8
|
-
creator:
|
|
8
|
+
creator: PublicKey;
|
|
9
9
|
/** Market PDA to open */
|
|
10
10
|
market: PublicKey;
|
|
11
11
|
/** Unix timestamp when market opens for trading */
|
|
@@ -14,21 +14,21 @@ export interface OpenMarketParams {
|
|
|
14
14
|
programId?: PublicKey;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Result from
|
|
17
|
+
* Result from building open market transaction
|
|
18
18
|
*/
|
|
19
19
|
export interface OpenMarketResult {
|
|
20
|
-
/** Transaction
|
|
21
|
-
|
|
20
|
+
/** Transaction to sign and send */
|
|
21
|
+
transaction: Transaction;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Builds a transaction to open a market for trading
|
|
25
25
|
*
|
|
26
26
|
* After creating a market and adding options, the creator must open it
|
|
27
27
|
* with a specific timestamp. The market must be funded before opening.
|
|
28
28
|
*
|
|
29
|
-
* @param provider - Anchor provider for connection
|
|
29
|
+
* @param provider - Anchor provider for connection
|
|
30
30
|
* @param params - Open market parameters
|
|
31
|
-
* @returns Transaction
|
|
31
|
+
* @returns Transaction to sign and send
|
|
32
32
|
*/
|
|
33
33
|
export declare function openMarket(provider: AnchorProvider, params: OpenMarketParams): Promise<OpenMarketResult>;
|
|
34
34
|
//# sourceMappingURL=openMarket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openMarket.d.ts","sourceRoot":"","sources":["../../src/instructions/openMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"openMarket.d.ts","sourceRoot":"","sources":["../../src/instructions/openMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,OAAO,EAAE,SAAS,CAAC;IACnB,yBAAyB;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,mDAAmD;IACnD,aAAa,EAAE,MAAM,GAAG,EAAE,CAAC;IAC3B,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAoB3B"}
|
|
@@ -2,14 +2,14 @@ import { Program, BN } from "@coral-xyz/anchor";
|
|
|
2
2
|
import { PROGRAM_ID } from "../constants";
|
|
3
3
|
import IDL from "../idl/conviction_market.json";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Builds a transaction to open a market for trading
|
|
6
6
|
*
|
|
7
7
|
* After creating a market and adding options, the creator must open it
|
|
8
8
|
* with a specific timestamp. The market must be funded before opening.
|
|
9
9
|
*
|
|
10
|
-
* @param provider - Anchor provider for connection
|
|
10
|
+
* @param provider - Anchor provider for connection
|
|
11
11
|
* @param params - Open market parameters
|
|
12
|
-
* @returns Transaction
|
|
12
|
+
* @returns Transaction to sign and send
|
|
13
13
|
*/
|
|
14
14
|
export async function openMarket(provider, params) {
|
|
15
15
|
const programId = params.programId ?? PROGRAM_ID;
|
|
@@ -17,13 +17,12 @@ export async function openMarket(provider, params) {
|
|
|
17
17
|
const openTimestampBN = typeof params.openTimestamp === "number"
|
|
18
18
|
? new BN(params.openTimestamp)
|
|
19
19
|
: params.openTimestamp;
|
|
20
|
-
const
|
|
20
|
+
const transaction = await program.methods
|
|
21
21
|
.openMarket(openTimestampBN)
|
|
22
22
|
.accountsPartial({
|
|
23
23
|
market: params.market,
|
|
24
24
|
})
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
return { signature };
|
|
25
|
+
.transaction();
|
|
26
|
+
return { transaction };
|
|
28
27
|
}
|
|
29
28
|
//# sourceMappingURL=openMarket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openMarket.js","sourceRoot":"","sources":["../../src/instructions/openMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAyBhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,QAAwB,EACxB,MAAwB;IAExB,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,eAAe,GACnB,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ;QACtC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;QAC9B,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;IAE3B,MAAM,
|
|
1
|
+
{"version":3,"file":"openMarket.js","sourceRoot":"","sources":["../../src/instructions/openMarket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAyBhD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,QAAwB,EACxB,MAAwB;IAExB,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,eAAe,GACnB,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ;QACtC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;QAC9B,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;IAE3B,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO;SACtC,UAAU,CAAC,eAAe,CAAC;SAC3B,eAAe,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;SACD,WAAW,EAAE,CAAC;IAEjB,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BN, type AnchorProvider } from "@coral-xyz/anchor";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PublicKey, Transaction } from "@solana/web3.js";
|
|
3
3
|
import type { X25519Keypair } from "../types";
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for revealing shares
|
|
6
6
|
*/
|
|
7
7
|
export interface RevealSharesParams {
|
|
8
8
|
/** User calling the reveal (can be anyone) */
|
|
9
|
-
signer:
|
|
9
|
+
signer: PublicKey;
|
|
10
10
|
/** Owner of the share account to reveal */
|
|
11
11
|
owner: PublicKey;
|
|
12
12
|
/** Market PDA */
|
|
@@ -17,27 +17,27 @@ export interface RevealSharesParams {
|
|
|
17
17
|
programId?: PublicKey;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Result from
|
|
20
|
+
* Result from building reveal shares transaction
|
|
21
21
|
*/
|
|
22
22
|
export interface RevealSharesResult {
|
|
23
|
-
/** Transaction
|
|
24
|
-
|
|
23
|
+
/** Transaction to sign and send */
|
|
24
|
+
transaction: Transaction;
|
|
25
25
|
/** PDA of the share account */
|
|
26
26
|
shareAccountPda: PublicKey;
|
|
27
27
|
/** Computation offset (pass to awaitComputationFinalization) */
|
|
28
28
|
computationOffset: BN;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Builds a transaction to reveal a user's encrypted shares after staking ends
|
|
32
32
|
*
|
|
33
33
|
* Permissionless - anyone can reveal anyone's shares after the staking
|
|
34
34
|
* period ends and the winning option is selected.
|
|
35
35
|
* Updates share account with revealed amount/option and credits vote
|
|
36
36
|
* token balance back to the user.
|
|
37
37
|
*
|
|
38
|
-
* @param provider - Anchor provider for connection
|
|
38
|
+
* @param provider - Anchor provider for connection
|
|
39
39
|
* @param params - Reveal shares parameters
|
|
40
|
-
* @returns Transaction
|
|
40
|
+
* @returns Transaction to sign and send, share account PDA, and computation offset
|
|
41
41
|
*/
|
|
42
42
|
export declare function revealShares(provider: AnchorProvider, params: RevealSharesParams): Promise<RevealSharesResult>;
|
|
43
43
|
//# sourceMappingURL=revealShares.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revealShares.d.ts","sourceRoot":"","sources":["../../src/instructions/revealShares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"revealShares.d.ts","sourceRoot":"","sources":["../../src/instructions/revealShares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAiB9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,MAAM,EAAE,SAAS,CAAC;IAClB,2CAA2C;IAC3C,KAAK,EAAE,SAAS,CAAC;IACjB,iBAAiB;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,4CAA4C;IAC5C,kBAAkB,EAAE,aAAa,CAAC;IAClC,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,WAAW,EAAE,WAAW,CAAC;IACzB,+BAA+B;IAC/B,eAAe,EAAE,SAAS,CAAC;IAC3B,gEAAgE;IAChE,iBAAiB,EAAE,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAqD7B"}
|
|
@@ -4,16 +4,16 @@ import { PROGRAM_ID, COMP_DEF_OFFSETS } from "../constants";
|
|
|
4
4
|
import { deriveVoteTokenAccountPda, deriveShareAccountPda, generateComputationOffset, ARCIUM_CLUSTER_OFFSET, getClusterAddress, } from "../utils";
|
|
5
5
|
import IDL from "../idl/conviction_market.json";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Builds a transaction to reveal a user's encrypted shares after staking ends
|
|
8
8
|
*
|
|
9
9
|
* Permissionless - anyone can reveal anyone's shares after the staking
|
|
10
10
|
* period ends and the winning option is selected.
|
|
11
11
|
* Updates share account with revealed amount/option and credits vote
|
|
12
12
|
* token balance back to the user.
|
|
13
13
|
*
|
|
14
|
-
* @param provider - Anchor provider for connection
|
|
14
|
+
* @param provider - Anchor provider for connection
|
|
15
15
|
* @param params - Reveal shares parameters
|
|
16
|
-
* @returns Transaction
|
|
16
|
+
* @returns Transaction to sign and send, share account PDA, and computation offset
|
|
17
17
|
*/
|
|
18
18
|
export async function revealShares(provider, params) {
|
|
19
19
|
const programId = params.programId ?? PROGRAM_ID;
|
|
@@ -24,7 +24,7 @@ export async function revealShares(provider, params) {
|
|
|
24
24
|
const [shareAccountPda] = deriveShareAccountPda(params.owner, params.market, programId);
|
|
25
25
|
// Auto-generate computation offset
|
|
26
26
|
const computationOffset = generateComputationOffset();
|
|
27
|
-
const
|
|
27
|
+
const transaction = await program.methods
|
|
28
28
|
.revealShares(computationOffset, Array.from(params.ownerX25519Keypair.publicKey))
|
|
29
29
|
.accountsPartial({
|
|
30
30
|
owner: params.owner,
|
|
@@ -36,10 +36,9 @@ export async function revealShares(provider, params) {
|
|
|
36
36
|
executingPool: getExecutingPoolAccAddress(ARCIUM_CLUSTER_OFFSET),
|
|
37
37
|
compDefAccount: getCompDefAccAddress(programId, Buffer.from(getCompDefAccOffset(COMP_DEF_OFFSETS.REVEAL_SHARES)).readUInt32LE()),
|
|
38
38
|
})
|
|
39
|
-
.
|
|
40
|
-
.rpc({ skipPreflight: true });
|
|
39
|
+
.transaction();
|
|
41
40
|
return {
|
|
42
|
-
|
|
41
|
+
transaction,
|
|
43
42
|
shareAccountPda,
|
|
44
43
|
computationOffset,
|
|
45
44
|
};
|
|
@@ -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,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,GAClB,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,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAE3C,kBAAkB;IAClB,MAAM,CAAC,mBAAmB,CAAC,GAAG,yBAAyB,CACrD,MAAM,CAAC,KAAK,EACZ,SAAS,CACV,CAAC;IACF,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,
|
|
1
|
+
{"version":3,"file":"revealShares.js","sourceRoot":"","sources":["../../src/instructions/revealShares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,MAAM,mBAAmB,CAAC;AAErE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,GAClB,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,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAE3C,kBAAkB;IAClB,MAAM,CAAC,mBAAmB,CAAC,GAAG,yBAAyB,CACrD,MAAM,CAAC,KAAK,EACZ,SAAS,CACV,CAAC;IACF,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;QACd,UAAU,EAAE,gBAAgB,CAAC,SAAS,CAAC;QACvC,cAAc,EAAE,oBAAoB,CAAC,qBAAqB,CAAC;QAC3D,aAAa,EAAE,0BAA0B,CAAC,qBAAqB,CAAC;QAChE,cAAc,EAAE,oBAAoB,CAClC,SAAS,EACT,MAAM,CAAC,IAAI,CACT,mBAAmB,CAAC,gBAAgB,CAAC,aAAa,CAAC,CACpD,CAAC,YAAY,EAAE,CACjB;KACF,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"}
|