@playmos/sdk 0.3.7 → 0.3.9
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 +3 -3
- package/dist/{chunk-VYR6BBHF.js → chunk-UZECDT6F.js} +15 -1
- package/dist/{errors-CdVzHuhY.d.cts → errors-BMlWHsMb.d.cts} +72 -7
- package/dist/{errors-CdVzHuhY.d.ts → errors-BMlWHsMb.d.ts} +72 -7
- package/dist/index.cjs +563 -183
- package/dist/index.d.cts +51 -9
- package/dist/index.d.ts +51 -9
- package/dist/index.js +549 -185
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/package.json +5 -1
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 CancelRoundResult, A as ActiveSeriesRound,
|
|
2
|
-
export {
|
|
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';
|
|
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: {
|
|
@@ -477,13 +510,14 @@ declare class Playmos {
|
|
|
477
510
|
settle: (input: RoundSettleInput) => Promise<SettleRoundResult>;
|
|
478
511
|
/**
|
|
479
512
|
* Cancel an open/locked round (operator sk_ only). Refunds entrants' escrowed ~90%
|
|
480
|
-
* and frees the series latch
|
|
481
|
-
*
|
|
513
|
+
* and frees the series latch (#346 / #376).
|
|
514
|
+
*
|
|
515
|
+
* **Default is submit-only:** may return `status: "cancelling"` after broadcast —
|
|
516
|
+
* that is **not** success. Only `status: "cancelled"` means the chain is terminal.
|
|
517
|
+
* Pass `{ confirm: true }` to poll until cancelled or timeout (honest `cancelling`
|
|
518
|
+
* if still pending — never invents terminal success).
|
|
482
519
|
*/
|
|
483
|
-
cancel: (input:
|
|
484
|
-
roundId: string;
|
|
485
|
-
gameId?: string;
|
|
486
|
-
}) => Promise<CancelRoundResult>;
|
|
520
|
+
cancel: (input: RoundCancelInput) => Promise<CancelRoundResult>;
|
|
487
521
|
get: (input: {
|
|
488
522
|
roundId: string;
|
|
489
523
|
}) => Promise<RoundState>;
|
|
@@ -606,6 +640,14 @@ declare class Playmos {
|
|
|
606
640
|
*/
|
|
607
641
|
private readonly mockPayments;
|
|
608
642
|
constructor(config: PlaymosConfig);
|
|
643
|
+
/**
|
|
644
|
+
* Wallet timeout policy (#462 / PR #463 residual).
|
|
645
|
+
* - connectTimeoutMs → eth_requestAccounts only
|
|
646
|
+
* - machine RPCs → 20s default
|
|
647
|
+
* - wallet_sendCalls → unbounded (0) — never short-time a payment sheet
|
|
648
|
+
*/
|
|
649
|
+
private walletTimeoutPolicy;
|
|
650
|
+
private walletProvider;
|
|
609
651
|
/** Connect the player's wallet and return their address. */
|
|
610
652
|
connect(): Promise<`0x${string}`>;
|
|
611
653
|
/**
|
|
@@ -848,4 +890,4 @@ declare function ulid(seedTime?: number): string;
|
|
|
848
890
|
/** `${prefix}_${ulid()}` — e.g. `pay_01J…`, `entry_01J…`, `idem_01J…`. */
|
|
849
891
|
declare function prefixedId(prefix: string): string;
|
|
850
892
|
|
|
851
|
-
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, 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 };
|
|
893
|
+
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 };
|
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 CancelRoundResult, A as ActiveSeriesRound,
|
|
2
|
-
export {
|
|
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';
|
|
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: {
|
|
@@ -477,13 +510,14 @@ declare class Playmos {
|
|
|
477
510
|
settle: (input: RoundSettleInput) => Promise<SettleRoundResult>;
|
|
478
511
|
/**
|
|
479
512
|
* Cancel an open/locked round (operator sk_ only). Refunds entrants' escrowed ~90%
|
|
480
|
-
* and frees the series latch
|
|
481
|
-
*
|
|
513
|
+
* and frees the series latch (#346 / #376).
|
|
514
|
+
*
|
|
515
|
+
* **Default is submit-only:** may return `status: "cancelling"` after broadcast —
|
|
516
|
+
* that is **not** success. Only `status: "cancelled"` means the chain is terminal.
|
|
517
|
+
* Pass `{ confirm: true }` to poll until cancelled or timeout (honest `cancelling`
|
|
518
|
+
* if still pending — never invents terminal success).
|
|
482
519
|
*/
|
|
483
|
-
cancel: (input:
|
|
484
|
-
roundId: string;
|
|
485
|
-
gameId?: string;
|
|
486
|
-
}) => Promise<CancelRoundResult>;
|
|
520
|
+
cancel: (input: RoundCancelInput) => Promise<CancelRoundResult>;
|
|
487
521
|
get: (input: {
|
|
488
522
|
roundId: string;
|
|
489
523
|
}) => Promise<RoundState>;
|
|
@@ -606,6 +640,14 @@ declare class Playmos {
|
|
|
606
640
|
*/
|
|
607
641
|
private readonly mockPayments;
|
|
608
642
|
constructor(config: PlaymosConfig);
|
|
643
|
+
/**
|
|
644
|
+
* Wallet timeout policy (#462 / PR #463 residual).
|
|
645
|
+
* - connectTimeoutMs → eth_requestAccounts only
|
|
646
|
+
* - machine RPCs → 20s default
|
|
647
|
+
* - wallet_sendCalls → unbounded (0) — never short-time a payment sheet
|
|
648
|
+
*/
|
|
649
|
+
private walletTimeoutPolicy;
|
|
650
|
+
private walletProvider;
|
|
609
651
|
/** Connect the player's wallet and return their address. */
|
|
610
652
|
connect(): Promise<`0x${string}`>;
|
|
611
653
|
/**
|
|
@@ -848,4 +890,4 @@ declare function ulid(seedTime?: number): string;
|
|
|
848
890
|
/** `${prefix}_${ulid()}` — e.g. `pay_01J…`, `entry_01J…`, `idem_01J…`. */
|
|
849
891
|
declare function prefixedId(prefix: string): string;
|
|
850
892
|
|
|
851
|
-
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, 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 };
|
|
893
|
+
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 };
|