@relai-fi/x402 0.6.2 → 0.6.4

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
@@ -4,3 +4,88 @@ export { RelayFeedbackConfig, submitRelayFeedback } from './relay-feedback.cjs';
4
4
  export { A as AcceptsExtra, B as BASE_MAINNET_NETWORK, C as CAIP2_TO_NETWORK, b as CHAIN_IDS, E as EXPLORER_TX_URL, l as EvmWallet, N as NETWORK_CAIP2, e as NETWORK_LABELS, d as NETWORK_TOKENS, c as NetworkToken, P as PaymentAccept, o as PaymentRequired, R as RELAI_FACILITATOR_URL, h as RELAI_NETWORKS, a as RelaiNetwork, m as ResourceInfo, S as SOLANA_MAINNET_NETWORK, k as SolanaWallet, U as USDC_ADDRESSES, g as USDC_BASE, f as USDC_SOLANA, W as WalletSet, j as isEvm, i as isSolana, n as normalizeNetwork, r as resolveToken } from './types-Y9ni5XwY.cjs';
5
5
  export { BridgeBalances, BridgeQuoteResult, BridgeResult } from './management.cjs';
6
6
  export { NETWORK_V1_TO_V2, NETWORK_V2_TO_V1, convertPayloadToVersion, convertV1ToV2, convertV2ToV1, detectPayloadVersion, formatUsd, fromAtomicUnits, isEvmNetwork, isSolanaNetwork, networkV1ToV2, networkV2ToV1, normalizePaymentHeader, toAtomicUnits } from './utils/index.cjs';
7
+ export { charge as evmChargeMethod } from './mpp/evm-method.cjs';
8
+ export { EvmChargeConfig, evmCharge as evmChargeServer } from './mpp/evm-server.cjs';
9
+ export { EvmChargeClientConfig, evmCharge as evmChargeClient } from './mpp/evm-client.cjs';
10
+ import 'mppx';
11
+ import 'zod/v4/core';
12
+ import 'zod/mini';
13
+ import 'viem';
14
+
15
+ /**
16
+ * Payment Code API — BLIK-style x402 payment codes
17
+ *
18
+ * generatePaymentCode() — sign EIP-3009 authorization and register on SKALE L3
19
+ * redeemPaymentCode() — redeem a code (payee calls this, triggers Base L2 settlement)
20
+ * getPaymentCode() — check code status
21
+ */
22
+ interface PaymentCodeConfig {
23
+ facilitatorUrl?: string;
24
+ }
25
+ interface GeneratePaymentCodeParams {
26
+ /** EIP-3009 signer — must implement signTypedData */
27
+ signer: {
28
+ getAddress(): Promise<string>;
29
+ signTypedData(domain: object, types: object, value: object): Promise<string>;
30
+ };
31
+ /** Payee wallet address */
32
+ to: string;
33
+ /** Amount in USDC micro-units (6 decimals), e.g. 1000 = $0.001 */
34
+ value: string | bigint;
35
+ /** USDC contract address on Base L2 (defaults to Base mainnet USDC) */
36
+ usdcContract?: string;
37
+ /** TTL in seconds (default: 120) */
38
+ ttl?: number;
39
+ }
40
+ interface PaymentCode {
41
+ code: string;
42
+ validBefore: number;
43
+ expiresIn: number;
44
+ }
45
+ interface RedeemResult {
46
+ success: boolean;
47
+ code: string;
48
+ l3TxHash: string;
49
+ l2TxHash: string;
50
+ explorerUrl: string;
51
+ amount: string;
52
+ from: string;
53
+ to: string;
54
+ }
55
+ interface CodeStatus {
56
+ code: string;
57
+ from: string;
58
+ to: string;
59
+ value: string;
60
+ validBefore: number;
61
+ redeemed: boolean;
62
+ expired: boolean;
63
+ redeemable: boolean;
64
+ }
65
+ /**
66
+ * Generate a BLIK-style x402 payment code backed by EIP-3009.
67
+ *
68
+ * @example
69
+ * const { code } = await generatePaymentCode(config, {
70
+ * signer: walletClient,
71
+ * to: "0xMerchant...",
72
+ * value: "1000", // $0.001 USDC
73
+ * ttl: 120,
74
+ * });
75
+ * // code = "X7K9P2AB"
76
+ */
77
+ declare function generatePaymentCode(config: PaymentCodeConfig, params: GeneratePaymentCodeParams): Promise<PaymentCode>;
78
+ /**
79
+ * Redeem a payment code. Triggers Base L2 settlement via relayer.
80
+ *
81
+ * @example
82
+ * const result = await redeemPaymentCode(config, "X7K9P2AB");
83
+ * // result.l2TxHash = "0x..."
84
+ */
85
+ declare function redeemPaymentCode(config: PaymentCodeConfig, code: string): Promise<RedeemResult>;
86
+ /**
87
+ * Get the status of a payment code.
88
+ */
89
+ declare function getPaymentCode(config: PaymentCodeConfig, code: string): Promise<CodeStatus>;
90
+
91
+ export { type CodeStatus, type GeneratePaymentCodeParams, type PaymentCode, type PaymentCodeConfig, type RedeemResult, generatePaymentCode, getPaymentCode, redeemPaymentCode };
package/dist/index.d.ts CHANGED
@@ -4,3 +4,88 @@ export { RelayFeedbackConfig, submitRelayFeedback } from './relay-feedback.js';
4
4
  export { A as AcceptsExtra, B as BASE_MAINNET_NETWORK, C as CAIP2_TO_NETWORK, b as CHAIN_IDS, E as EXPLORER_TX_URL, l as EvmWallet, N as NETWORK_CAIP2, e as NETWORK_LABELS, d as NETWORK_TOKENS, c as NetworkToken, P as PaymentAccept, o as PaymentRequired, R as RELAI_FACILITATOR_URL, h as RELAI_NETWORKS, a as RelaiNetwork, m as ResourceInfo, S as SOLANA_MAINNET_NETWORK, k as SolanaWallet, U as USDC_ADDRESSES, g as USDC_BASE, f as USDC_SOLANA, W as WalletSet, j as isEvm, i as isSolana, n as normalizeNetwork, r as resolveToken } from './types-Y9ni5XwY.js';
