@playmos/sdk 0.3.8 → 0.3.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as Network, P as PlaymosConfig, W as WebhookEvent, R as RoundOpenInput, a as RoundState, b as RoundSettleInput, S as SettleRoundResult, c as RoundCancelInput, C as CancelRoundResult, A as ActiveSeriesRound, d as PrizeBalance, e as WithdrawResult, f as AgentWallet, g as AgentFundResult, T as TransferResult, E as EscrowHoldInput, h as EscrowHoldResult, i as EscrowResolveResult, M as MarketplaceListInput, L as Listing, j as MarketplaceSaleResult, k as MarketplaceGetResult, l as PayInput, m as Payment, n as EnterRoundInput, o as TransferReconcile, p as WaitOptions, q as TransferInput, r as TransferConfirmOptions, V as VerifyResult, s as PayoutRule } from './errors-BMlWHsMb.cjs';
2
- export { t as ActiveForSeriesResult, u as AgentEconomyConfig, v as AlreadyEnteredError, w as ApiError, x as AuthError, y as ConfigError, z as ContractConfig, B as Eip1193Provider, G as GasConfig, D as GasMode, I as InsufficientGasError, F as InvalidAmountError, H as ListingStatus, J as MarketplaceItem, K as MarketplaceSale, O as MissingFieldError, Q as NothingToWithdrawError, U as PaymentFailedError, X as PaymentStatus, Y as PlaymosError, Z as PlaymosErrorCode, _ as RetryOptions, $ as RoundStatus, a0 as WalletConfig, a1 as WalletConnectionError, a2 as WalletConnector, a3 as WalletTimeoutError, a4 as WebhookEventType } from './errors-BMlWHsMb.cjs';
1
+ import { N as Network, P as PlaymosConfig, W as WebhookEvent, R as RoundOpenInput, a as RoundState, b as RoundSettleInput, S as SettleRoundResult, c as RoundCancelInput, C as CancelRoundResult, d as RoundGetResult, A as ActiveSeriesRound, e as PrizeBalance, f as WithdrawResult, g as AgentWallet, h as AgentFundResult, T as TransferResult, E as EscrowHoldInput, i as EscrowHoldResult, j as EscrowResolveResult, M as MarketplaceListInput, L as Listing, k as MarketplaceSaleResult, l as MarketplaceGetResult, m as PayInput, n as Payment, o as EnterRoundInput, p as TransferReconcile, q as WaitOptions, r as TransferInput, s as TransferConfirmOptions, V as VerifyResult, t as PayoutRule } from './errors-Chizbb96.cjs';
2
+ export { u as ActiveForSeriesResult, v as AgentEconomyConfig, w as AlreadyEnteredError, x as ApiError, y as AuthError, z as ConfigError, B as ContractConfig, D as Eip1193Provider, G as GasConfig, F as GasMode, I as InsufficientGasError, H as InvalidAmountError, J as ListingStatus, K as MarketplaceItem, O as MarketplaceSale, Q as MissingFieldError, U as NothingToWithdrawError, X as PaymentFailedError, Y as PaymentStatus, Z as PlaymosError, _ as PlaymosErrorCode, $ as RetryOptions, a0 as RoundGetVia, a1 as RoundStatus, a2 as WalletConfig, a3 as WalletConnectionError, a4 as WalletConnector, a5 as WalletTimeoutError, a6 as WebhookEventType } from './errors-Chizbb96.cjs';
3
3
 
4
4
  /**
5
5
  * Environment resolution + the canonical address book.
@@ -463,11 +463,44 @@ declare class Playmos {
463
463
  * rounds.settle({ ranking }) → contract pays winners.
464
464
  *
465
465
  * Operator txs are signed by the Playmos service (OPERATOR_ROLE key).
466
+ *
467
+ * Offline `mock: true`: settle applies the stored payout rule and the 60/30/10
468
+ * pool leg across entries (#490). No series seed bank — mock pool is a floor,
469
+ * not a forecast of a live series with inherited seed.
466
470
  */
