@vercora-protocol/sdk 0.0.9 → 0.0.10
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/README.md +9 -6
- package/dist/idl/vercora.json +4692 -0
- package/dist/idl.d.ts +7 -0
- package/dist/idl.d.ts.map +1 -0
- package/dist/idl.js +13 -0
- package/dist/idl.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,11 @@ npm install @coral-xyz/anchor @solana/web3.js @solana/spl-token bn.js
|
|
|
22
22
|
import * as anchor from "@coral-xyz/anchor";
|
|
23
23
|
import { Program } from "@coral-xyz/anchor";
|
|
24
24
|
import { Connection, clusterApiUrl } from "@solana/web3.js";
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
IDL,
|
|
27
|
+
PROGRAM_ID,
|
|
28
|
+
PredictionMarketClient,
|
|
29
|
+
} from "@vercora-protocol/sdk";
|
|
26
30
|
import type { Vercora } from "@vercora-protocol/sdk";
|
|
27
31
|
import { BN } from "bn.js";
|
|
28
32
|
|
|
@@ -31,9 +35,8 @@ const connection = new Connection(clusterApiUrl("devnet"));
|
|
|
31
35
|
const provider = new anchor.AnchorProvider(connection, wallet, {});
|
|
32
36
|
anchor.setProvider(provider);
|
|
33
37
|
|
|
34
|
-
// 2.
|
|
35
|
-
|
|
36
|
-
const program = new anchor.Program<Vercora>(IDL, PROGRAM_ID, provider);
|
|
38
|
+
// 2. Program from the bundled IDL (`IDL` includes the program address; `PROGRAM_ID` matches it)
|
|
39
|
+
const program = new anchor.Program<Vercora>(IDL, provider);
|
|
37
40
|
|
|
38
41
|
// 3. Create the client
|
|
39
42
|
const client = new PredictionMarketClient(program);
|
|
@@ -41,9 +44,9 @@ const client = new PredictionMarketClient(program);
|
|
|
41
44
|
|
|
42
45
|
## Platforms and categories
|
|
43
46
|
|
|
44
|
-
Markets store **`platform_id`** and **`category_id`** as on-chain
|
|
47
|
+
Markets store **`platform_id`** as **`u32`** and **`category_id`** as **`u8`** on-chain (not pubkeys). See the IDL `CreateMarketArgs` and account layouts for the exact Borsh layout.
|
|
45
48
|
|
|
46
|
-
1. **`register_platform`** (program authority) — assigns the next id from `GlobalConfig.next_platform_id` and creates a **`PlatformRegistry`** PDA: seeds `["platform", platform_id
|
|
49
|
+
1. **`register_platform`** (program authority) — assigns the next id from `GlobalConfig.next_platform_id` and creates a **`PlatformRegistry`** PDA: seeds `["platform", platform_id.to_le_bytes()]` (4-byte little-endian `u32`). Holds `next_category_id` and `profile_authority` (who may edit the **`PlatformProfile`** for that id).
|
|
47
50
|
2. **`create_market_category`** — args `(platform_id, category_id, name)`; **`category_id`** must equal **`PlatformRegistry.next_category_id`** (then the registry is bumped after init). PDA seeds: `["market-category", platform_id le u32, category_id le u8]`.
|
|
48
51
|
3. **`create_market`** — args include `platform_id` and `category_id`. Rules: if `platform_id == 0` then `category_id` must be `0` and no registry/category accounts are passed. If `platform_id > 0`, pass the **`platform_registry`** account; if `category_id > 0`, pass the matching **`market_category`** account.
|
|
49
52
|
|