5
5
  export { BridgeBalances, BridgeQuoteResult, BridgeResult } from './management.js';
6
6
  export { NETWORK_V1_TO_V2, NETWORK_V2_TO_V1, convertPayloadToVersion, convertV1ToV2, convertV2ToV1, detectPayloadVersion, formatUsd, fromAtomicUnits, isEvmNetwork, isSolanaNetwork, networkV1ToV2, networkV2ToV1, normalizePaymentHeader, toAtomicUnits } from './utils/index.js';
7
+ export { charge as evmChargeMethod } from './mpp/evm-method.js';
8
+ export { EvmChargeConfig, evmCharge as evmChargeServer } from './mpp/evm-server.js';
9
+ export { EvmChargeClientConfig, evmCharge as evmChargeClient } from './mpp/evm-client.js';
10
+ import 'mppx';
11
+ import 'zod/v4/core';
12
+ import 'zod/mini';
13
+ import 'viem';
14
+
15
+ /**
16
+ * Payment Code API — BLIK-style x402 payment codes
17
+ *
18
+ * generatePaymentCode() — sign EIP-3009 authorization and register on SKALE L3
19
+ * redeemPaymentCode() — redeem a code (payee calls this, triggers Base L2 settlement)
20
+ * getPaymentCode() — check code status
21
+ */
22
+ interface PaymentCodeConfig {
23
+ facilitatorUrl?: string;
24
+ }
25
+ interface GeneratePaymentCodeParams {
26
+ /** EIP-3009 signer — must implement signTypedData */
27
+ signer: {
28
+ getAddress(): Promise<string>;
29
+ signTypedData(domain: object, types: object, value: object): Promise<string>;
30
+ };
31
+ /** Payee wallet address */
32
+ to: string;
33
+ /** Amount in USDC micro-units (6 decimals), e.g. 1000 = $0.001 */
34
+ value: string | bigint;
35
+ /** USDC contract address on Base L2 (defaults to Base mainnet USDC) */
36
+ usdcContract?: string;
37
+ /** TTL in seconds (default: 120) */
38
+ ttl?: number;
39
+ }
40
+ interface PaymentCode {
41
+ code: string;
42
+ validBefore: number;
43
+ expiresIn: number;
44
+ }
45
+ interface RedeemResult {
46
+ success: boolean;
47
+ code: string;
48
+ l3TxHash: string;
49
+ l2TxHash: string;
50
+ explorerUrl: string;
51
+ amount: string;
52
+ from: string;
53
+ to: string;
54
+ }
55
+ interface CodeStatus {
56
+ code: string;
57
+ from: string;
58
+ to: string;
59
+ value: string;
60
+ validBefore: number;
61
+ redeemed: boolean;
62
+ expired: boolean;
63
+ redeemable: boolean;
64
+ }
65
+ /**
66
+ * Generate a BLIK-style x402 payment code backed by EIP-3009.
67
+ *
68
+ * @example
69
+ * const { code } = await generatePaymentCode(config, {
70
+ * signer: walletClient,
71
+ * to: "0xMerchant...",
72
+ * value: "1000", // $0.001 USDC
73
+ * ttl: 120,
74
+ * });
75
+ * // code = "X7K9P2AB"
76
+ */
77
+ declare function generatePaymentCode(config: PaymentCodeConfig, params: GeneratePaymentCodeParams): Promise<PaymentCode>;
78
+ /**
79
+ * Redeem a payment code. Triggers Base L2 settlement via relayer.
80
+ *
81
+ * @example
82
+ * const result = await redeemPaymentCode(config, "X7K9P2AB");
83
+ * // result.l2TxHash = "0x..."
84
+ */
85
+ declare function redeemPaymentCode(config: PaymentCodeConfig, code: string): Promise<RedeemResult>;
86
+ /**
87
+ * Get the status of a payment code.
88
+ */
89
+ declare function getPaymentCode(config: PaymentCodeConfig, code: string): Promise<CodeStatus>;
90
+
91
+ export { type CodeStatus, type GeneratePaymentCodeParams, type PaymentCode, type PaymentCodeConfig, type RedeemResult, generatePaymentCode, getPaymentCode, redeemPaymentCode };