@cypher-zk/sdk 0.7.1 → 0.7.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/{client-sr7mY_Wj.d.ts → client-BECBXFEY.d.ts} +13 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +49 -53
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -6884,6 +6884,12 @@ interface CypherClientOptions {
|
|
|
6884
6884
|
commitment?: Commitment;
|
|
6885
6885
|
/** Override the program ID (for redeploys with a different keypair). */
|
|
6886
6886
|
programId?: PublicKey;
|
|
6887
|
+
/**
|
|
6888
|
+
* The SPL token program that owns the accepted mint. Defaults to auto-detection
|
|
6889
|
+
* (resolved on first `globalState.fetch()` by querying the mint's account owner).
|
|
6890
|
+
* Pass `TOKEN_2022_PROGRAM_ID` explicitly to skip the detection RPC call.
|
|
6891
|
+
*/
|
|
6892
|
+
tokenProgram?: PublicKey;
|
|
6887
6893
|
/** Extra confirmation options forwarded to `AnchorProvider`. */
|
|
6888
6894
|
confirmOptions?: ConfirmOptions;
|
|
6889
6895
|
}
|
|
@@ -6903,6 +6909,13 @@ declare class CypherClient {
|
|
|
6903
6909
|
readonly programId: PublicKey;
|
|
6904
6910
|
readonly cluster: ClusterConfig;
|
|
6905
6911
|
private _globalStateCache;
|
|
6912
|
+
private _tokenProgram;
|
|
6913
|
+
/**
|
|
6914
|
+
* The SPL token program that owns the accepted mint (TOKEN_PROGRAM_ID or
|
|
6915
|
+
* TOKEN_2022_PROGRAM_ID). Defaults to TOKEN_PROGRAM_ID until auto-detected
|
|
6916
|
+
* on the first `globalState.fetch()` call.
|
|
6917
|
+
*/
|
|
6918
|
+
get tokenProgram(): PublicKey;
|
|
6906
6919
|
/**
|
|
6907
6920
|
* High-level account accessors. Each namespace is a thin facade over
|
|
6908
6921
|
* the per-account fetch helpers in `./accounts/`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as Cypher, C as CypherClient, l as CircuitName } from './client-
|
|
2
|
-
export { m as ACCOUNT_DISCRIMINATOR_SIZE, n as ALL_CIRCUITS, o as ALL_EVENT_NAMES, p as ActionProgressEvent, q as ActionStage, r as AdminClaimRemainingParams, A as AdminOverrideResolutionInputs, s as AdminOverrideResolutionParams, t as AwaitComputationOptions, B as BPS_DENOMINATOR, u as BetPlacedEvent, v as CIRCUITS, w as CLUSTERS, a as CancelMarketParams, c as ClaimInputs, x as ClaimParams, b as ClaimResult, y as ClusterConfig, z as ClusterName, D as ComputationResult, H as CreateMarketMultiParams, e as CreateMarketParams, d as CreateMarketResult, I as CreatorWithdrawnEvent, J as CypherClientOptions, j as CypherEvent, K as CypherEventName, L as DEFAULT_CLAIM_PERIOD_SECS, N as DEFAULT_REFUND_PERIOD_SECS, O as DEFAULT_RESOLUTION_WINDOW_SECS, E as EncryptedPositionAccount, Q as EventCallback, T as EventSubscription, F as FinalizeResolutionInputs, U as FinalizeResolutionParams, f as FlagResolutionInputs, V as FlagResolutionParams, G as GlobalStateAccount, W as INIT_COMP_DEF_INSTRUCTIONS, X as InitCompDefMethodName, Y as InitCompDefParams, Z as InitializeParams, _ as KNOWN_MINTS, $ as LpPositionAccount, a0 as MAX_CHALLENGE_PERIOD_SECS, a1 as MAX_LP_FEE_BPS, a2 as MAX_OUTCOMES_MULTI, a3 as MAX_PROTOCOL_FEE_BPS, a4 as MAX_QUESTION_BYTES, a5 as MIN_BET_USDC, a6 as MIN_CHALLENGE_PERIOD_SECS, a7 as MIN_CREATOR_BOND, a8 as MIN_OUTCOMES_MULTI, M as MarketAccount, a9 as MarketCancelledEvent, aa as MarketCategory, ab as MarketCategoryValue, ac as MarketCreatedEvent, ad as MarketFinalizedEvent, ae as MarketResolvedEvent, af as MarketState, ag as MarketStateValue, ah as MarketType, ai as MarketTypeValue, aj as ODDS_SCALE, ak as PROGRAM_ID, al as PayoutClaimedEvent, g as PlaceBetInputs, P as PlaceBetResult, am as PlacePrivateBetParams, an as PollEventsOptions, ao as PolledEvent, ap as ProgressCallback, aq as RefundClaimedEvent, R as ResolutionActionResult, ar as ResolutionFlaggedEvent, as as ResolutionOverriddenEvent, i as ResolveMarketInputs, at as ResolveMarketParams, h as ResolveMarketResult, au as SendIxOptions, S as SubscribeOptions, av as UpdateAcceptedMintParams, aw as UserCryptoKeypair, ax as Wallet, ay as WithdrawCreatorFundsParams, az as adminClaimRemainingIx, aA as adminOverrideResolutionAction, aB as adminOverrideResolutionIx, aC as awaitComputation, aD as buildAllInitCompDefIx, aE as cancelMarketAction, aF as cancelMarketIx, aG as claimPayoutAction, aH as claimPayoutMultiIx, aI as claimPayoutYesnoIx, aJ as claimRefundAction, aK as claimRefundMultiIx, aL as claimRefundYesnoIx, aM as compDefOffsetBytes, aN as compDefOffsetU32, aO as createCipher, aP as createMarketAction, aQ as createMarketIx, aR as createMarketMultiAction, aS as createMarketMultiIx, aT as createUserKeypair, aU as deriveSharedSecret, aV as fetchAllMarkets, aW as fetchGlobalState, aX as fetchLpPosition, aY as fetchLpPositionsByProvider, aZ as fetchMarket, a_ as fetchMarketsByCreator, a$ as fetchMarketsByState, b0 as fetchMxePublicKey, b1 as fetchPosition, b2 as fetchPositionsForMarket, b3 as fetchUserPositions, b4 as finalizeResolutionAction, b5 as finalizeResolutionIx, b6 as flagResolutionAction, b7 as flagResolutionIx, b8 as freshNonce, b9 as initCompDefIx, ba as initializeIx, bb as keypairToWallet, bc as leBytesToBigInt, bd as onBetPlaced, be as onCreatorWithdrawn, bf as onMarketCancelled, bg as onMarketCreated, bh as onMarketFinalized, bi as onMarketResolved, bj as onPayoutClaimed, bk as onRefundClaimed, bl as onResolutionFlagged, bm as onResolutionOverridden, bn as parseLogs, bo as parseLogsFor, bp as placeBetAction, bq as placePrivateBetMultiIx, br as placePrivateBetYesnoIx, bs as pollEvents, bt as randomComputationOffset, bu as readonlyWallet, bv as resolveMarketAction, bw as resolveMarketMultiIx, bx as resolveMarketYesnoIx, by as sendIx, bz as sendIxAndAwaitArcium, bA as subscribeAll, bB as subscribeEvent, bC as updateAcceptedMintIx, bD as withdrawCreatorFundsAction, bE as withdrawCreatorFundsIx } from './client-
|
|
1
|
+
import { k as Cypher, C as CypherClient, l as CircuitName } from './client-BECBXFEY.js';
|
|
2
|
+
export { m as ACCOUNT_DISCRIMINATOR_SIZE, n as ALL_CIRCUITS, o as ALL_EVENT_NAMES, p as ActionProgressEvent, q as ActionStage, r as AdminClaimRemainingParams, A as AdminOverrideResolutionInputs, s as AdminOverrideResolutionParams, t as AwaitComputationOptions, B as BPS_DENOMINATOR, u as BetPlacedEvent, v as CIRCUITS, w as CLUSTERS, a as CancelMarketParams, c as ClaimInputs, x as ClaimParams, b as ClaimResult, y as ClusterConfig, z as ClusterName, D as ComputationResult, H as CreateMarketMultiParams, e as CreateMarketParams, d as CreateMarketResult, I as CreatorWithdrawnEvent, J as CypherClientOptions, j as CypherEvent, K as CypherEventName, L as DEFAULT_CLAIM_PERIOD_SECS, N as DEFAULT_REFUND_PERIOD_SECS, O as DEFAULT_RESOLUTION_WINDOW_SECS, E as EncryptedPositionAccount, Q as EventCallback, T as EventSubscription, F as FinalizeResolutionInputs, U as FinalizeResolutionParams, f as FlagResolutionInputs, V as FlagResolutionParams, G as GlobalStateAccount, W as INIT_COMP_DEF_INSTRUCTIONS, X as InitCompDefMethodName, Y as InitCompDefParams, Z as InitializeParams, _ as KNOWN_MINTS, $ as LpPositionAccount, a0 as MAX_CHALLENGE_PERIOD_SECS, a1 as MAX_LP_FEE_BPS, a2 as MAX_OUTCOMES_MULTI, a3 as MAX_PROTOCOL_FEE_BPS, a4 as MAX_QUESTION_BYTES, a5 as MIN_BET_USDC, a6 as MIN_CHALLENGE_PERIOD_SECS, a7 as MIN_CREATOR_BOND, a8 as MIN_OUTCOMES_MULTI, M as MarketAccount, a9 as MarketCancelledEvent, aa as MarketCategory, ab as MarketCategoryValue, ac as MarketCreatedEvent, ad as MarketFinalizedEvent, ae as MarketResolvedEvent, af as MarketState, ag as MarketStateValue, ah as MarketType, ai as MarketTypeValue, aj as ODDS_SCALE, ak as PROGRAM_ID, al as PayoutClaimedEvent, g as PlaceBetInputs, P as PlaceBetResult, am as PlacePrivateBetParams, an as PollEventsOptions, ao as PolledEvent, ap as ProgressCallback, aq as RefundClaimedEvent, R as ResolutionActionResult, ar as ResolutionFlaggedEvent, as as ResolutionOverriddenEvent, i as ResolveMarketInputs, at as ResolveMarketParams, h as ResolveMarketResult, au as SendIxOptions, S as SubscribeOptions, av as UpdateAcceptedMintParams, aw as UserCryptoKeypair, ax as Wallet, ay as WithdrawCreatorFundsParams, az as adminClaimRemainingIx, aA as adminOverrideResolutionAction, aB as adminOverrideResolutionIx, aC as awaitComputation, aD as buildAllInitCompDefIx, aE as cancelMarketAction, aF as cancelMarketIx, aG as claimPayoutAction, aH as claimPayoutMultiIx, aI as claimPayoutYesnoIx, aJ as claimRefundAction, aK as claimRefundMultiIx, aL as claimRefundYesnoIx, aM as compDefOffsetBytes, aN as compDefOffsetU32, aO as createCipher, aP as createMarketAction, aQ as createMarketIx, aR as createMarketMultiAction, aS as createMarketMultiIx, aT as createUserKeypair, aU as deriveSharedSecret, aV as fetchAllMarkets, aW as fetchGlobalState, aX as fetchLpPosition, aY as fetchLpPositionsByProvider, aZ as fetchMarket, a_ as fetchMarketsByCreator, a$ as fetchMarketsByState, b0 as fetchMxePublicKey, b1 as fetchPosition, b2 as fetchPositionsForMarket, b3 as fetchUserPositions, b4 as finalizeResolutionAction, b5 as finalizeResolutionIx, b6 as flagResolutionAction, b7 as flagResolutionIx, b8 as freshNonce, b9 as initCompDefIx, ba as initializeIx, bb as keypairToWallet, bc as leBytesToBigInt, bd as onBetPlaced, be as onCreatorWithdrawn, bf as onMarketCancelled, bg as onMarketCreated, bh as onMarketFinalized, bi as onMarketResolved, bj as onPayoutClaimed, bk as onRefundClaimed, bl as onResolutionFlagged, bm as onResolutionOverridden, bn as parseLogs, bo as parseLogsFor, bp as placeBetAction, bq as placePrivateBetMultiIx, br as placePrivateBetYesnoIx, bs as pollEvents, bt as randomComputationOffset, bu as readonlyWallet, bv as resolveMarketAction, bw as resolveMarketMultiIx, bx as resolveMarketYesnoIx, by as sendIx, bz as sendIxAndAwaitArcium, bA as subscribeAll, bB as subscribeEvent, bC as updateAcceptedMintIx, bD as withdrawCreatorFundsAction, bE as withdrawCreatorFundsIx } from './client-BECBXFEY.js';
|
|
3
3
|
import { GetProgramAccountsFilter, PublicKey } from '@solana/web3.js';
|
|
4
4
|
import { BN } from '@anchor-lang/core';
|
|
5
5
|
import { RescueCipher } from '@arcium-hq/client';
|
|
@@ -118,8 +118,8 @@ declare const GLOBAL_STATE_OFFSETS: {
|
|
|
118
118
|
declare const ADDRESS_LOOKUP_TABLE_PROGRAM_ID: PublicKey;
|
|
119
119
|
/** Convert `bigint | number | BN` → `BN`. Idempotent. */
|
|
120
120
|
declare function toBN(v: bigint | number | BN): BN;
|
|
121
|
-
/** The default ATA derivation for `(owner, mint)`. */
|
|
122
|
-
declare function userAta(owner: PublicKey, mint: PublicKey): PublicKey;
|
|
121
|
+
/** The default ATA derivation for `(owner, mint)`. Pass `tokenProgram` for Token-2022 mints. */
|
|
122
|
+
declare function userAta(owner: PublicKey, mint: PublicKey, tokenProgram?: PublicKey): PublicKey;
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* A user's plaintext bet input as the circuits expect it.
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { __commonJS, __toESM } from './chunk-5WRI5ZAA.js';
|
|
|
2
2
|
import idlJson from './cypher-G57ZWFM3.json';
|
|
3
3
|
import { PublicKey, AddressLookupTableProgram, SystemProgram, Transaction } from '@solana/web3.js';
|
|
4
4
|
import { BN, AnchorProvider, Program, BorshCoder, EventParser } from '@anchor-lang/core';
|
|
5
|
-
import {
|
|
5
|
+
import { TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync } from '@solana/spl-token';
|
|
6
6
|
export { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync } from '@solana/spl-token';
|
|
7
7
|
import { getCompDefAccOffset, getMXEAccAddress, getCompDefAccAddress, getArciumProgramId, getLookupTableAddress, getClockAccAddress, getFeePoolAccAddress, getExecutingPoolAccAddress, getMempoolAccAddress, getClusterAccAddress, getComputationAccAddress, awaitComputationFinalization, x25519, RescueCipher, getMXEPublicKey } from '@arcium-hq/client';
|
|
8
8
|
|
|
@@ -2285,6 +2285,23 @@ function materialize(code) {
|
|
|
2285
2285
|
msg: CYPHER_ERROR_MESSAGES[name]
|
|
2286
2286
|
};
|
|
2287
2287
|
}
|
|
2288
|
+
var ADDRESS_LOOKUP_TABLE_PROGRAM_ID = AddressLookupTableProgram.programId;
|
|
2289
|
+
function method(client, methodName) {
|
|
2290
|
+
const m = client.program.methods[methodName];
|
|
2291
|
+
if (!m) {
|
|
2292
|
+
throw new Error(
|
|
2293
|
+
`instructions: unknown program method '${methodName}' \u2014 IDL out of sync?`
|
|
2294
|
+
);
|
|
2295
|
+
}
|
|
2296
|
+
return m;
|
|
2297
|
+
}
|
|
2298
|
+
function toBN(v) {
|
|
2299
|
+
if (v instanceof BN) return v;
|
|
2300
|
+
return new BN(typeof v === "bigint" ? v.toString() : v);
|
|
2301
|
+
}
|
|
2302
|
+
function userAta(owner, mint, tokenProgram = TOKEN_PROGRAM_ID) {
|
|
2303
|
+
return getAssociatedTokenAddressSync(mint, owner, true, tokenProgram);
|
|
2304
|
+
}
|
|
2288
2305
|
|
|
2289
2306
|
// src/accounts/globalState.ts
|
|
2290
2307
|
function decode(raw) {
|
|
@@ -2542,23 +2559,6 @@ async function fetchLpPositionsByProvider(client, provider) {
|
|
|
2542
2559
|
const raw = await facade2(client).all([lpPositionFilters.byProvider(provider)]);
|
|
2543
2560
|
return raw.map(({ publicKey, account }) => ({ publicKey, account: decode4(account) }));
|
|
2544
2561
|
}
|
|
2545
|
-
var ADDRESS_LOOKUP_TABLE_PROGRAM_ID = AddressLookupTableProgram.programId;
|
|
2546
|
-
function method(client, methodName) {
|
|
2547
|
-
const m = client.program.methods[methodName];
|
|
2548
|
-
if (!m) {
|
|
2549
|
-
throw new Error(
|
|
2550
|
-
`instructions: unknown program method '${methodName}' \u2014 IDL out of sync?`
|
|
2551
|
-
);
|
|
2552
|
-
}
|
|
2553
|
-
return m;
|
|
2554
|
-
}
|
|
2555
|
-
function toBN(v) {
|
|
2556
|
-
if (v instanceof BN) return v;
|
|
2557
|
-
return new BN(typeof v === "bigint" ? v.toString() : v);
|
|
2558
|
-
}
|
|
2559
|
-
function userAta(owner, mint) {
|
|
2560
|
-
return getAssociatedTokenAddressSync(mint, owner, true);
|
|
2561
|
-
}
|
|
2562
2562
|
|
|
2563
2563
|
// src/instructions/admin.ts
|
|
2564
2564
|
async function initializeIx(client, params) {
|
|
@@ -2600,7 +2600,7 @@ async function adminClaimRemainingIx(client, params) {
|
|
|
2600
2600
|
market: marketPdaKey,
|
|
2601
2601
|
marketVault: vaultPda,
|
|
2602
2602
|
protocolTreasury: params.protocolTreasury,
|
|
2603
|
-
tokenProgram:
|
|
2603
|
+
tokenProgram: client.tokenProgram
|
|
2604
2604
|
}).instruction();
|
|
2605
2605
|
}
|
|
2606
2606
|
var CIRCUITS = {
|
|
@@ -2692,7 +2692,7 @@ async function createMarketIx(client, params) {
|
|
|
2692
2692
|
const [marketPdaKey] = marketPda(toBN(params.expectedMarketId), client.programId);
|
|
2693
2693
|
const [vaultPda] = marketVaultPda(marketPdaKey, client.programId);
|
|
2694
2694
|
const [lpPda] = lpPositionPda(marketPdaKey, params.creator, client.programId);
|
|
2695
|
-
const creatorAta = userAta(params.creator, params.acceptedMint);
|
|
2695
|
+
const creatorAta = userAta(params.creator, params.acceptedMint, client.tokenProgram);
|
|
2696
2696
|
return method(client, "createMarket")(
|
|
2697
2697
|
params.question,
|
|
2698
2698
|
toBN(params.closeTime),
|
|
@@ -2707,7 +2707,7 @@ async function createMarketIx(client, params) {
|
|
|
2707
2707
|
marketVault: vaultPda,
|
|
2708
2708
|
creatorTokenAccount: creatorAta,
|
|
2709
2709
|
acceptedMint: params.acceptedMint,
|
|
2710
|
-
tokenProgram:
|
|
2710
|
+
tokenProgram: client.tokenProgram,
|
|
2711
2711
|
systemProgram: SystemProgram.programId
|
|
2712
2712
|
}).instruction();
|
|
2713
2713
|
}
|
|
@@ -2722,7 +2722,7 @@ async function createMarketMultiIx(client, params) {
|
|
|
2722
2722
|
const [marketPdaKey] = marketPda(toBN(params.expectedMarketId), client.programId);
|
|
2723
2723
|
const [vaultPda] = marketVaultPda(marketPdaKey, client.programId);
|
|
2724
2724
|
const [lpPda] = lpPositionPda(marketPdaKey, params.creator, client.programId);
|
|
2725
|
-
const creatorAta = userAta(params.creator, params.acceptedMint);
|
|
2725
|
+
const creatorAta = userAta(params.creator, params.acceptedMint, client.tokenProgram);
|
|
2726
2726
|
return method(client, "createMarketMulti")(
|
|
2727
2727
|
params.question,
|
|
2728
2728
|
toBN(params.closeTime),
|
|
@@ -2738,7 +2738,7 @@ async function createMarketMultiIx(client, params) {
|
|
|
2738
2738
|
marketVault: vaultPda,
|
|
2739
2739
|
creatorTokenAccount: creatorAta,
|
|
2740
2740
|
acceptedMint: params.acceptedMint,
|
|
2741
|
-
tokenProgram:
|
|
2741
|
+
tokenProgram: client.tokenProgram,
|
|
2742
2742
|
systemProgram: SystemProgram.programId
|
|
2743
2743
|
}).instruction();
|
|
2744
2744
|
}
|
|
@@ -2746,28 +2746,28 @@ async function cancelMarketIx(client, params) {
|
|
|
2746
2746
|
const [marketPdaKey] = marketPda(toBN(params.marketId), client.programId);
|
|
2747
2747
|
const [vaultPda] = marketVaultPda(marketPdaKey, client.programId);
|
|
2748
2748
|
const [lpPda] = lpPositionPda(marketPdaKey, params.creator, client.programId);
|
|
2749
|
-
const creatorAta = userAta(params.creator, params.acceptedMint);
|
|
2749
|
+
const creatorAta = userAta(params.creator, params.acceptedMint, client.tokenProgram);
|
|
2750
2750
|
return method(client, "cancelMarket")().accountsPartial({
|
|
2751
2751
|
creator: params.creator,
|
|
2752
2752
|
market: marketPdaKey,
|
|
2753
2753
|
marketVault: vaultPda,
|
|
2754
2754
|
lpPosition: lpPda,
|
|
2755
2755
|
creatorTokenAccount: creatorAta,
|
|
2756
|
-
tokenProgram:
|
|
2756
|
+
tokenProgram: client.tokenProgram
|
|
2757
2757
|
}).instruction();
|
|
2758
2758
|
}
|
|
2759
2759
|
async function withdrawCreatorFundsIx(client, params) {
|
|
2760
2760
|
const [marketPdaKey] = marketPda(toBN(params.marketId), client.programId);
|
|
2761
2761
|
const [vaultPda] = marketVaultPda(marketPdaKey, client.programId);
|
|
2762
2762
|
const [lpPda] = lpPositionPda(marketPdaKey, params.creator, client.programId);
|
|
2763
|
-
const creatorAta = userAta(params.creator, params.acceptedMint);
|
|
2763
|
+
const creatorAta = userAta(params.creator, params.acceptedMint, client.tokenProgram);
|
|
2764
2764
|
return method(client, "withdrawCreatorFunds")().accountsPartial({
|
|
2765
2765
|
creator: params.creator,
|
|
2766
2766
|
market: marketPdaKey,
|
|
2767
2767
|
lpPosition: lpPda,
|
|
2768
2768
|
marketVault: vaultPda,
|
|
2769
2769
|
creatorTokenAccount: creatorAta,
|
|
2770
|
-
tokenProgram:
|
|
2770
|
+
tokenProgram: client.tokenProgram
|
|
2771
2771
|
}).instruction();
|
|
2772
2772
|
}
|
|
2773
2773
|
function buildArciumQueueAccounts(client, params) {
|
|
@@ -2842,7 +2842,7 @@ async function buildPlaceBetIx(client, circuit, methodName, params) {
|
|
|
2842
2842
|
const [marketPdaKey] = marketPda(toBN(params.marketId), client.programId);
|
|
2843
2843
|
const [vaultPda] = marketVaultPda(marketPdaKey, client.programId);
|
|
2844
2844
|
const [positionPdaKey] = positionPda(marketPdaKey, params.user, client.programId);
|
|
2845
|
-
const userTokenAccount = userAta(params.user, params.acceptedMint);
|
|
2845
|
+
const userTokenAccount = userAta(params.user, params.acceptedMint, client.tokenProgram);
|
|
2846
2846
|
const arcium = buildArciumQueueAccounts(client, {
|
|
2847
2847
|
circuit,
|
|
2848
2848
|
computationOffset: toBN(params.computationOffset),
|
|
@@ -2875,7 +2875,7 @@ async function buildPlaceBetIx(client, circuit, methodName, params) {
|
|
|
2875
2875
|
userTokenAccount,
|
|
2876
2876
|
protocolTreasury: params.protocolTreasury,
|
|
2877
2877
|
position: positionPdaKey,
|
|
2878
|
-
tokenProgram:
|
|
2878
|
+
tokenProgram: client.tokenProgram
|
|
2879
2879
|
}).instruction();
|
|
2880
2880
|
}
|
|
2881
2881
|
function placePrivateBetYesnoIx(client, params) {
|
|
@@ -2945,7 +2945,7 @@ async function buildClaimIx(client, circuit, methodName, params) {
|
|
|
2945
2945
|
const [marketPdaKey] = marketPda(toBN(params.marketId), client.programId);
|
|
2946
2946
|
const [vaultPda] = marketVaultPda(marketPdaKey, client.programId);
|
|
2947
2947
|
const [positionPdaKey] = positionPda(marketPdaKey, params.user, client.programId);
|
|
2948
|
-
const userTokenAccount = userAta(params.user, params.acceptedMint);
|
|
2948
|
+
const userTokenAccount = userAta(params.user, params.acceptedMint, client.tokenProgram);
|
|
2949
2949
|
const arcium = buildArciumQueueAccounts(client, {
|
|
2950
2950
|
circuit,
|
|
2951
2951
|
computationOffset: toBN(params.computationOffset),
|
|
@@ -2969,7 +2969,7 @@ async function buildClaimIx(client, circuit, methodName, params) {
|
|
|
2969
2969
|
position: positionPdaKey,
|
|
2970
2970
|
marketVault: vaultPda,
|
|
2971
2971
|
userTokenAccount,
|
|
2972
|
-
tokenProgram:
|
|
2972
|
+
tokenProgram: client.tokenProgram
|
|
2973
2973
|
}).instruction();
|
|
2974
2974
|
}
|
|
2975
2975
|
function claimPayoutYesnoIx(client, params) {
|
|
@@ -3093,6 +3093,8 @@ function rethrowCypher(err) {
|
|
|
3093
3093
|
}
|
|
3094
3094
|
throw err;
|
|
3095
3095
|
}
|
|
3096
|
+
|
|
3097
|
+
// src/actions/createMarket.ts
|
|
3096
3098
|
async function createMarketCommon(client, inputs) {
|
|
3097
3099
|
emitProgress(inputs.onProgress, "validating", {
|
|
3098
3100
|
message: "Validating market draft"
|
|
@@ -3108,28 +3110,6 @@ async function createMarketCommon(client, inputs) {
|
|
|
3108
3110
|
const expectedMarketId = gs.marketCounter;
|
|
3109
3111
|
const challengePeriod = inputs.challengePeriod ?? MIN_CHALLENGE_PERIOD_SECS;
|
|
3110
3112
|
const bondAmount = inputs.bondAmount ?? MIN_CREATOR_BOND;
|
|
3111
|
-
const creatorAta = getAssociatedTokenAddressSync(
|
|
3112
|
-
acceptedMint,
|
|
3113
|
-
inputs.creator,
|
|
3114
|
-
false,
|
|
3115
|
-
TOKEN_PROGRAM_ID,
|
|
3116
|
-
ASSOCIATED_TOKEN_PROGRAM_ID
|
|
3117
|
-
);
|
|
3118
|
-
const ataInfo = await client.connection.getAccountInfo(creatorAta);
|
|
3119
|
-
if (!ataInfo) {
|
|
3120
|
-
emitProgress(inputs.onProgress, "validating", {
|
|
3121
|
-
message: "Initializing token account for accepted mint..."
|
|
3122
|
-
});
|
|
3123
|
-
const createAtaIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
3124
|
-
inputs.creator,
|
|
3125
|
-
creatorAta,
|
|
3126
|
-
inputs.creator,
|
|
3127
|
-
acceptedMint,
|
|
3128
|
-
TOKEN_PROGRAM_ID,
|
|
3129
|
-
ASSOCIATED_TOKEN_PROGRAM_ID
|
|
3130
|
-
);
|
|
3131
|
-
await sendIx(client, createAtaIx);
|
|
3132
|
-
}
|
|
3133
3113
|
const ix = inputs.kind === "yesno" ? await createMarketIx(client, {
|
|
3134
3114
|
...inputs,
|
|
3135
3115
|
acceptedMint,
|
|
@@ -3785,6 +3765,15 @@ var CypherClient = class {
|
|
|
3785
3765
|
programId;
|
|
3786
3766
|
cluster;
|
|
3787
3767
|
_globalStateCache = null;
|
|
3768
|
+
_tokenProgram = null;
|
|
3769
|
+
/**
|
|
3770
|
+
* The SPL token program that owns the accepted mint (TOKEN_PROGRAM_ID or
|
|
3771
|
+
* TOKEN_2022_PROGRAM_ID). Defaults to TOKEN_PROGRAM_ID until auto-detected
|
|
3772
|
+
* on the first `globalState.fetch()` call.
|
|
3773
|
+
*/
|
|
3774
|
+
get tokenProgram() {
|
|
3775
|
+
return this._tokenProgram ?? TOKEN_PROGRAM_ID;
|
|
3776
|
+
}
|
|
3788
3777
|
/**
|
|
3789
3778
|
* High-level account accessors. Each namespace is a thin facade over
|
|
3790
3779
|
* the per-account fetch helpers in `./accounts/`.
|
|
@@ -3826,6 +3815,7 @@ var CypherClient = class {
|
|
|
3826
3815
|
this.wallet = opts.wallet;
|
|
3827
3816
|
this.programId = opts.programId ?? PROGRAM_ID;
|
|
3828
3817
|
this.cluster = resolveCluster(opts.cluster, opts.connection.rpcEndpoint);
|
|
3818
|
+
if (opts.tokenProgram) this._tokenProgram = opts.tokenProgram;
|
|
3829
3819
|
const confirmOptions = opts.confirmOptions ?? {
|
|
3830
3820
|
commitment: opts.commitment ?? "confirmed",
|
|
3831
3821
|
preflightCommitment: opts.commitment ?? "confirmed",
|
|
@@ -3838,6 +3828,12 @@ var CypherClient = class {
|
|
|
3838
3828
|
fetch: async (o = {}) => {
|
|
3839
3829
|
if (o.refresh || !this._globalStateCache) {
|
|
3840
3830
|
this._globalStateCache = await fetchGlobalState(this);
|
|
3831
|
+
if (!this._tokenProgram) {
|
|
3832
|
+
const mintInfo = await this.connection.getAccountInfo(
|
|
3833
|
+
this._globalStateCache.acceptedMint
|
|
3834
|
+
);
|
|
3835
|
+
if (mintInfo) this._tokenProgram = mintInfo.owner;
|
|
3836
|
+
}
|
|
3841
3837
|
}
|
|
3842
3838
|
return this._globalStateCache;
|
|
3843
3839
|
},
|