@cypher-zk/sdk 0.3.0 → 0.5.0
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 +569 -138
- package/dist/{client-hOLBWshA.d.ts → client-B0EueahJ.d.ts} +587 -21
- package/dist/{cypher-WAYH63ZA.json → cypher-M5PH6UM5.json} +440 -30
- package/dist/index.d.ts +23 -4
- package/dist/index.js +191 -12
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +6 -2
- package/dist/react/index.js +34 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/src/idl/cypher.json +440 -30
- package/src/idl/cypher.ts +440 -30
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { k as Cypher, C as CypherClient, l as CircuitName } from './client-B0EueahJ.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, x as CREATOR_BOND, a as CancelMarketParams, c as ClaimInputs, y as ClaimParams, b as ClaimResult, z as ClusterConfig, D as ClusterName, H as ComputationResult, I as CreateMarketMultiParams, e as CreateMarketParams, d as CreateMarketResult, J as CreatorWithdrawnEvent, K as CypherClientOptions, j as CypherEvent, L as CypherEventName, N as DEFAULT_CLAIM_PERIOD_SECS, O as DEFAULT_REFUND_PERIOD_SECS, Q as DEFAULT_RESOLUTION_WINDOW_SECS, E as EncryptedPositionAccount, T as EventCallback, U as EventSubscription, F as FinalizeResolutionInputs, V as FinalizeResolutionParams, f as FlagResolutionInputs, W as FlagResolutionParams, G as GlobalStateAccount, X as INIT_COMP_DEF_INSTRUCTIONS, Y as InitCompDefMethodName, Z as InitCompDefParams, _ as InitializeParams, $ as KNOWN_MINTS, a0 as LpPositionAccount, a1 as MAX_CHALLENGE_PERIOD_SECS, a2 as MAX_LP_FEE_BPS, a3 as MAX_OUTCOMES_MULTI, a4 as MAX_PROTOCOL_FEE_BPS, a5 as MAX_QUESTION_BYTES, a6 as MIN_BET_USDC, a7 as MIN_CHALLENGE_PERIOD_SECS, 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-B0EueahJ.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';
|
|
@@ -77,8 +77,11 @@ declare const MARKET_OFFSETS: {
|
|
|
77
77
|
readonly resolutionDeadline: 537;
|
|
78
78
|
readonly claimDeadline: 545;
|
|
79
79
|
readonly refundDeadline: 553;
|
|
80
|
-
readonly
|
|
81
|
-
readonly
|
|
80
|
+
readonly challengePeriod: 561;
|
|
81
|
+
readonly challengeDeadline: 569;
|
|
82
|
+
readonly disputed: 577;
|
|
83
|
+
readonly bump: 578;
|
|
84
|
+
readonly vaultBump: 579;
|
|
82
85
|
};
|
|
83
86
|
declare const ENCRYPTED_POSITION_OFFSETS: {
|
|
84
87
|
readonly user: 0;
|
|
@@ -292,6 +295,12 @@ type MarketPhase =
|
|
|
292
295
|
"betting"
|
|
293
296
|
/** Bets closed, resolver may submit an outcome (now in resolution window). */
|
|
294
297
|
| "awaitingResolve"
|
|
298
|
+
/** v0.2+: reveal callback ran, awaiting end of challenge window (anyone may flag). */
|
|
299
|
+
| "pendingResolution"
|
|
300
|
+
/** v0.2+: dispute window elapsed undisputed; anyone may call `finalize_resolution`. */
|
|
301
|
+
| "awaitingFinalize"
|
|
302
|
+
/** v0.2+: a flag was raised during the challenge window; admin override required. */
|
|
303
|
+
| "disputed"
|
|
295
304
|
/** Resolved + within claim window → winners can claim payouts. */
|
|
296
305
|
| "claimable"
|
|
297
306
|
/** Unresolved + past resolution deadline → bettors can claim refunds. */
|
|
@@ -312,6 +321,10 @@ interface MarketDeadlineInputs {
|
|
|
312
321
|
claimDeadline: bigint;
|
|
313
322
|
refundDeadline: bigint;
|
|
314
323
|
totalBetsCount?: bigint;
|
|
324
|
+
/** v0.2+: set by reveal callback to `resolution_time + challenge_period`. */
|
|
325
|
+
challengeDeadline?: bigint;
|
|
326
|
+
/** v0.2+: set true by `flag_resolution`. */
|
|
327
|
+
disputed?: boolean;
|
|
315
328
|
}
|
|
316
329
|
/**
|
|
317
330
|
* Compute the phase of `market` at `nowSec` (defaults to wall-clock now).
|
|
@@ -387,6 +400,12 @@ declare const CypherErrorCode: {
|
|
|
387
400
|
readonly WrongMint: 6033;
|
|
388
401
|
readonly NotAcceptedMint: 6034;
|
|
389
402
|
readonly InvalidCategory: 6035;
|
|
403
|
+
readonly InvalidChallengePeriod: 6036;
|
|
404
|
+
readonly NotPendingResolution: 6037;
|
|
405
|
+
readonly ChallengePeriodNotElapsed: 6038;
|
|
406
|
+
readonly ChallengePeriodElapsed: 6039;
|
|
407
|
+
readonly MarketDisputed: 6040;
|
|
408
|
+
readonly MarketNotDisputed: 6041;
|
|
390
409
|
};
|
|
391
410
|
type CypherErrorName = keyof typeof CypherErrorCode;
|
|
392
411
|
type CypherErrorCodeValue = (typeof CypherErrorCode)[keyof typeof CypherErrorCode];
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __commonJS, __toESM } from './chunk-5WRI5ZAA.js';
|
|
2
|
-
import idlJson from './cypher-
|
|
2
|
+
import idlJson from './cypher-M5PH6UM5.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
5
|
import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
@@ -2013,6 +2013,8 @@ var CREATOR_BOND = 10000000n;
|
|
|
2013
2013
|
var DEFAULT_RESOLUTION_WINDOW_SECS = 7 * 24 * 3600;
|
|
2014
2014
|
var DEFAULT_CLAIM_PERIOD_SECS = 14 * 24 * 3600;
|
|
2015
2015
|
var DEFAULT_REFUND_PERIOD_SECS = 14 * 24 * 3600;
|
|
2016
|
+
var MIN_CHALLENGE_PERIOD_SECS = 24 * 3600;
|
|
2017
|
+
var MAX_CHALLENGE_PERIOD_SECS = 48 * 3600;
|
|
2016
2018
|
var MAX_PROTOCOL_FEE_BPS = 100;
|
|
2017
2019
|
var MAX_LP_FEE_BPS = 500;
|
|
2018
2020
|
var BPS_DENOMINATOR = 10000n;
|
|
@@ -2021,7 +2023,8 @@ var MarketState = {
|
|
|
2021
2023
|
Active: 0,
|
|
2022
2024
|
Closed: 1,
|
|
2023
2025
|
Resolved: 2,
|
|
2024
|
-
Unresolved: 3
|
|
2026
|
+
Unresolved: 3,
|
|
2027
|
+
PendingResolution: 4
|
|
2025
2028
|
};
|
|
2026
2029
|
var MarketType = {
|
|
2027
2030
|
YesNo: 0,
|
|
@@ -2146,6 +2149,13 @@ function marketPhase(market, nowSec = unixNowSecs()) {
|
|
|
2146
2149
|
if (market.state === MarketState.Closed) {
|
|
2147
2150
|
return "cancelled";
|
|
2148
2151
|
}
|
|
2152
|
+
if (market.state === MarketState.PendingResolution) {
|
|
2153
|
+
if (market.disputed) return "disputed";
|
|
2154
|
+
if (market.challengeDeadline && nowSec <= market.challengeDeadline) {
|
|
2155
|
+
return "pendingResolution";
|
|
2156
|
+
}
|
|
2157
|
+
return "awaitingFinalize";
|
|
2158
|
+
}
|
|
2149
2159
|
if (market.state === MarketState.Resolved) {
|
|
2150
2160
|
if (market.claimDeadline > 0n && nowSec <= market.claimDeadline) {
|
|
2151
2161
|
return "claimable";
|
|
@@ -2212,7 +2222,13 @@ var CypherErrorCode = {
|
|
|
2212
2222
|
WrongMarketType: 6032,
|
|
2213
2223
|
WrongMint: 6033,
|
|
2214
2224
|
NotAcceptedMint: 6034,
|
|
2215
|
-
InvalidCategory: 6035
|
|
2225
|
+
InvalidCategory: 6035,
|
|
2226
|
+
InvalidChallengePeriod: 6036,
|
|
2227
|
+
NotPendingResolution: 6037,
|
|
2228
|
+
ChallengePeriodNotElapsed: 6038,
|
|
2229
|
+
ChallengePeriodElapsed: 6039,
|
|
2230
|
+
MarketDisputed: 6040,
|
|
2231
|
+
MarketNotDisputed: 6041
|
|
2216
2232
|
};
|
|
2217
2233
|
var CYPHER_ERROR_MESSAGES = Object.freeze(
|
|
2218
2234
|
Object.fromEntries(
|
|
@@ -2328,8 +2344,11 @@ var MARKET_OFFSETS = {
|
|
|
2328
2344
|
resolutionDeadline: 537,
|
|
2329
2345
|
claimDeadline: 545,
|
|
2330
2346
|
refundDeadline: 553,
|
|
2331
|
-
|
|
2332
|
-
|
|
2347
|
+
challengePeriod: 561,
|
|
2348
|
+
challengeDeadline: 569,
|
|
2349
|
+
disputed: 577,
|
|
2350
|
+
bump: 578,
|
|
2351
|
+
vaultBump: 579
|
|
2333
2352
|
};
|
|
2334
2353
|
var ENCRYPTED_POSITION_OFFSETS = {
|
|
2335
2354
|
user: 0,
|
|
@@ -2442,6 +2461,9 @@ function decode2(raw) {
|
|
|
2442
2461
|
resolutionDeadline: BigInt(raw.resolutionDeadline.toString()),
|
|
2443
2462
|
claimDeadline: BigInt(raw.claimDeadline.toString()),
|
|
2444
2463
|
refundDeadline: BigInt(raw.refundDeadline.toString()),
|
|
2464
|
+
challengePeriod: BigInt(raw.challengePeriod.toString()),
|
|
2465
|
+
challengeDeadline: BigInt(raw.challengeDeadline.toString()),
|
|
2466
|
+
disputed: raw.disputed,
|
|
2445
2467
|
bump: raw.bump,
|
|
2446
2468
|
vaultBump: raw.vaultBump
|
|
2447
2469
|
};
|
|
@@ -2651,6 +2673,12 @@ function validateMarketDraft(params) {
|
|
|
2651
2673
|
if (!Number.isInteger(params.category) || params.category < 0 || params.category > 6) {
|
|
2652
2674
|
throw new Error("createMarketIx: category must be a u8 in [0, 6]");
|
|
2653
2675
|
}
|
|
2676
|
+
const cp = BigInt(params.challengePeriod);
|
|
2677
|
+
if (cp < BigInt(MIN_CHALLENGE_PERIOD_SECS) || cp > BigInt(MAX_CHALLENGE_PERIOD_SECS)) {
|
|
2678
|
+
throw new Error(
|
|
2679
|
+
`createMarketIx: challengePeriod must be in [${MIN_CHALLENGE_PERIOD_SECS}, ${MAX_CHALLENGE_PERIOD_SECS}] seconds`
|
|
2680
|
+
);
|
|
2681
|
+
}
|
|
2654
2682
|
}
|
|
2655
2683
|
async function createMarketIx(client, params) {
|
|
2656
2684
|
validateMarketDraft(params);
|
|
@@ -2662,7 +2690,8 @@ async function createMarketIx(client, params) {
|
|
|
2662
2690
|
return method(client, "createMarket")(
|
|
2663
2691
|
params.question,
|
|
2664
2692
|
toBN(params.closeTime),
|
|
2665
|
-
params.category
|
|
2693
|
+
params.category,
|
|
2694
|
+
toBN(params.challengePeriod)
|
|
2666
2695
|
).accountsPartial({
|
|
2667
2696
|
creator: params.creator,
|
|
2668
2697
|
globalState: gsPda,
|
|
@@ -2691,7 +2720,8 @@ async function createMarketMultiIx(client, params) {
|
|
|
2691
2720
|
params.question,
|
|
2692
2721
|
toBN(params.closeTime),
|
|
2693
2722
|
params.category,
|
|
2694
|
-
params.numOutcomes
|
|
2723
|
+
params.numOutcomes,
|
|
2724
|
+
toBN(params.challengePeriod)
|
|
2695
2725
|
).accountsPartial({
|
|
2696
2726
|
creator: params.creator,
|
|
2697
2727
|
globalState: gsPda,
|
|
@@ -2966,6 +2996,34 @@ function claimRefundMultiIx(client, params) {
|
|
|
2966
2996
|
params
|
|
2967
2997
|
);
|
|
2968
2998
|
}
|
|
2999
|
+
|
|
3000
|
+
// src/instructions/resolution.ts
|
|
3001
|
+
async function flagResolutionIx(client, params) {
|
|
3002
|
+
const [marketPdaKey] = marketPda(toBN(params.marketId), client.programId);
|
|
3003
|
+
return method(client, "flagResolution")().accountsPartial({
|
|
3004
|
+
flagger: params.flagger,
|
|
3005
|
+
market: marketPdaKey
|
|
3006
|
+
}).instruction();
|
|
3007
|
+
}
|
|
3008
|
+
async function finalizeResolutionIx(client, params) {
|
|
3009
|
+
const [marketPdaKey] = marketPda(toBN(params.marketId), client.programId);
|
|
3010
|
+
return method(client, "finalizeResolution")().accountsPartial({
|
|
3011
|
+
caller: params.caller,
|
|
3012
|
+
market: marketPdaKey
|
|
3013
|
+
}).instruction();
|
|
3014
|
+
}
|
|
3015
|
+
async function adminOverrideResolutionIx(client, params) {
|
|
3016
|
+
if (!Number.isInteger(params.outcomeValue) || params.outcomeValue < 0 || params.outcomeValue > 255) {
|
|
3017
|
+
throw new Error("adminOverrideResolutionIx: outcomeValue must be a u8");
|
|
3018
|
+
}
|
|
3019
|
+
const [marketPdaKey] = marketPda(toBN(params.marketId), client.programId);
|
|
3020
|
+
const [gsPda] = globalStatePda(client.programId);
|
|
3021
|
+
return method(client, "adminOverrideResolution")(params.outcomeValue).accountsPartial({
|
|
3022
|
+
admin: params.admin,
|
|
3023
|
+
globalState: gsPda,
|
|
3024
|
+
market: marketPdaKey
|
|
3025
|
+
}).instruction();
|
|
3026
|
+
}
|
|
2969
3027
|
async function awaitComputation(client, computationOffset, opts = {}) {
|
|
2970
3028
|
const started = Date.now();
|
|
2971
3029
|
const offsetBN = computationOffset instanceof BN ? computationOffset : new BN(computationOffset.toString());
|
|
@@ -3042,14 +3100,17 @@ async function createMarketCommon(client, inputs) {
|
|
|
3042
3100
|
const gs = await client.globalState.fetch({ refresh: true });
|
|
3043
3101
|
const acceptedMint = inputs.acceptedMint ?? gs.acceptedMint;
|
|
3044
3102
|
const expectedMarketId = gs.marketCounter;
|
|
3103
|
+
const challengePeriod = inputs.challengePeriod ?? MIN_CHALLENGE_PERIOD_SECS;
|
|
3045
3104
|
const ix = inputs.kind === "yesno" ? await createMarketIx(client, {
|
|
3046
3105
|
...inputs,
|
|
3047
3106
|
acceptedMint,
|
|
3048
|
-
expectedMarketId
|
|
3107
|
+
expectedMarketId,
|
|
3108
|
+
challengePeriod
|
|
3049
3109
|
}) : await createMarketMultiIx(client, {
|
|
3050
3110
|
...inputs,
|
|
3051
3111
|
acceptedMint,
|
|
3052
|
-
expectedMarketId
|
|
3112
|
+
expectedMarketId,
|
|
3113
|
+
challengePeriod
|
|
3053
3114
|
});
|
|
3054
3115
|
emitProgress(inputs.onProgress, "submitting", {
|
|
3055
3116
|
message: "Submitting create-market transaction"
|
|
@@ -3375,6 +3436,16 @@ async function commonClaim(client, inputs, flavor) {
|
|
|
3375
3436
|
}
|
|
3376
3437
|
const phase = marketPhase(market);
|
|
3377
3438
|
if (flavor === "payout" && phase !== "claimable") {
|
|
3439
|
+
if (phase === "pendingResolution" || phase === "awaitingFinalize") {
|
|
3440
|
+
throw new Error(
|
|
3441
|
+
`claimPayout: market is in '${phase}' \u2014 call finalizeResolution first (or wait for someone to)`
|
|
3442
|
+
);
|
|
3443
|
+
}
|
|
3444
|
+
if (phase === "disputed") {
|
|
3445
|
+
throw new Error(
|
|
3446
|
+
"claimPayout: market is disputed \u2014 awaiting admin override before payouts open"
|
|
3447
|
+
);
|
|
3448
|
+
}
|
|
3378
3449
|
throw new Error(
|
|
3379
3450
|
`claimPayout: market phase is '${phase}' \u2014 payouts require 'claimable'`
|
|
3380
3451
|
);
|
|
@@ -3387,6 +3458,11 @@ async function commonClaim(client, inputs, flavor) {
|
|
|
3387
3458
|
if (flavor === "payout" && market.state !== MarketState.Resolved) {
|
|
3388
3459
|
throw new Error("claimPayout: market is not resolved");
|
|
3389
3460
|
}
|
|
3461
|
+
if (flavor === "refund" && market.state === MarketState.PendingResolution) {
|
|
3462
|
+
throw new Error(
|
|
3463
|
+
"claimRefund: market is pending resolution \u2014 refund not available until challenge window concludes unresolved"
|
|
3464
|
+
);
|
|
3465
|
+
}
|
|
3390
3466
|
emitProgress(inputs.onProgress, "fetching-state");
|
|
3391
3467
|
const { acceptedMint } = await client.globalState.fetch();
|
|
3392
3468
|
const { lut } = await fetchMxeLookupTable(client);
|
|
@@ -3434,6 +3510,87 @@ function claimRefundAction(client, inputs) {
|
|
|
3434
3510
|
function cap(s) {
|
|
3435
3511
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
3436
3512
|
}
|
|
3513
|
+
|
|
3514
|
+
// src/actions/resolution.ts
|
|
3515
|
+
async function flagResolutionAction(client, inputs) {
|
|
3516
|
+
emitProgress(inputs.onProgress, "validating", {
|
|
3517
|
+
message: "Validating flag inputs"
|
|
3518
|
+
});
|
|
3519
|
+
const market = await client.markets.fetch(inputs.marketId);
|
|
3520
|
+
if (!market) throw new Error(`flagResolution: market ${inputs.marketId} not found`);
|
|
3521
|
+
if (market.state !== MarketState.PendingResolution) {
|
|
3522
|
+
throw new Error(
|
|
3523
|
+
`flagResolution: market state is ${market.state}, expected PendingResolution (4)`
|
|
3524
|
+
);
|
|
3525
|
+
}
|
|
3526
|
+
if (market.disputed) {
|
|
3527
|
+
throw new Error("flagResolution: market is already disputed");
|
|
3528
|
+
}
|
|
3529
|
+
emitProgress(inputs.onProgress, "submitting", { message: "Submitting flag" });
|
|
3530
|
+
const ix = await flagResolutionIx(client, {
|
|
3531
|
+
flagger: inputs.flagger,
|
|
3532
|
+
marketId: inputs.marketId
|
|
3533
|
+
});
|
|
3534
|
+
const signature = await sendIx(client, ix);
|
|
3535
|
+
emitProgress(inputs.onProgress, "refetching");
|
|
3536
|
+
const [pda] = marketPda(inputs.marketId, client.programId);
|
|
3537
|
+
const out = { signature, market: await client.markets.fetchByPda(pda) };
|
|
3538
|
+
emitProgress(inputs.onProgress, "done", { signature });
|
|
3539
|
+
return out;
|
|
3540
|
+
}
|
|
3541
|
+
async function finalizeResolutionAction(client, inputs) {
|
|
3542
|
+
emitProgress(inputs.onProgress, "validating", {
|
|
3543
|
+
message: "Validating finalize inputs"
|
|
3544
|
+
});
|
|
3545
|
+
const market = await client.markets.fetch(inputs.marketId);
|
|
3546
|
+
if (!market) throw new Error(`finalizeResolution: market ${inputs.marketId} not found`);
|
|
3547
|
+
if (market.state !== MarketState.PendingResolution) {
|
|
3548
|
+
throw new Error(
|
|
3549
|
+
`finalizeResolution: market state is ${market.state}, expected PendingResolution (4)`
|
|
3550
|
+
);
|
|
3551
|
+
}
|
|
3552
|
+
if (market.disputed) {
|
|
3553
|
+
throw new Error("finalizeResolution: market is disputed \u2014 admin override required");
|
|
3554
|
+
}
|
|
3555
|
+
emitProgress(inputs.onProgress, "submitting", { message: "Submitting finalize" });
|
|
3556
|
+
const ix = await finalizeResolutionIx(client, {
|
|
3557
|
+
caller: inputs.caller,
|
|
3558
|
+
marketId: inputs.marketId
|
|
3559
|
+
});
|
|
3560
|
+
const signature = await sendIx(client, ix);
|
|
3561
|
+
emitProgress(inputs.onProgress, "refetching");
|
|
3562
|
+
const [pda] = marketPda(inputs.marketId, client.programId);
|
|
3563
|
+
const out = { signature, market: await client.markets.fetchByPda(pda) };
|
|
3564
|
+
emitProgress(inputs.onProgress, "done", { signature });
|
|
3565
|
+
return out;
|
|
3566
|
+
}
|
|
3567
|
+
async function adminOverrideResolutionAction(client, inputs) {
|
|
3568
|
+
emitProgress(inputs.onProgress, "validating", {
|
|
3569
|
+
message: "Validating admin override inputs"
|
|
3570
|
+
});
|
|
3571
|
+
const market = await client.markets.fetch(inputs.marketId);
|
|
3572
|
+
if (!market) throw new Error(`adminOverrideResolution: market ${inputs.marketId} not found`);
|
|
3573
|
+
if (market.state !== MarketState.PendingResolution) {
|
|
3574
|
+
throw new Error(
|
|
3575
|
+
`adminOverrideResolution: market state is ${market.state}, expected PendingResolution (4)`
|
|
3576
|
+
);
|
|
3577
|
+
}
|
|
3578
|
+
if (!market.disputed) {
|
|
3579
|
+
throw new Error("adminOverrideResolution: market is not disputed");
|
|
3580
|
+
}
|
|
3581
|
+
emitProgress(inputs.onProgress, "submitting", { message: "Submitting override" });
|
|
3582
|
+
const ix = await adminOverrideResolutionIx(client, {
|
|
3583
|
+
admin: inputs.admin,
|
|
3584
|
+
marketId: inputs.marketId,
|
|
3585
|
+
outcomeValue: inputs.outcomeValue
|
|
3586
|
+
});
|
|
3587
|
+
const signature = await sendIx(client, ix);
|
|
3588
|
+
emitProgress(inputs.onProgress, "refetching");
|
|
3589
|
+
const [pda] = marketPda(inputs.marketId, client.programId);
|
|
3590
|
+
const out = { signature, market: await client.markets.fetchByPda(pda) };
|
|
3591
|
+
emitProgress(inputs.onProgress, "done", { signature });
|
|
3592
|
+
return out;
|
|
3593
|
+
}
|
|
3437
3594
|
var ALL_EVENT_NAMES = /* @__PURE__ */ new Set([
|
|
3438
3595
|
"MarketCreatedEvent",
|
|
3439
3596
|
"BetPlacedEvent",
|
|
@@ -3441,7 +3598,10 @@ var ALL_EVENT_NAMES = /* @__PURE__ */ new Set([
|
|
|
3441
3598
|
"MarketCancelledEvent",
|
|
3442
3599
|
"CreatorWithdrawnEvent",
|
|
3443
3600
|
"PayoutClaimedEvent",
|
|
3444
|
-
"RefundClaimedEvent"
|
|
3601
|
+
"RefundClaimedEvent",
|
|
3602
|
+
"ResolutionFlaggedEvent",
|
|
3603
|
+
"MarketFinalizedEvent",
|
|
3604
|
+
"ResolutionOverriddenEvent"
|
|
3445
3605
|
]);
|
|
3446
3606
|
var _coder = null;
|
|
3447
3607
|
var _parser = null;
|
|
@@ -3550,6 +3710,15 @@ function onPayoutClaimed(connection, callback, opts) {
|
|
|
3550
3710
|
function onRefundClaimed(connection, callback, opts) {
|
|
3551
3711
|
return subscribeEvent(connection, "RefundClaimedEvent", callback, opts);
|
|
3552
3712
|
}
|
|
3713
|
+
function onResolutionFlagged(connection, callback, opts) {
|
|
3714
|
+
return subscribeEvent(connection, "ResolutionFlaggedEvent", callback, opts);
|
|
3715
|
+
}
|
|
3716
|
+
function onMarketFinalized(connection, callback, opts) {
|
|
3717
|
+
return subscribeEvent(connection, "MarketFinalizedEvent", callback, opts);
|
|
3718
|
+
}
|
|
3719
|
+
function onResolutionOverridden(connection, callback, opts) {
|
|
3720
|
+
return subscribeEvent(connection, "ResolutionOverriddenEvent", callback, opts);
|
|
3721
|
+
}
|
|
3553
3722
|
async function pollEvents(connection, opts = {}) {
|
|
3554
3723
|
const pid = opts.programId ?? PROGRAM_ID;
|
|
3555
3724
|
const sigs = await connection.getSignaturesForAddress(pid, {
|
|
@@ -3619,6 +3788,8 @@ var CypherClient = class {
|
|
|
3619
3788
|
bets;
|
|
3620
3789
|
resolveIx;
|
|
3621
3790
|
claimIx;
|
|
3791
|
+
/** v0.2+: dispute / challenge-window instruction builders. */
|
|
3792
|
+
resolutionIx;
|
|
3622
3793
|
constructor(opts) {
|
|
3623
3794
|
this.connection = opts.connection;
|
|
3624
3795
|
this.wallet = opts.wallet;
|
|
@@ -3667,7 +3838,10 @@ var CypherClient = class {
|
|
|
3667
3838
|
placeBet: (inputs) => placeBetAction(this, inputs),
|
|
3668
3839
|
resolveMarket: (inputs) => resolveMarketAction(this, inputs),
|
|
3669
3840
|
claimPayout: (inputs) => claimPayoutAction(this, inputs),
|
|
3670
|
-
claimRefund: (inputs) => claimRefundAction(this, inputs)
|
|
3841
|
+
claimRefund: (inputs) => claimRefundAction(this, inputs),
|
|
3842
|
+
flagResolution: (inputs) => flagResolutionAction(this, inputs),
|
|
3843
|
+
finalizeResolution: (inputs) => finalizeResolutionAction(this, inputs),
|
|
3844
|
+
adminOverrideResolution: (inputs) => adminOverrideResolutionAction(this, inputs)
|
|
3671
3845
|
};
|
|
3672
3846
|
this.events = {
|
|
3673
3847
|
subscribeAll: (cb, opts2) => subscribeAll(this.connection, cb, opts2),
|
|
@@ -3720,6 +3894,11 @@ var CypherClient = class {
|
|
|
3720
3894
|
refundYesnoIx: (p) => claimRefundYesnoIx(this, p),
|
|
3721
3895
|
refundMultiIx: (p) => claimRefundMultiIx(this, p)
|
|
3722
3896
|
};
|
|
3897
|
+
this.resolutionIx = {
|
|
3898
|
+
flagIx: (p) => flagResolutionIx(this, p),
|
|
3899
|
+
finalizeIx: (p) => finalizeResolutionIx(this, p),
|
|
3900
|
+
adminOverrideIx: (p) => adminOverrideResolutionIx(this, p)
|
|
3901
|
+
};
|
|
3723
3902
|
}
|
|
3724
3903
|
};
|
|
3725
3904
|
function resolveCluster(cluster, rpcEndpoint) {
|
|
@@ -3748,6 +3927,6 @@ safe-buffer/index.js:
|
|
|
3748
3927
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
3749
3928
|
*/
|
|
3750
3929
|
|
|
3751
|
-
export { ACCOUNT_DISCRIMINATOR_SIZE, ADDRESS_LOOKUP_TABLE_PROGRAM_ID, ALL_CIRCUITS, ALL_EVENT_NAMES, BPS_DENOMINATOR, CIRCUITS, CLUSTERS, CREATOR_BOND, CYPHER_ERROR_MESSAGES, CypherClient, CypherErrorCode, DEFAULT_CLAIM_PERIOD_SECS, DEFAULT_REFUND_PERIOD_SECS, DEFAULT_RESOLUTION_WINDOW_SECS, ENCRYPTED_POSITION_OFFSETS, GLOBAL_STATE_OFFSETS, IDL, IDL_PROGRAM_ID, INIT_COMP_DEF_INSTRUCTIONS, KNOWN_MINTS, LP_POSITION_OFFSETS, MARKET_OFFSETS, MAX_LP_FEE_BPS, MAX_OUTCOMES_MULTI, MAX_PROTOCOL_FEE_BPS, MAX_QUESTION_BYTES, MIN_BET_USDC, MIN_OUTCOMES_MULTI, MarketCategory, MarketState, MarketType, ODDS_SCALE, PROGRAM_ID, adminClaimRemainingIx, arciumSignerPda, awaitComputation, bigIntToLeBytes, buildAllInitCompDefIx, buildArciumQueueAccounts, cancelMarketAction, cancelMarketIx, claimPayoutAction, claimPayoutMultiIx, claimPayoutYesnoIx, claimRefundAction, claimRefundMultiIx, claimRefundYesnoIx, compDefOffsetBytes, compDefOffsetU32, computeFees, createCipher, createMarketAction, createMarketIx, createMarketMultiAction, createMarketMultiIx, createUserKeypair, cypherErrorName, decryptBetInput, deriveSharedSecret, discriminatorFilter, encryptBetInput, encryptRefundInput, fetchAllMarkets, fetchGlobalState, fetchLpPosition, fetchLpPositionsByProvider, fetchMarket, fetchMarketsByCreator, fetchMarketsByState, fetchMxeLookupTable, fetchMxePublicKey, fetchPosition, fetchPositionsForMarket, fetchUserPositions, freshNonce, globalStatePda, initCompDefIx, initializeIx, isBetAmountValid, isValidCloseTime, keypairToWallet, leBytesToBigInt, lpPositionFilters, lpPositionPda, marketFilters, marketPda, marketPhase, marketVaultPda, onBetPlaced, onCreatorWithdrawn, onMarketCancelled, onMarketCreated, onMarketResolved, onPayoutClaimed, onRefundClaimed, parseCypherError, parseLogs, parseLogsFor, placeBetAction, placePrivateBetMultiIx, placePrivateBetYesnoIx, pollEvents, positionFilters, positionPda, projectDeadlines, randomComputationOffset, readonlyWallet, resolveMarketAction, resolveMarketMultiIx, resolveMarketYesnoIx, sendIx, sendIxAndAwaitArcium, subscribeAll, subscribeEvent, toBN, updateAcceptedMintIx, userAta, withdrawCreatorFundsAction, withdrawCreatorFundsIx };
|
|
3930
|
+
export { ACCOUNT_DISCRIMINATOR_SIZE, ADDRESS_LOOKUP_TABLE_PROGRAM_ID, ALL_CIRCUITS, ALL_EVENT_NAMES, BPS_DENOMINATOR, CIRCUITS, CLUSTERS, CREATOR_BOND, CYPHER_ERROR_MESSAGES, CypherClient, CypherErrorCode, DEFAULT_CLAIM_PERIOD_SECS, DEFAULT_REFUND_PERIOD_SECS, DEFAULT_RESOLUTION_WINDOW_SECS, ENCRYPTED_POSITION_OFFSETS, GLOBAL_STATE_OFFSETS, IDL, IDL_PROGRAM_ID, INIT_COMP_DEF_INSTRUCTIONS, KNOWN_MINTS, LP_POSITION_OFFSETS, MARKET_OFFSETS, MAX_CHALLENGE_PERIOD_SECS, MAX_LP_FEE_BPS, MAX_OUTCOMES_MULTI, MAX_PROTOCOL_FEE_BPS, MAX_QUESTION_BYTES, MIN_BET_USDC, MIN_CHALLENGE_PERIOD_SECS, MIN_OUTCOMES_MULTI, MarketCategory, MarketState, MarketType, ODDS_SCALE, PROGRAM_ID, adminClaimRemainingIx, adminOverrideResolutionAction, adminOverrideResolutionIx, arciumSignerPda, awaitComputation, bigIntToLeBytes, buildAllInitCompDefIx, buildArciumQueueAccounts, cancelMarketAction, cancelMarketIx, claimPayoutAction, claimPayoutMultiIx, claimPayoutYesnoIx, claimRefundAction, claimRefundMultiIx, claimRefundYesnoIx, compDefOffsetBytes, compDefOffsetU32, computeFees, createCipher, createMarketAction, createMarketIx, createMarketMultiAction, createMarketMultiIx, createUserKeypair, cypherErrorName, decryptBetInput, deriveSharedSecret, discriminatorFilter, encryptBetInput, encryptRefundInput, fetchAllMarkets, fetchGlobalState, fetchLpPosition, fetchLpPositionsByProvider, fetchMarket, fetchMarketsByCreator, fetchMarketsByState, fetchMxeLookupTable, fetchMxePublicKey, fetchPosition, fetchPositionsForMarket, fetchUserPositions, finalizeResolutionAction, finalizeResolutionIx, flagResolutionAction, flagResolutionIx, freshNonce, globalStatePda, initCompDefIx, initializeIx, isBetAmountValid, isValidCloseTime, keypairToWallet, leBytesToBigInt, lpPositionFilters, lpPositionPda, marketFilters, marketPda, marketPhase, marketVaultPda, onBetPlaced, onCreatorWithdrawn, onMarketCancelled, onMarketCreated, onMarketFinalized, onMarketResolved, onPayoutClaimed, onRefundClaimed, onResolutionFlagged, onResolutionOverridden, parseCypherError, parseLogs, parseLogsFor, placeBetAction, placePrivateBetMultiIx, placePrivateBetYesnoIx, pollEvents, positionFilters, positionPda, projectDeadlines, randomComputationOffset, readonlyWallet, resolveMarketAction, resolveMarketMultiIx, resolveMarketYesnoIx, sendIx, sendIxAndAwaitArcium, subscribeAll, subscribeEvent, toBN, updateAcceptedMintIx, userAta, withdrawCreatorFundsAction, withdrawCreatorFundsIx };
|
|
3752
3931
|
//# sourceMappingURL=index.js.map
|
|
3753
3932
|
//# sourceMappingURL=index.js.map
|