@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
|
@@ -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/keypairs.d.ts
CHANGED
|
@@ -17,4 +17,10 @@ export declare function generateSolanaKeypair(): Keypair;
|
|
|
17
17
|
* @returns A new X25519Keypair with publicKey and secretKey
|
|
18
18
|
*/
|
|
19
19
|
export declare function generateX25519Keypair(): X25519Keypair;
|
|
20
|
+
/**
|
|
21
|
+
* Derives an X25519 keypair deterministically from a signature
|
|
22
|
+
* @param signature - Signature bytes to derive the keypair from
|
|
23
|
+
* @returns A deterministic X25519Keypair derived from the signature
|
|
24
|
+
*/
|
|
25
|
+
export declare function deriveX25519KeypairFromSignature(signature: Uint8Array): X25519Keypair;
|
|
20
26
|
//# sourceMappingURL=keypairs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keypairs.d.ts","sourceRoot":"","sources":["../../src/utils/keypairs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"keypairs.d.ts","sourceRoot":"","sources":["../../src/utils/keypairs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,aAAa,CAQrD;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,UAAU,GACpB,aAAa,CAIf"}
|
package/dist/utils/keypairs.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Keypair } from "@solana/web3.js";
|
|
2
2
|
import { x25519 } from "@arcium-hq/client";
|
|
3
|
+
import { createHash } from "crypto";
|
|
3
4
|
/**
|
|
4
5
|
* Generates a new Solana keypair
|
|
5
6
|
*
|
|
@@ -26,4 +27,14 @@ export function generateX25519Keypair() {
|
|
|
26
27
|
secretKey,
|
|
27
28
|
};
|
|
28
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Derives an X25519 keypair deterministically from a signature
|
|
32
|
+
* @param signature - Signature bytes to derive the keypair from
|
|
33
|
+
* @returns A deterministic X25519Keypair derived from the signature
|
|
34
|
+
*/
|
|
35
|
+
export function deriveX25519KeypairFromSignature(signature) {
|
|
36
|
+
const secretKey = new Uint8Array(createHash("sha256").update(signature).digest());
|
|
37
|
+
const publicKey = x25519.getPublicKey(secretKey);
|
|
38
|
+
return { secretKey, publicKey };
|
|
39
|
+
}
|
|
29
40
|
//# sourceMappingURL=keypairs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keypairs.js","sourceRoot":"","sources":["../../src/utils/keypairs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"keypairs.js","sourceRoot":"","sources":["../../src/utils/keypairs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAe,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;IAClD,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAEjD,OAAO;QACL,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,SAAqB;IAErB,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAClF,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACjD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAClC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bench.games/conviction-markets",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
5
|
-
"type": "module",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"author": "Bench",
|
|
6
5
|
"main": "./dist/index.js",
|
|
7
|
-
"
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@types/bun": "latest",
|
|
8
|
+
"typescript": "^5.3.0"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"@arcium-hq/client": "^0.6.0",
|
|
12
|
+
"@coral-xyz/anchor": "^0.30.0",
|
|
13
|
+
"@solana/web3.js": "^1.87.0"
|
|
14
|
+
},
|
|
8
15
|
"exports": {
|
|
9
16
|
".": {
|
|
10
17
|
"import": "./dist/index.js",
|
|
11
18
|
"types": "./dist/index.d.ts"
|
|
12
19
|
}
|
|
13
20
|
},
|
|
21
|
+
"description": "TypeScript SDK for Solana Conviction Markets with encrypted votes using Arcium MPC",
|
|
14
22
|
"files": [
|
|
15
23
|
"dist",
|
|
16
24
|
"README.md"
|
|
17
25
|
],
|
|
18
|
-
"publishConfig": {
|
|
19
|
-
"access": "public"
|
|
20
|
-
},
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsc",
|
|
23
|
-
"prepublishOnly": "bun run build",
|
|
24
|
-
"type-check": "tsc --noEmit"
|
|
25
|
-
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"solana",
|
|
28
28
|
"conviction-voting",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"arcium",
|
|
32
32
|
"encrypted-voting"
|
|
33
33
|
],
|
|
34
|
-
"author": "Bench",
|
|
35
34
|
"license": "MIT",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"@coral-xyz/anchor": "^0.30.0",
|
|
39
|
-
"@solana/web3.js": "^1.87.0"
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
40
37
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc",
|
|
40
|
+
"prepublishOnly": "bun run build",
|
|
41
|
+
"type-check": "tsc --noEmit"
|
|
42
|
+
},
|
|
43
|
+
"type": "module",
|
|
44
|
+
"types": "./dist/index.d.ts"
|
|
45
45
|
}
|