467
471
  /** Offline mock store for rounds.open/lock/settle/get when `mock: true` (3-game dogfood). */
468
472
  private readonly mockRounds;
469
473
  /** Mock withdrawable credits after settle — key `${roundId}:${walletLower}` (#240 offline prize). */
470
474
  private readonly mockWithdrawable;
475
+ /**
476
+ * Mock pot after per-entry rake (PrizePool escrowed sum) — keyed by roundId (#490).
477
+ * Payable pool at lock = pot × POOL_BPS / (POOL_BPS + SEED_BPS); inherited seed = 0 offline.
478
+ */
479
+ private readonly mockPotMicro;
480
+ /** Persisted settle winners for re-settle replay (#490 C2) — never re-invent pool-to-everyone. */
481
+ private readonly mockSettleWinners;
482
+ /**
483
+ * Resolve mock round by roundId **or** roundKey (kit `entryProvider` keys by roundKey, #490 C3).
484
+ */
485
+ private findMockRound;
486
+ /**
487
+ * 6dp USD → micro for mock winner amounts (#490 C1). Must not use 2dp `validateAmount`
488
+ * (would zero 0.135 from top-n 30% of $0.45).
489
+ */
490
+ private parseUsdToMicroLoose;
491
+ /** Live-shaped 400 for mock payout validation (C5) — never leak raw PayoutError. */
492
+ private mockPayoutApiError;
493
+ /**
494
+ * Accumulate one mock entry into the pot (chain parity: rake off top, then lock split).
495
+ * No-op when no matching open/locked round — never 404 (C4).
496
+ */
497
+ private mockAccumulateEntry;
498
+ /**
499
+ * Payable pool micro for mock lock/settle.
500
+ * With recorded entries: pot × POOL/(POOL+SEED) (seed bank = 0 offline).
501
+ * Zero entries: fall back to entryAmount micro (C4 — preserves existing suite).
502
+ */
503
+ private mockPayablePoolMicro;
471
504
  readonly rounds: {
472
505
  open: (input: RoundOpenInput) => Promise<RoundState>;
473
506
  lock: (input: {
@@ -485,9 +518,22 @@ declare class Playmos {
485
518
  * if still pending — never invents terminal success).
486
519
  */
487
520
  cancel: (input: RoundCancelInput) => Promise<CancelRoundResult>;
521
+ /**
522
+ * Round state only (stable). Prefer {@link getWithMeta} when you need service
523
+ * read-path honesty (`via` / `chainReadFailed` — #497 / #501).
524
+ */
488
525
  get: (input: {
489
526
  roundId: string;
490
527
  }) => Promise<RoundState>;
528
+ /**
529
+ * Round state + transport meta from GET /v1/rounds/:id (#501).
530
+ * Does **not** attach `via` onto RoundState (Claude rejected option B — hub would
531
+ * silently pick it up and leak into settle/cancel paths that call get()).
532
+ * Under `mock: true`, meta fields are **omitted** (no eth_call; do not invent "cache").
533
+ */
534
+ getWithMeta: (input: {
535
+ roundId: string;
536
+ }) => Promise<RoundGetResult>;
491
537
  /**
492
538
  * Authoritative series latch (#351) — `null` means **proven free**.
493
539
  * `GET /v1/series/:seriesKey/active?gameId=…` — not a candidate probe.
@@ -517,6 +563,11 @@ declare class Playmos {
517
563
  withdraw: (input: {
518
564
  prizePoolAddress?: `0x${string}`;
519
565
  roundId?: string;
566
+ /**
567
+ * Winner wallet (0x…). **Required under mock** (#495 Claude) — live path uses the
568
+ * connected provider. Without this, mock paid the first non-zero credit to anyone.
569
+ */
570
+ wallet?: string;
520
571
  /** Pre-check claimable; default true. Set false only if you already called `prize()`. */
521
572
  checkBalance?: boolean;
522
573
  }) => Promise<WithdrawResult>;
@@ -857,4 +908,4 @@ declare function ulid(seedTime?: number): string;
857
908
  /** `${prefix}_${ulid()}` — e.g. `pay_01J…`, `entry_01J…`, `idem_01J…`. */
858
909
  declare function prefixedId(prefix: string): string;
859
910
 
860
- export { ActiveSeriesRound, AgentFundResult, AgentWallet, type Authorization, CHAIN_ID, CancelRoundResult, type CreatePaymentRequirementInput, DEFAULT_API_BASE_URL, EnterRoundInput, EscrowHoldInput, EscrowHoldResult, EscrowResolveResult, Listing, MICRO_PER_USDC, MarketplaceGetResult, MarketplaceListInput, MarketplaceSaleResult, Network, PayInput, Payment, type PaymentRequirement, PayoutError, PayoutRule, PayoutRule as PayoutRuleCompute, Playmos, PlaymosConfig, PrizeBalance, RoundCancelInput, RoundOpenInput, RoundSettleInput, RoundState, SettleRoundResult, type SettlementAsset, TransferConfirmOptions, TransferInput, TransferReconcile, TransferResult, USDC_ADDRESS, USDC_DECIMALS, VerifyResult, WaitOptions, type WalletSignatureAuthorization, WebhookEvent, WithdrawResult, type X402ChallengeInput, type X402ChallengeResult, type X402FulfillAuthorization, type X402PayInput, type X402PayloadAuthorization, type X402PayloadMode, type X402PaymentRequired, type X402SettleResult, clientRuntimeSignals, computeIapSplit, computePayout, computePoolSplit, createPaymentRequirement, createX402Challenge, decodePaymentHeader, encodePaymentHeader, formatMicroToUsd, isClientRuntime, isWalletSignatureAuthorization, isX402PayloadAuthorization, networkToCaip2, parsePaymentRequirement, parseUsdToMicro, prefixedId, previewEscrowFee, previewIapSplit, previewMarketplaceSplit, previewPoolSplit, previewTransferSplit, resolveEnv, serializePaymentRequirement, toX402PaymentRequired, ulid, validateX402ChallengeInput };
911
+ export { ActiveSeriesRound, AgentFundResult, AgentWallet, type Authorization, CHAIN_ID, CancelRoundResult, type CreatePaymentRequirementInput, DEFAULT_API_BASE_URL, EnterRoundInput, EscrowHoldInput, EscrowHoldResult, EscrowResolveResult, Listing, MICRO_PER_USDC, MarketplaceGetResult, MarketplaceListInput, MarketplaceSaleResult, Network, PayInput, Payment, type PaymentRequirement, PayoutError, PayoutRule, PayoutRule as PayoutRuleCompute, Playmos, PlaymosConfig, PrizeBalance, RoundCancelInput, RoundGetResult, RoundOpenInput, RoundSettleInput, RoundState, SettleRoundResult, type SettlementAsset, TransferConfirmOptions, TransferInput, TransferReconcile, TransferResult, USDC_ADDRESS, USDC_DECIMALS, VerifyResult, WaitOptions, type WalletSignatureAuthorization, WebhookEvent, WithdrawResult, type X402ChallengeInput, type X402ChallengeResult, type X402FulfillAuthorization, type X402PayInput, type X402PayloadAuthorization, type X402PayloadMode, type X402PaymentRequired, type X402SettleResult, clientRuntimeSignals, computeIapSplit, computePayout, computePoolSplit, createPaymentRequirement, createX402Challenge, decodePaymentHeader, encodePaymentHeader, formatMicroToUsd, isClientRuntime, isWalletSignatureAuthorization, isX402PayloadAuthorization, networkToCaip2, parsePaymentRequirement, parseUsdToMicro, prefixedId, previewEscrowFee, previewIapSplit, previewMarketplaceSplit, previewPoolSplit, previewTransferSplit, resolveEnv, serializePaymentRequirement, toX402PaymentRequired, ulid, validateX402ChallengeInput };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as Network, P as PlaymosConfig, W as WebhookEvent, R as RoundOpenInput, a as RoundState, b as RoundSettleInput, S as SettleRoundResult, c as RoundCancelInput, C as CancelRoundResult, A as ActiveSeriesRound, d as PrizeBalance, e as WithdrawResult, f as AgentWallet, g as AgentFundResult, T as TransferResult, E as EscrowHoldInput, h as EscrowHoldResult, i as EscrowResolveResult, M as MarketplaceListInput, L as Listing, j as MarketplaceSaleResult, k as MarketplaceGetResult, l as PayInput, m as Payment, n as EnterRoundInput, o as TransferReconcile, p as WaitOptions, q as TransferInput, r as TransferConfirmOptions, V as VerifyResult, s as PayoutRule } from './errors-BMlWHsMb.js';
2
- export { t as ActiveForSeriesResult, u as AgentEconomyConfig, v as AlreadyEnteredError, w as ApiError, x as AuthError, y as ConfigError, z as ContractConfig, B as Eip1193Provider, G as GasConfig, D as GasMode, I as InsufficientGasError, F as InvalidAmountError, H as ListingStatus, J as MarketplaceItem, K as MarketplaceSale, O as MissingFieldError, Q as NothingToWithdrawError, U as PaymentFailedError, X as PaymentStatus, Y as PlaymosError, Z as PlaymosErrorCode, _ as RetryOptions, $ as RoundStatus, a0 as WalletConfig, a1 as WalletConnectionError, a2 as WalletConnector, a3 as WalletTimeoutError, a4 as WebhookEventType } from './errors-BMlWHsMb.js';
1
+ import { N as Network, P as PlaymosConfig, W as WebhookEvent, R as RoundOpenInput, a as RoundState, b as RoundSettleInput, S as SettleRoundResult, c as RoundCancelInput, C as CancelRoundResult, d as RoundGetResult, A as ActiveSeriesRound, e as PrizeBalance, f as WithdrawResult, g as AgentWallet, h as AgentFundResult, T as TransferResult, E as EscrowHoldInput, i as EscrowHoldResult, j as EscrowResolveResult, M as MarketplaceListInput, L as Listing, k as MarketplaceSaleResult, l as MarketplaceGetResult, m as PayInput, n as Payment, o as EnterRoundInput, p as TransferReconcile, q as WaitOptions, r as TransferInput, s as TransferConfirmOptions, V as VerifyResult, t as PayoutRule } from './errors-Chizbb96.js';
2
+ export { u as ActiveForSeriesResult, v as AgentEconomyConfig, w as AlreadyEnteredError, x as ApiError, y as AuthError, z as ConfigError, B as ContractConfig, D as Eip1193Provider, G as GasConfig, F as GasMode, I as InsufficientGasError, H as InvalidAmountError, J as ListingStatus, K as MarketplaceItem, O as MarketplaceSale, Q as MissingFieldError, U as NothingToWithdrawError, X as PaymentFailedError, Y as PaymentStatus, Z as PlaymosError, _ as PlaymosErrorCode, $ as RetryOptions, a0 as RoundGetVia, a1 as RoundStatus, a2 as WalletConfig, a3 as WalletConnectionError, a4 as WalletConnector, a5 as WalletTimeoutError, a6 as WebhookEventType } from './errors-Chizbb96.js';
3
3
 
