@bench.games/conviction-markets 0.1.6 → 0.1.7
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/utils/fetchMarkets.d.ts +50 -0
- package/dist/utils/fetchMarkets.d.ts.map +1 -0
- package/dist/utils/fetchMarkets.js +41 -0
- package/dist/utils/fetchMarkets.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { type AnchorProvider } from "@coral-xyz/anchor";
|
|
3
|
+
/**
|
|
4
|
+
* Fetches all conviction markets created by a specific user
|
|
5
|
+
*
|
|
6
|
+
* Uses memcmp filter to efficiently query only markets created by the given creator.
|
|
7
|
+
*
|
|
8
|
+
* @param provider - Anchor provider for connection
|
|
9
|
+
* @param creator - Public key of the market creator
|
|
10
|
+
* @returns Array of market accounts with their public keys
|
|
11
|
+
*/
|
|
12
|
+
export declare function fetchUserMarkets(provider: AnchorProvider, creator: PublicKey): Promise<import("@coral-xyz/anchor").ProgramAccount<{
|
|
13
|
+
encryptedAvailableShares: number[][];
|
|
14
|
+
bump: number;
|
|
15
|
+
creator: PublicKey;
|
|
16
|
+
index: import("bn.js");
|
|
17
|
+
totalOptions: number;
|
|
18
|
+
maxOptions: number;
|
|
19
|
+
openTimestamp: import("bn.js") | null;
|
|
20
|
+
timeToStake: import("bn.js");
|
|
21
|
+
timeToReveal: import("bn.js");
|
|
22
|
+
selectedOption: number | null;
|
|
23
|
+
stateNonce: import("bn.js");
|
|
24
|
+
maxShares: import("bn.js");
|
|
25
|
+
rewardLamports: import("bn.js");
|
|
26
|
+
selectAuthority: PublicKey | null;
|
|
27
|
+
}>[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Fetches all conviction markets from the program
|
|
30
|
+
*
|
|
31
|
+
* @param provider - Anchor provider for connection
|
|
32
|
+
* @returns Array of all market accounts with their public keys
|
|
33
|
+
*/
|
|
34
|
+
export declare function fetchAllMarkets(provider: AnchorProvider): Promise<import("@coral-xyz/anchor").ProgramAccount<{
|
|
35
|
+
encryptedAvailableShares: number[][];
|
|
36
|
+
bump: number;
|
|
37
|
+
creator: PublicKey;
|
|
38
|
+
index: import("bn.js");
|
|
39
|
+
totalOptions: number;
|
|
40
|
+
maxOptions: number;
|
|
41
|
+
openTimestamp: import("bn.js") | null;
|
|
42
|
+
timeToStake: import("bn.js");
|
|
43
|
+
timeToReveal: import("bn.js");
|
|
44
|
+
selectedOption: number | null;
|
|
45
|
+
stateNonce: import("bn.js");
|
|
46
|
+
maxShares: import("bn.js");
|
|
47
|
+
rewardLamports: import("bn.js");
|
|
48
|
+
selectAuthority: PublicKey | null;
|
|
49
|
+
}>[]>;
|
|
50
|
+
//# sourceMappingURL=fetchMarkets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchMarkets.d.ts","sourceRoot":"","sources":["../../src/utils/fetchMarkets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIjE;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,SAAS;;;;;;;;;;;;;;;MAuBnB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,cAAc;;;;;;;;;;;;;;;MAQ7D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import IDL from "../idl/conviction_market.json";
|
|
3
|
+
/**
|
|
4
|
+
* Fetches all conviction markets created by a specific user
|
|
5
|
+
*
|
|
6
|
+
* Uses memcmp filter to efficiently query only markets created by the given creator.
|
|
7
|
+
*
|
|
8
|
+
* @param provider - Anchor provider for connection
|
|
9
|
+
* @param creator - Public key of the market creator
|
|
10
|
+
* @returns Array of market accounts with their public keys
|
|
11
|
+
*/
|
|
12
|
+
export async function fetchUserMarkets(provider, creator) {
|
|
13
|
+
const program = new Program(IDL, provider);
|
|
14
|
+
// Fetch all ConvictionMarket accounts for this creator using memcmp filter
|
|
15
|
+
// Account structure (after discriminator):
|
|
16
|
+
// - 8 bytes: discriminator
|
|
17
|
+
// - 32 bytes: encrypted_available_shares
|
|
18
|
+
// - 1 byte: bump
|
|
19
|
+
// - 32 bytes: creator (offset 41)
|
|
20
|
+
const accounts = await program.account.convictionMarket.all([
|
|
21
|
+
{
|
|
22
|
+
memcmp: {
|
|
23
|
+
offset: 8 + 32 + 1, // Skip discriminator + encrypted_available_shares + bump
|
|
24
|
+
bytes: creator.toBase58(),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
]);
|
|
28
|
+
return accounts;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Fetches all conviction markets from the program
|
|
32
|
+
*
|
|
33
|
+
* @param provider - Anchor provider for connection
|
|
34
|
+
* @returns Array of all market accounts with their public keys
|
|
35
|
+
*/
|
|
36
|
+
export async function fetchAllMarkets(provider) {
|
|
37
|
+
const program = new Program(IDL, provider);
|
|
38
|
+
const accounts = await program.account.convictionMarket.all();
|
|
39
|
+
return accounts;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=fetchMarkets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchMarkets.js","sourceRoot":"","sources":["../../src/utils/fetchMarkets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAuB,MAAM,mBAAmB,CAAC;AAEjE,OAAO,GAAG,MAAM,+BAA+B,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAwB,EACxB,OAAkB;IAElB,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,2EAA2E;IAC3E,2CAA2C;IAC3C,2BAA2B;IAC3B,yCAAyC;IACzC,iBAAiB;IACjB,kCAAkC;IAClC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC;QAC1D;YACE,MAAM,EAAE;gBACN,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,yDAAyD;gBAC7E,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;aAC1B;SACF;KACF,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAwB;IAC5D,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,GAAuB,EACvB,QAAQ,CACoB,CAAC;IAE/B,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC;IAC9D,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
package/dist/utils/index.js
CHANGED
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|