@mysten-incubation/suipay-buyer 0.4.0-dev.10 → 0.4.0-dev.12
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 +8 -0
- package/dist/{chunk-RWUAPD7K.js → chunk-FWLPQH4N.js} +301 -16
- package/dist/index.d.ts +21 -12
- package/dist/index.js +292 -68
- package/dist/{native-transfer-DWs55Mse.d.ts → native-transfer-D0UoteMk.d.ts} +83 -4
- package/dist/native-transfer.d.ts +1 -1
- package/dist/native-transfer.js +3 -1
- package/package.json +1 -1
|
@@ -437,7 +437,7 @@ declare const ERRORS: {
|
|
|
437
437
|
};
|
|
438
438
|
};
|
|
439
439
|
readonly 'service.unavailable': {
|
|
440
|
-
readonly surfaces: readonly ["gateway", "console_server", "mcp_hosted", "browser"];
|
|
440
|
+
readonly surfaces: readonly ["gateway", "seller", "console_server", "mcp_hosted", "browser"];
|
|
441
441
|
readonly status: 503;
|
|
442
442
|
readonly title: "Service temporarily unavailable";
|
|
443
443
|
readonly paymentState: "not_charged";
|
|
@@ -449,6 +449,19 @@ declare const ERRORS: {
|
|
|
449
449
|
readonly message: "This isn't available right now. Try again in a moment.";
|
|
450
450
|
};
|
|
451
451
|
};
|
|
452
|
+
readonly 'service.halted': {
|
|
453
|
+
readonly surfaces: readonly ["gateway", "seller", "console_server", "mcp_hosted", "browser"];
|
|
454
|
+
readonly status: 503;
|
|
455
|
+
readonly title: "Services halted temporarily";
|
|
456
|
+
readonly paymentState: "not_charged";
|
|
457
|
+
readonly retry: "after_delay";
|
|
458
|
+
readonly retryAfterSeconds: 5;
|
|
459
|
+
readonly nextAction: "retry_later";
|
|
460
|
+
readonly user: {
|
|
461
|
+
readonly title: "Services halted temporarily";
|
|
462
|
+
readonly message: "Try again in a moment.";
|
|
463
|
+
};
|
|
464
|
+
};
|
|
452
465
|
readonly 'service.not_ready': {
|
|
453
466
|
readonly surfaces: readonly ["gateway", "seller", "console_server"];
|
|
454
467
|
readonly status: 503;
|
|
@@ -1693,6 +1706,31 @@ declare const ERRORS: {
|
|
|
1693
1706
|
readonly message: "Enter a valid agent address and try again.";
|
|
1694
1707
|
};
|
|
1695
1708
|
};
|
|
1709
|
+
readonly 'account.deposit_cap_exceeded': {
|
|
1710
|
+
readonly surfaces: readonly ["gateway", "sdk", "browser"];
|
|
1711
|
+
readonly status: 403;
|
|
1712
|
+
readonly title: "Deposit would exceed the vault beta cap";
|
|
1713
|
+
readonly paymentState: "not_charged";
|
|
1714
|
+
readonly retry: "never";
|
|
1715
|
+
readonly nextAction: "fix_request";
|
|
1716
|
+
readonly user: {
|
|
1717
|
+
readonly title: "Over the beta vault limit";
|
|
1718
|
+
readonly message: "This deposit would put your vault over the Mainnet Beta cap. Deposit less, or withdraw first.";
|
|
1719
|
+
};
|
|
1720
|
+
};
|
|
1721
|
+
readonly 'account.deposits_paused': {
|
|
1722
|
+
readonly surfaces: readonly ["gateway", "sdk", "browser"];
|
|
1723
|
+
readonly status: 403;
|
|
1724
|
+
readonly title: "Deposits are paused";
|
|
1725
|
+
readonly paymentState: "not_charged";
|
|
1726
|
+
readonly retry: "after_delay";
|
|
1727
|
+
readonly retryAfterSeconds: 30;
|
|
1728
|
+
readonly nextAction: "retry_later";
|
|
1729
|
+
readonly user: {
|
|
1730
|
+
readonly title: "Deposits paused";
|
|
1731
|
+
readonly message: "New deposits are paused right now. Withdrawals and spending still work. Try again after deposits resume.";
|
|
1732
|
+
};
|
|
1733
|
+
};
|
|
1696
1734
|
readonly 'account.finalize_mismatch': {
|
|
1697
1735
|
readonly surfaces: readonly ["gateway"];
|
|
1698
1736
|
readonly status: 409;
|
|
@@ -3358,13 +3396,35 @@ interface X402PaymentPayload {
|
|
|
3358
3396
|
};
|
|
3359
3397
|
}
|
|
3360
3398
|
|
|
3399
|
+
/**
|
|
3400
|
+
* Buyer helper: pick the sui:* exact accept the buyer's own intent allows,
|
|
3401
|
+
* return a PaymentPayload plus the `_meta` object to attach. Does not
|
|
3402
|
+
* implement an MCP client.
|
|
3403
|
+
*
|
|
3404
|
+
* The PaymentRequired comes from a server the buyer does not trust, so nothing
|
|
3405
|
+
* in it chooses what gets paid: the buyer states the network, asset, ceiling and
|
|
3406
|
+
* (optionally) recipient up front, and an accept outside that intent is never
|
|
3407
|
+
* handed to a signer.
|
|
3408
|
+
*/
|
|
3409
|
+
|
|
3410
|
+
/** What the buyer is willing to pay, decided before any server response is read. */
|
|
3411
|
+
interface BuyerPaymentIntent {
|
|
3412
|
+
/** CAIP-2 network the payment must settle on, e.g. `sui:testnet`. */
|
|
3413
|
+
network: string;
|
|
3414
|
+
/** Largest amount, in the asset's base units, the buyer will pay. */
|
|
3415
|
+
maxAmount: bigint | string;
|
|
3416
|
+
/** Coin type the payment must be made in. Compared in canonical form. */
|
|
3417
|
+
asset: string;
|
|
3418
|
+
/** When set, the accept's `payTo` must be this address. */
|
|
3419
|
+
recipient?: string;
|
|
3420
|
+
}
|
|
3361
3421
|
interface McpPaymentSigner {
|
|
3362
3422
|
buildNativeTransfer(accept: X402Accept): Promise<{
|
|
3363
3423
|
transaction: string;
|
|
3364
3424
|
signature: string;
|
|
3365
3425
|
}>;
|
|
3366
3426
|
}
|
|
3367
|
-
declare function buildMcpPaymentPayload(paymentRequired: X402PaymentRequired, signer: McpPaymentSigner): Promise<{
|
|
3427
|
+
declare function buildMcpPaymentPayload(paymentRequired: X402PaymentRequired, signer: McpPaymentSigner, intent: BuyerPaymentIntent): Promise<{
|
|
3368
3428
|
payload: X402PaymentPayload;
|
|
3369
3429
|
meta: {
|
|
3370
3430
|
'x402/payment': X402PaymentPayload;
|
|
@@ -3387,13 +3447,15 @@ declare function buildMcpPaymentPayload(paymentRequired: X402PaymentRequired, si
|
|
|
3387
3447
|
* withdrawal), which the gateway would classify as not native.
|
|
3388
3448
|
*/
|
|
3389
3449
|
|
|
3450
|
+
/** Default ceiling on auto-estimated gas when the caller does not pin `gas`. */
|
|
3451
|
+
declare const DEFAULT_NATIVE_MAX_GAS_BUDGET = 10000000n;
|
|
3390
3452
|
/**
|
|
3391
3453
|
* Fields the native builder actually reads. `extra.suipay` Move-call dressing
|
|
3392
3454
|
* (module/function) is not an input: this PTB is MoveCall-free by construction.
|
|
3393
3455
|
*/
|
|
3394
3456
|
type NativeTransferAccept = Pick<X402Accept, 'scheme' | 'network' | 'amount' | 'asset' | 'payTo'>;
|
|
3395
3457
|
/** Why a native transfer was refused. Internal; callers branch on the registry `code`. */
|
|
3396
|
-
type NativeTransferErrorCode = 'UNSUPPORTED_ACCEPT' | 'INSUFFICIENT_BALANCE' | 'TOO_MANY_COINS' | 'BUILD_FAILED' | 'NOT_NATIVE';
|
|
3458
|
+
type NativeTransferErrorCode = 'UNSUPPORTED_ACCEPT' | 'INTENT_INVALID' | 'INTENT_MISMATCH' | 'INTENT_LIMIT_EXCEEDED' | 'INSUFFICIENT_BALANCE' | 'TOO_MANY_COINS' | 'BUILD_FAILED' | 'NOT_NATIVE';
|
|
3397
3459
|
/**
|
|
3398
3460
|
* A native transfer that was not built. Nothing was signed, so the money state
|
|
3399
3461
|
* is always `not_charged`. `reason` names the internal refusal for logs.
|
|
@@ -3416,8 +3478,20 @@ interface BuildNativeTransferInput {
|
|
|
3416
3478
|
client: ClientWithCoreApi;
|
|
3417
3479
|
sender: string;
|
|
3418
3480
|
accept: NativeTransferAccept;
|
|
3481
|
+
/**
|
|
3482
|
+
* What the buyer decided to pay before reading the server's accept. The
|
|
3483
|
+
* accept must sit inside it and `client.network` must match it, or nothing
|
|
3484
|
+
* is built.
|
|
3485
|
+
*/
|
|
3486
|
+
intent: BuyerPaymentIntent;
|
|
3419
3487
|
/** Pin gas instead of letting the client resolve it. */
|
|
3420
3488
|
gas?: NativeTransferGas;
|
|
3489
|
+
/**
|
|
3490
|
+
* Ceiling on the built transaction's gas budget. Defaults to
|
|
3491
|
+
* {@link DEFAULT_NATIVE_MAX_GAS_BUDGET}; when `gas` is pinned, that budget is
|
|
3492
|
+
* the ceiling unless this is set lower.
|
|
3493
|
+
*/
|
|
3494
|
+
maxGasBudget?: bigint;
|
|
3421
3495
|
}
|
|
3422
3496
|
interface NativeTransferBuild {
|
|
3423
3497
|
/** Base64 BCS TransactionData, ready for a wallet to sign as-is. */
|
|
@@ -3436,6 +3510,7 @@ declare function inspectNativeTransfer(bytes: Uint8Array, expected: {
|
|
|
3436
3510
|
sender: string;
|
|
3437
3511
|
payTo: string;
|
|
3438
3512
|
amount: bigint;
|
|
3513
|
+
maxGasBudget?: bigint;
|
|
3439
3514
|
}): string | null;
|
|
3440
3515
|
/** Build and self-check the native transfer. Throws {@link NativeTransferError}; never returns bytes that fail. */
|
|
3441
3516
|
declare function buildNativeTransferBytes(input: BuildNativeTransferInput): Promise<NativeTransferBuild>;
|
|
@@ -3444,9 +3519,13 @@ interface NativeTransferSignerInput {
|
|
|
3444
3519
|
sender: string;
|
|
3445
3520
|
/** Sign the exact transaction bytes; return the serialized signature. */
|
|
3446
3521
|
sign: (bytes: Uint8Array) => Promise<string>;
|
|
3522
|
+
/** The buyer's bounds; checked against every accept and against `client.network`. */
|
|
3523
|
+
intent: BuyerPaymentIntent;
|
|
3447
3524
|
gas?: NativeTransferGas;
|
|
3525
|
+
/** Ceiling on auto-estimated or pinned gas; see {@link BuildNativeTransferInput.maxGasBudget}. */
|
|
3526
|
+
maxGasBudget?: bigint;
|
|
3448
3527
|
}
|
|
3449
3528
|
/** An {@link McpPaymentSigner} backed by {@link buildNativeTransferBytes}. */
|
|
3450
3529
|
declare function createNativeTransferSigner(input: NativeTransferSignerInput): McpPaymentSigner;
|
|
3451
3530
|
|
|
3452
|
-
export { type BuildNativeTransferInput as B, type CodeFor as C, type DelegationScope as D, type ErrorCode as E, type McpPaymentSigner as M, type NextAction as N, type Offer as O, type PaymentState as P, type Receipt as R, SuiPayError as S, type
|
|
3531
|
+
export { type BuildNativeTransferInput as B, type CodeFor as C, type DelegationScope as D, type ErrorCode as E, type McpPaymentSigner as M, type NextAction as N, type Offer as O, type PaymentState as P, type Receipt as R, SuiPayError as S, type BuyerPaymentIntent as a, type NativeTransferAccept as b, type NativeTransferBuild as c, NativeTransferError as d, type NativeTransferGas as e, type NativeTransferSignerInput as f, type SuiPayErrorFields as g, buildMcpPaymentPayload as h, buildNativeTransferBytes as i, createNativeTransferSigner as j, inspectNativeTransfer as k, DEFAULT_NATIVE_MAX_GAS_BUDGET as l, type NativeTransferErrorCode as m, toErrorFields as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '@mysten/sui/client';
|
|
2
|
-
export { B as BuildNativeTransferInput, a as
|
|
2
|
+
export { B as BuildNativeTransferInput, a as BuyerPaymentIntent, l as DEFAULT_NATIVE_MAX_GAS_BUDGET, b as NativeTransferAccept, c as NativeTransferBuild, d as NativeTransferError, m as NativeTransferErrorCode, e as NativeTransferGas, f as NativeTransferSignerInput, i as buildNativeTransferBytes, j as createNativeTransferSigner, k as inspectNativeTransfer } from './native-transfer-D0UoteMk.js';
|
package/dist/native-transfer.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_NATIVE_MAX_GAS_BUDGET,
|
|
2
3
|
NativeTransferError,
|
|
3
4
|
buildNativeTransferBytes,
|
|
4
5
|
createNativeTransferSigner,
|
|
5
6
|
inspectNativeTransfer
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FWLPQH4N.js";
|
|
7
8
|
export {
|
|
9
|
+
DEFAULT_NATIVE_MAX_GAS_BUDGET,
|
|
8
10
|
NativeTransferError,
|
|
9
11
|
buildNativeTransferBytes,
|
|
10
12
|
createNativeTransferSigner,
|
package/package.json
CHANGED