4
4
  /**
5
5
  * Environment resolution + the canonical address book.
@@ -463,11 +463,44 @@ declare class Playmos {
463
463
  * rounds.settle({ ranking }) → contract pays winners.
464
464
  *
465
465
  * Operator txs are signed by the Playmos service (OPERATOR_ROLE key).
466
+ *
467
+ * Offline `mock: true`: settle applies the stored payout rule and the 60/30/10
468
+ * pool leg across entries (#490). No series seed bank — mock pool is a floor,
469
+ * not a forecast of a live series with inherited seed.
466
470
  */
467
471
  /** Offline mock store for rounds.open/lock/settle/get when `mock: true` (3-game dogfood). */
468
472
  private readonly mockRounds;
469
473
  /** Mock withdrawable credits after settle — key `${roundId}:${walletLower}` (#240 offline prize). */
470
474
  private readonly mockWithdrawable;
475
+ /**
476
+ * Mock pot after per-entry rake (PrizePool escrowed sum) — keyed by roundId (#490).
477
+ * Payable pool at lock = pot × POOL_BPS / (POOL_BPS + SEED_BPS); inherited seed = 0 offline.
478
+ */
479
+ private readonly mockPotMicro;
480
+ /** Persisted settle winners for re-settle replay (#490 C2) — never re-invent pool-to-everyone. */
481
+ private readonly mockSettleWinners;
482
+ /**
483
+ * Resolve mock round by roundId **or** roundKey (kit `entryProvider` keys by roundKey, #490 C3).
484
+ */
485
+ private findMockRound;
486
+ /**
487
+ * 6dp USD → micro for mock winner amounts (#490 C1). Must not use 2dp `validateAmount`
488
+ * (would zero 0.135 from top-n 30% of $0.45).
489
+ */
490
+ private parseUsdToMicroLoose;
491
+ /** Live-shaped 400 for mock payout validation (C5) — never leak raw PayoutError. */
492
+ private mockPayoutApiError;
493
+ /**
494
+ * Accumulate one mock entry into the pot (chain parity: rake off top, then lock split).
495
+ * No-op when no matching open/locked round — never 404 (C4).
496
+ */
497
+ private mockAccumulateEntry;
498
+ /**
499
+ * Payable pool micro for mock lock/settle.
500
+ * With recorded entries: pot × POOL/(POOL+SEED) (seed bank = 0 offline).
501
+ * Zero entries: fall back to entryAmount micro (C4 — preserves existing suite).
502
+ */
503
+ private mockPayablePoolMicro;
471
504
  readonly rounds: {
472
505
  open: (input: RoundOpenInput) => Promise<RoundState>;
473
506
  lock: (input: {
@@ -485,9 +518,22 @@ declare class Playmos {
485
518
  * if still pending — never invents terminal success).
486
519
  */
487
520
  cancel: (input: RoundCancelInput) => Promise<CancelRoundResult>;
521
+ /**
522
+ * Round state only (stable). Prefer {@link getWithMeta} when you need service
523
+ * read-path honesty (`via` / `chainReadFailed` — #497 / #501).
524
+ */
488
525
  get: (input: {
489
526
  roundId: string;
490
527
  }) => Promise<RoundState>;
528
+ /**
529
+ * Round state + transport meta from GET /v1/rounds/:id (#501).
530
+ * Does **not** attach `via` onto RoundState (Claude rejected option B — hub would
531
+ * silently pick it up and leak into settle/cancel paths that call get()).
532
+ * Under `mock: true`, meta fields are **omitted** (no eth_call; do not invent "cache").
533
+ */
534
+ getWithMeta: (input: {
535
+ roundId: string;
536
+ }) => Promise<RoundGetResult>;
491
537
  /**
492
538
  * Authoritative series latch (#351) — `null` means **proven free**.
493
539
  * `GET /v1/series/:seriesKey/active?gameId=…` — not a candidate probe.
@@ -517,6 +563,11 @@ declare class Playmos {
517
563
  withdraw: (input: {
518
564
  prizePoolAddress?: `0x${string}`;
519
565
  roundId?: string;
566
+ /**
567
+ * Winner wallet (0x…). **Required under mock** (#495 Claude) — live path uses the
568
+ * connected provider. Without this, mock paid the first non-zero credit to anyone.
569
+ */
570
+ wallet?: string;
520
571
  /** Pre-check claimable; default true. Set false only if you already called `prize()`. */
521
572
  checkBalance?: boolean;
522
573
  }) => Promise<WithdrawResult>;
@@ -857,4 +908,4 @@ declare function ulid(seedTime?: number): string;
857
908
  /** `${prefix}_${ulid()}` — e.g. `pay_01J…`, `entry_01J…`, `idem_01J…`. */
858
909
  declare function prefixedId(prefix: string): string;
859
910
 
860
- export { ActiveSeriesRound, AgentFundResult, AgentWallet, type Authorization, CHAIN_ID, CancelRoundResult, type CreatePaymentRequirementInput, DEFAULT_API_BASE_URL, EnterRoundInput, EscrowHoldInput, EscrowHoldResult, EscrowResolveResult, Listing, MICRO_PER_USDC, MarketplaceGetResult, MarketplaceListInput, MarketplaceSaleResult, Network, PayInput, Payment, type PaymentRequirement, PayoutError, PayoutRule, PayoutRule as PayoutRuleCompute, Playmos, PlaymosConfig, PrizeBalance, RoundCancelInput, RoundOpenInput, RoundSettleInput, RoundState, SettleRoundResult, type SettlementAsset, TransferConfirmOptions, TransferInput, TransferReconcile, TransferResult, USDC_ADDRESS, USDC_DECIMALS, VerifyResult, WaitOptions, type WalletSignatureAuthorization, WebhookEvent, WithdrawResult, type X402ChallengeInput, type X402ChallengeResult, type X402FulfillAuthorization, type X402PayInput, type X402PayloadAuthorization, type X402PayloadMode, type X402PaymentRequired, type X402SettleResult, clientRuntimeSignals, computeIapSplit, computePayout, computePoolSplit, createPaymentRequirement, createX402Challenge, decodePaymentHeader, encodePaymentHeader, formatMicroToUsd, isClientRuntime, isWalletSignatureAuthorization, isX402PayloadAuthorization, networkToCaip2, parsePaymentRequirement, parseUsdToMicro, prefixedId, previewEscrowFee, previewIapSplit, previewMarketplaceSplit, previewPoolSplit, previewTransferSplit, resolveEnv, serializePaymentRequirement, toX402PaymentRequired, ulid, validateX402ChallengeInput };
911
+ export { ActiveSeriesRound, AgentFundResult, AgentWallet, type Authorization, CHAIN_ID, CancelRoundResult, type CreatePaymentRequirementInput, DEFAULT_API_BASE_URL, EnterRoundInput, EscrowHoldInput, EscrowHoldResult, EscrowResolveResult, Listing, MICRO_PER_USDC, MarketplaceGetResult, MarketplaceListInput, MarketplaceSaleResult, Network, PayInput, Payment, type PaymentRequirement, PayoutError, PayoutRule, PayoutRule as PayoutRuleCompute, Playmos, PlaymosConfig, PrizeBalance, RoundCancelInput, RoundGetResult, RoundOpenInput, RoundSettleInput, RoundState, SettleRoundResult, type SettlementAsset, TransferConfirmOptions, TransferInput, TransferReconcile, TransferResult, USDC_ADDRESS, USDC_DECIMALS, VerifyResult, WaitOptions, type WalletSignatureAuthorization, WebhookEvent, WithdrawResult, type X402ChallengeInput, type X402ChallengeResult, type X402FulfillAuthorization, type X402PayInput, type X402PayloadAuthorization, type X402PayloadMode, type X402PaymentRequired, type X402SettleResult, clientRuntimeSignals, computeIapSplit, computePayout, computePoolSplit, createPaymentRequirement, createX402Challenge, decodePaymentHeader, encodePaymentHeader, formatMicroToUsd, isClientRuntime, isWalletSignatureAuthorization, isX402PayloadAuthorization, networkToCaip2, parsePaymentRequirement, parseUsdToMicro, prefixedId, previewEscrowFee, previewIapSplit, previewMarketplaceSplit, previewPoolSplit, previewTransferSplit, resolveEnv, serializePaymentRequirement, toX402PaymentRequired, ulid, validateX402ChallengeInput };