@payai/x402-evm 2.4.1 → 2.4.3
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/cjs/batch-settlement/client/file-storage.d.ts +47 -0
- package/dist/cjs/batch-settlement/client/file-storage.js +116 -0
- package/dist/cjs/batch-settlement/client/file-storage.js.map +1 -0
- package/dist/cjs/batch-settlement/client/index.d.ts +111 -0
- package/dist/cjs/batch-settlement/client/index.js +1565 -0
- package/dist/cjs/batch-settlement/client/index.js.map +1 -0
- package/dist/cjs/batch-settlement/facilitator/index.d.ts +71 -0
- package/dist/cjs/batch-settlement/facilitator/index.js +2032 -0
- package/dist/cjs/batch-settlement/facilitator/index.js.map +1 -0
- package/dist/cjs/batch-settlement/server/file-storage.d.ts +53 -0
- package/dist/cjs/batch-settlement/server/file-storage.js +181 -0
- package/dist/cjs/batch-settlement/server/file-storage.js.map +1 -0
- package/dist/cjs/batch-settlement/server/index.d.ts +491 -0
- package/dist/cjs/batch-settlement/server/index.js +1960 -0
- package/dist/cjs/batch-settlement/server/index.js.map +1 -0
- package/dist/cjs/batch-settlement/server/redis-storage.d.ts +87 -0
- package/dist/cjs/batch-settlement/server/redis-storage.js +181 -0
- package/dist/cjs/batch-settlement/server/redis-storage.js.map +1 -0
- package/dist/cjs/exact/client/index.d.ts +6 -4
- package/dist/cjs/exact/client/index.js +7 -5
- package/dist/cjs/exact/client/index.js.map +1 -1
- package/dist/cjs/exact/facilitator/index.d.ts +16 -9
- package/dist/cjs/exact/facilitator/index.js +35 -7
- package/dist/cjs/exact/facilitator/index.js.map +1 -1
- package/dist/cjs/exact/server/index.js +40 -1
- package/dist/cjs/exact/server/index.js.map +1 -1
- package/dist/cjs/exact/v1/client/index.d.ts +2 -1
- package/dist/cjs/exact/v1/client/index.js.map +1 -1
- package/dist/cjs/exact/v1/facilitator/index.d.ts +11 -5
- package/dist/cjs/exact/v1/facilitator/index.js +16 -2
- package/dist/cjs/exact/v1/facilitator/index.js.map +1 -1
- package/dist/cjs/index.d.ts +113 -7
- package/dist/cjs/index.js +1353 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/{esm/permit2-CyZxwngN.d.mts → cjs/permit2-DhJRUcgY.d.ts} +1 -13
- package/dist/cjs/rpc-DULZzRne.d.ts +13 -0
- package/dist/cjs/scheme-CvkPJXBD.d.ts +307 -0
- package/dist/{esm/scheme-DCR7hsa3.d.mts → cjs/scheme-DTQFE9xp.d.ts} +2 -2
- package/dist/{esm/signer-D912R4mq.d.mts → cjs/signer-tYS6Y46X.d.ts} +3 -0
- package/dist/cjs/storage-6W5MO46W.d.ts +50 -0
- package/dist/cjs/storage-Bl6aD0Xg.d.ts +81 -0
- package/dist/cjs/types-CF8P2-NM.d.ts +180 -0
- package/dist/cjs/upto/client/index.d.ts +5 -3
- package/dist/cjs/upto/client/index.js +7 -5
- package/dist/cjs/upto/client/index.js.map +1 -1
- package/dist/cjs/upto/facilitator/index.d.ts +2 -1
- package/dist/cjs/upto/facilitator/index.js +2 -1
- package/dist/cjs/upto/facilitator/index.js.map +1 -1
- package/dist/cjs/upto/server/index.js +40 -1
- package/dist/cjs/upto/server/index.js.map +1 -1
- package/dist/cjs/v1/index.d.ts +2 -1
- package/dist/cjs/v1/index.js.map +1 -1
- package/dist/esm/batch-settlement/client/file-storage.d.mts +47 -0
- package/dist/esm/batch-settlement/client/file-storage.mjs +63 -0
- package/dist/esm/batch-settlement/client/file-storage.mjs.map +1 -0
- package/dist/esm/batch-settlement/client/index.d.mts +111 -0
- package/dist/esm/batch-settlement/client/index.mjs +59 -0
- package/dist/esm/batch-settlement/client/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/facilitator/index.d.mts +71 -0
- package/dist/esm/batch-settlement/facilitator/index.mjs +1235 -0
- package/dist/esm/batch-settlement/facilitator/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/server/file-storage.d.mts +53 -0
- package/dist/esm/batch-settlement/server/file-storage.mjs +128 -0
- package/dist/esm/batch-settlement/server/file-storage.mjs.map +1 -0
- package/dist/esm/batch-settlement/server/index.d.mts +491 -0
- package/dist/esm/batch-settlement/server/index.mjs +1645 -0
- package/dist/esm/batch-settlement/server/index.mjs.map +1 -0
- package/dist/esm/batch-settlement/server/redis-storage.d.mts +87 -0
- package/dist/esm/batch-settlement/server/redis-storage.mjs +156 -0
- package/dist/esm/batch-settlement/server/redis-storage.mjs.map +1 -0
- package/dist/esm/chunk-2EUQTNJO.mjs +38 -0
- package/dist/esm/chunk-2EUQTNJO.mjs.map +1 -0
- package/dist/esm/chunk-53USC5VE.mjs +47 -0
- package/dist/esm/chunk-53USC5VE.mjs.map +1 -0
- package/dist/esm/{chunk-GJ57SZGI.mjs → chunk-6WQOGWBE.mjs} +7 -5
- package/dist/esm/{chunk-GJ57SZGI.mjs.map → chunk-6WQOGWBE.mjs.map} +1 -1
- package/dist/esm/{chunk-F3OOHBAW.mjs → chunk-BTYNCDNS.mjs} +42 -2
- package/dist/esm/{chunk-F3OOHBAW.mjs.map → chunk-BTYNCDNS.mjs.map} +1 -1
- package/dist/esm/{chunk-ERK2ZPOY.mjs → chunk-CSQS7ZON.mjs} +27 -7
- package/dist/esm/chunk-CSQS7ZON.mjs.map +1 -0
- package/dist/esm/chunk-GD4MKCN7.mjs +57 -0
- package/dist/esm/chunk-GD4MKCN7.mjs.map +1 -0
- package/dist/esm/chunk-HYABYUBD.mjs +432 -0
- package/dist/esm/chunk-HYABYUBD.mjs.map +1 -0
- package/dist/esm/chunk-IN5YIT5C.mjs +159 -0
- package/dist/esm/chunk-IN5YIT5C.mjs.map +1 -0
- package/dist/esm/{chunk-JII456TS.mjs → chunk-JK7SLLF7.mjs} +1 -1
- package/dist/esm/chunk-JK7SLLF7.mjs.map +1 -0
- package/dist/esm/{chunk-C4ZQMS77.mjs → chunk-MACPBXCT.mjs} +2 -216
- package/dist/esm/chunk-MACPBXCT.mjs.map +1 -0
- package/dist/esm/chunk-NKYVYGRA.mjs +911 -0
- package/dist/esm/chunk-NKYVYGRA.mjs.map +1 -0
- package/dist/esm/{chunk-FQJR4RCF.mjs → chunk-R7I3RZFF.mjs} +10 -6
- package/dist/esm/{chunk-FQJR4RCF.mjs.map → chunk-R7I3RZFF.mjs.map} +1 -1
- package/dist/esm/{chunk-CRT6YNY5.mjs → chunk-RWLVVO3B.mjs} +21 -61
- package/dist/esm/chunk-RWLVVO3B.mjs.map +1 -0
- package/dist/esm/chunk-TGFAVNUD.mjs +111 -0
- package/dist/esm/chunk-TGFAVNUD.mjs.map +1 -0
- package/dist/esm/chunk-TW7Z65AO.mjs +34 -0
- package/dist/esm/chunk-TW7Z65AO.mjs.map +1 -0
- package/dist/esm/chunk-U4HCGTLU.mjs +35 -0
- package/dist/esm/chunk-U4HCGTLU.mjs.map +1 -0
- package/dist/esm/chunk-VS3RYAYE.mjs +80 -0
- package/dist/esm/chunk-VS3RYAYE.mjs.map +1 -0
- package/dist/esm/chunk-W6ON4LG2.mjs +39 -0
- package/dist/esm/chunk-W6ON4LG2.mjs.map +1 -0
- package/dist/esm/{chunk-WKBC5YMI.mjs → chunk-YMQCTKDU.mjs} +23 -55
- package/dist/esm/chunk-YMQCTKDU.mjs.map +1 -0
- package/dist/esm/exact/client/index.d.mts +6 -4
- package/dist/esm/exact/client/index.mjs +10 -5
- package/dist/esm/exact/facilitator/index.d.mts +16 -9
- package/dist/esm/exact/facilitator/index.mjs +36 -14
- package/dist/esm/exact/facilitator/index.mjs.map +1 -1
- package/dist/esm/exact/server/index.mjs +1 -1
- package/dist/esm/exact/v1/client/index.d.mts +2 -1
- package/dist/esm/exact/v1/client/index.mjs +5 -2
- package/dist/esm/exact/v1/facilitator/index.d.mts +11 -5
- package/dist/esm/exact/v1/facilitator/index.mjs +5 -2
- package/dist/esm/index.d.mts +113 -7
- package/dist/esm/index.mjs +53 -7
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/permit2-DhJRUcgY.d.mts +729 -0
- package/dist/esm/rpc-DULZzRne.d.mts +13 -0
- package/dist/esm/scheme-DtbSS4Fk.d.mts +307 -0
- package/dist/esm/scheme-gtqAIYPJ.d.mts +47 -0
- package/dist/esm/signer-tYS6Y46X.d.mts +170 -0
- package/dist/esm/storage-6W5MO46W.d.mts +50 -0
- package/dist/esm/storage-sZ1CDS4P.d.mts +81 -0
- package/dist/esm/types-CF8P2-NM.d.mts +180 -0
- package/dist/esm/upto/client/index.d.mts +5 -3
- package/dist/esm/upto/client/index.mjs +9 -4
- package/dist/esm/upto/facilitator/index.d.mts +2 -1
- package/dist/esm/upto/facilitator/index.mjs +17 -9
- package/dist/esm/upto/facilitator/index.mjs.map +1 -1
- package/dist/esm/upto/server/index.mjs +1 -1
- package/dist/esm/v1/index.d.mts +2 -1
- package/dist/esm/v1/index.mjs +5 -2
- package/package.json +5 -5
- package/dist/esm/chunk-C4ZQMS77.mjs.map +0 -1
- package/dist/esm/chunk-CRT6YNY5.mjs.map +0 -1
- package/dist/esm/chunk-ERK2ZPOY.mjs.map +0 -1
- package/dist/esm/chunk-JII456TS.mjs.map +0 -1
- package/dist/esm/chunk-WKBC5YMI.mjs.map +0 -1
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
type EvmSchemeConfig = {
|
|
2
|
-
rpcUrl?: string;
|
|
3
|
-
};
|
|
4
|
-
type EvmSchemeConfigByChainId = Record<number, EvmSchemeConfig>;
|
|
5
|
-
type EvmSchemeOptions = EvmSchemeConfig | EvmSchemeConfigByChainId;
|
|
6
|
-
/** @deprecated Use EvmSchemeConfig */
|
|
7
|
-
type ExactEvmSchemeConfig = EvmSchemeConfig;
|
|
8
|
-
/** @deprecated Use EvmSchemeConfigByChainId */
|
|
9
|
-
type ExactEvmSchemeConfigByChainId = EvmSchemeConfigByChainId;
|
|
10
|
-
/** @deprecated Use EvmSchemeOptions */
|
|
11
|
-
type ExactEvmSchemeOptions = EvmSchemeOptions;
|
|
12
|
-
|
|
13
1
|
declare const authorizationTypes: {
|
|
14
2
|
readonly TransferWithAuthorization: readonly [{
|
|
15
3
|
readonly name: "from";
|
|
@@ -738,4 +726,4 @@ declare function getPermit2AllowanceReadParams(params: Permit2AllowanceParams):
|
|
|
738
726
|
args: [`0x${string}`, `0x${string}`];
|
|
739
727
|
};
|
|
740
728
|
|
|
741
|
-
export { type
|
|
729
|
+
export { type Permit2AllowanceParams as P, PERMIT2_ADDRESS as a, x402UptoPermit2ProxyAddress as b, createPermit2ApprovalTx as c, authorizationTypes as d, erc20AllowanceAbi as e, eip3009ABI as f, getPermit2AllowanceReadParams as g, x402ExactPermit2ProxyABI as h, x402UptoPermit2ProxyABI as i, permit2WitnessTypes as p, uptoPermit2WitnessTypes as u, x402ExactPermit2ProxyAddress as x };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type EvmSchemeConfig = {
|
|
2
|
+
rpcUrl?: string;
|
|
3
|
+
};
|
|
4
|
+
type EvmSchemeConfigByChainId = Record<number, EvmSchemeConfig>;
|
|
5
|
+
type EvmSchemeOptions = EvmSchemeConfig | EvmSchemeConfigByChainId;
|
|
6
|
+
/** @deprecated Use EvmSchemeConfig */
|
|
7
|
+
type ExactEvmSchemeConfig = EvmSchemeConfig;
|
|
8
|
+
/** @deprecated Use EvmSchemeConfigByChainId */
|
|
9
|
+
type ExactEvmSchemeConfigByChainId = EvmSchemeConfigByChainId;
|
|
10
|
+
/** @deprecated Use EvmSchemeOptions */
|
|
11
|
+
type ExactEvmSchemeOptions = EvmSchemeOptions;
|
|
12
|
+
|
|
13
|
+
export type { ExactEvmSchemeOptions as E, ExactEvmSchemeConfig as a, ExactEvmSchemeConfigByChainId as b, EvmSchemeOptions as c, EvmSchemeConfig as d, EvmSchemeConfigByChainId as e };
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { PaymentRequirements, SettleResponse, SchemeNetworkClient, SchemeClientHooks, PaymentPayloadContext, PaymentPayloadResult, PaymentRequired } from '@payai/x402/types';
|
|
2
|
+
import { C as ClientEvmSigner } from './signer-tYS6Y46X.js';
|
|
3
|
+
import { C as ChannelConfig } from './types-CF8P2-NM.js';
|
|
4
|
+
import { c as EvmSchemeOptions } from './rpc-DULZzRne.js';
|
|
5
|
+
import { B as BatchSettlementClientContext, C as ClientChannelStorage } from './storage-6W5MO46W.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Caller-tunable policy controlling how the client sizes channel deposits.
|
|
9
|
+
*/
|
|
10
|
+
interface BatchSettlementDepositPolicy {
|
|
11
|
+
depositMultiplier?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Return shape for custom deposit sizing.
|
|
15
|
+
*/
|
|
16
|
+
type BatchSettlementDepositStrategyResult = string | bigint | false | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Information supplied before the client signs a deposit authorization.
|
|
19
|
+
*/
|
|
20
|
+
interface BatchSettlementDepositStrategyContext {
|
|
21
|
+
paymentRequirements: PaymentRequirements;
|
|
22
|
+
channelConfig: ChannelConfig;
|
|
23
|
+
channelId: `0x${string}`;
|
|
24
|
+
clientContext: BatchSettlementClientContext;
|
|
25
|
+
requestAmount: string;
|
|
26
|
+
maxClaimableAmount: string;
|
|
27
|
+
currentBalance: string;
|
|
28
|
+
minimumDepositAmount: string;
|
|
29
|
+
depositAmount: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Custom deposit sizing callback for initial deposits and top-ups.
|
|
33
|
+
*/
|
|
34
|
+
type BatchSettlementDepositStrategy = (context: BatchSettlementDepositStrategyContext) => BatchSettlementDepositStrategyResult | Promise<BatchSettlementDepositStrategyResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Full options object accepted by `BatchSettlementEvmScheme`. Either this or a
|
|
37
|
+
* bare {@link BatchSettlementDepositPolicy} can be passed as the second
|
|
38
|
+
* constructor argument.
|
|
39
|
+
*/
|
|
40
|
+
interface BatchSettlementEvmSchemeOptions {
|
|
41
|
+
depositPolicy?: BatchSettlementDepositPolicy;
|
|
42
|
+
/** Optional callback for app-specific deposit sizing or skipping. */
|
|
43
|
+
depositStrategy?: BatchSettlementDepositStrategy;
|
|
44
|
+
storage?: ClientChannelStorage;
|
|
45
|
+
salt?: `0x${string}`;
|
|
46
|
+
payerAuthorizer?: `0x${string}`;
|
|
47
|
+
rpcUrl?: string;
|
|
48
|
+
/** When set, EIP-712 vouchers are signed with this key; deposits still use the main `signer`. */
|
|
49
|
+
voucherSigner?: ClientEvmSigner;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Resolved options after merging defaults — used internally by the scheme,
|
|
53
|
+
* recovery, and refund modules.
|
|
54
|
+
*/
|
|
55
|
+
interface ResolvedClientOptions {
|
|
56
|
+
depositPolicy?: BatchSettlementDepositPolicy;
|
|
57
|
+
depositStrategy?: BatchSettlementDepositStrategy;
|
|
58
|
+
storage: ClientChannelStorage;
|
|
59
|
+
salt: `0x${string}`;
|
|
60
|
+
payerAuthorizer?: `0x${string}`;
|
|
61
|
+
voucherSigner?: ClientEvmSigner;
|
|
62
|
+
extensionRpcOptions?: EvmSchemeOptions;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Discriminates a full options object from a bare deposit-policy object.
|
|
66
|
+
*
|
|
67
|
+
* @param o - Constructor argument that may be options, deposit policy only, or undefined.
|
|
68
|
+
* @returns `true` when `o` is a {@link BatchSettlementEvmSchemeOptions} object.
|
|
69
|
+
*/
|
|
70
|
+
declare function isBatchSettlementEvmSchemeOptions(o: BatchSettlementEvmSchemeOptions | BatchSettlementDepositPolicy | undefined): o is BatchSettlementEvmSchemeOptions;
|
|
71
|
+
/**
|
|
72
|
+
* Normalises the constructor's second argument into a uniform options shape.
|
|
73
|
+
*
|
|
74
|
+
* @param second - Optional second constructor argument (options or deposit policy).
|
|
75
|
+
* @returns Resolved storage, salt, deposit policy, and optional payer authorizer.
|
|
76
|
+
*/
|
|
77
|
+
declare function resolveClientOptions(second?: BatchSettlementEvmSchemeOptions | BatchSettlementDepositPolicy): ResolvedClientOptions;
|
|
78
|
+
/**
|
|
79
|
+
* Validates a {@link BatchSettlementDepositPolicy}, throwing on invalid fields.
|
|
80
|
+
*
|
|
81
|
+
* @param policy - The policy to validate (no-op when undefined).
|
|
82
|
+
*/
|
|
83
|
+
declare function validateDepositPolicy(policy: BatchSettlementDepositPolicy | undefined): void;
|
|
84
|
+
/**
|
|
85
|
+
* Computes the deposit amount based on the deposit multiplier.
|
|
86
|
+
*
|
|
87
|
+
* @param policy - Deposit policy controlling multiplier (may be undefined).
|
|
88
|
+
* @param requestAmount - Amount requested for this operation, in token base units.
|
|
89
|
+
* @returns Deposit amount string in token base units.
|
|
90
|
+
*/
|
|
91
|
+
declare function depositAmountForRequest(policy: BatchSettlementDepositPolicy | undefined, requestAmount: bigint): string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Runtime dependency bag shared by every storage-bound client helper (channel,
|
|
95
|
+
* recovery, refund) and the {@link BatchSettlementEvmScheme} class.
|
|
96
|
+
*/
|
|
97
|
+
interface BatchSettlementClientDeps {
|
|
98
|
+
signer: ClientEvmSigner;
|
|
99
|
+
storage: ClientChannelStorage;
|
|
100
|
+
salt: `0x${string}`;
|
|
101
|
+
payerAuthorizer?: `0x${string}`;
|
|
102
|
+
voucherSigner?: ClientEvmSigner;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Constructs the immutable {@link ChannelConfig} from payment requirements and
|
|
106
|
+
* a client deps bag (signer, salt, optional payerAuthorizer / voucherSigner).
|
|
107
|
+
*
|
|
108
|
+
* @param deps - Client identity inputs.
|
|
109
|
+
* @param paymentRequirements - Server payment requirements providing receiver, asset, and extra fields.
|
|
110
|
+
* @returns The ChannelConfig that uniquely identifies this payment channel.
|
|
111
|
+
*/
|
|
112
|
+
declare function buildChannelConfig(deps: BatchSettlementClientDeps, paymentRequirements: PaymentRequirements): ChannelConfig;
|
|
113
|
+
/**
|
|
114
|
+
* Updates local channel state from a parsed `SettleResponse`.
|
|
115
|
+
*
|
|
116
|
+
* @param storage - Client channel storage.
|
|
117
|
+
* @param settle - The parsed settle response.
|
|
118
|
+
*/
|
|
119
|
+
declare function processSettleResponse(storage: ClientChannelStorage, settle: SettleResponse): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Reconciles local channel state with the outcome of a cooperative refund.
|
|
122
|
+
*
|
|
123
|
+
* Deletes the channel record when the post-refund balance is zero (full refund),
|
|
124
|
+
* otherwise updates local state from the server snapshot.
|
|
125
|
+
*
|
|
126
|
+
* @param storage - Client channel storage.
|
|
127
|
+
* @param channelKey - Lowercased channel id used as the storage key.
|
|
128
|
+
* @param settleExtra - The `extra` block from the refund settle response.
|
|
129
|
+
*/
|
|
130
|
+
declare function updateChannelAfterRefund(storage: ClientChannelStorage, channelKey: string, settleExtra: Record<string, unknown>): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Processes the `PAYMENT-RESPONSE` header after a successful request.
|
|
133
|
+
*
|
|
134
|
+
* Decodes the header into a `SettleResponse` and delegates to
|
|
135
|
+
* {@link processSettleResponse}.
|
|
136
|
+
*
|
|
137
|
+
* @param storage - Client channel storage.
|
|
138
|
+
* @param getHeader - Function to retrieve a response header by name.
|
|
139
|
+
*/
|
|
140
|
+
declare function processPaymentResponse(storage: ClientChannelStorage, getHeader: (name: string) => string | null | undefined): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Recovers a channel record from onchain state (useful after a cold start or
|
|
143
|
+
* channel record loss).
|
|
144
|
+
*
|
|
145
|
+
* @param deps - Signer + storage + identity inputs.
|
|
146
|
+
* @param paymentRequirements - Server payment requirements used to derive the ChannelConfig.
|
|
147
|
+
* @returns The recovered client context.
|
|
148
|
+
*/
|
|
149
|
+
declare function recoverChannel(deps: BatchSettlementClientDeps, paymentRequirements: PaymentRequirements): Promise<BatchSettlementClientContext>;
|
|
150
|
+
/**
|
|
151
|
+
* Reads `channels(channelId)` returning `[balance, totalClaimed]`.
|
|
152
|
+
*
|
|
153
|
+
* @param signer - Signer providing `readContract`.
|
|
154
|
+
* @param channelId - The `bytes32` channel id to query.
|
|
155
|
+
* @returns Tuple of `[balance, totalClaimed]` as bigints.
|
|
156
|
+
*/
|
|
157
|
+
declare function readChannelBalanceAndTotalClaimed(signer: ClientEvmSigner, channelId: `0x${string}`): Promise<[bigint, bigint]>;
|
|
158
|
+
/**
|
|
159
|
+
* Returns whether a local channel record exists for the given channel.
|
|
160
|
+
*
|
|
161
|
+
* @param storage - Client channel storage.
|
|
162
|
+
* @param channelId - The channel identifier to check.
|
|
163
|
+
* @returns `true` when a channel record is stored.
|
|
164
|
+
*/
|
|
165
|
+
declare function hasChannel(storage: ClientChannelStorage, channelId: string): Promise<boolean>;
|
|
166
|
+
/**
|
|
167
|
+
* Returns the local channel context for a channel, if present.
|
|
168
|
+
*
|
|
169
|
+
* @param storage - Client channel storage.
|
|
170
|
+
* @param channelId - The channel identifier.
|
|
171
|
+
* @returns Stored context or `undefined`.
|
|
172
|
+
*/
|
|
173
|
+
declare function getChannel(storage: ClientChannelStorage, channelId: string): Promise<BatchSettlementClientContext | undefined>;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Caller-facing options for {@link refundChannel}.
|
|
177
|
+
*/
|
|
178
|
+
interface RefundOptions {
|
|
179
|
+
/** Token base units to refund; omit for a full refund (drains remaining balance). */
|
|
180
|
+
amount?: string;
|
|
181
|
+
/** Custom fetch implementation (defaults to `globalThis.fetch`). */
|
|
182
|
+
fetch?: typeof fetch;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Sends a cooperative refund request to the channel that backs `url`.
|
|
186
|
+
*
|
|
187
|
+
* Flow:
|
|
188
|
+
* 1. Probe the URL with `GET` (no payment) to obtain the route's payment requirements.
|
|
189
|
+
* 2. Build the `ChannelConfig` and resolve the local session (or recover it).
|
|
190
|
+
* 3. Sign a zero-charge refund voucher (`maxClaimableAmount = chargedCumulativeAmount`).
|
|
191
|
+
* 4. Send the voucher via `PAYMENT-SIGNATURE`. On a corrective 402, run the
|
|
192
|
+
* standard recovery path and retry once.
|
|
193
|
+
* 5. Return the parsed `SettleResponse` from the server.
|
|
194
|
+
*
|
|
195
|
+
* @param ctx - Identity inputs (storage, signers, salt, payerAuthorizer).
|
|
196
|
+
* @param url - Any protected route on the channel to refund (the resource handler is bypassed).
|
|
197
|
+
* @param options - Optional `amount` (partial refund) and `fetch` override.
|
|
198
|
+
* @returns The settle response describing the refund outcome.
|
|
199
|
+
* @throws When the probe fails, the receiver lacks an authorizer, or recovery fails.
|
|
200
|
+
*/
|
|
201
|
+
declare function refundChannel(ctx: BatchSettlementClientDeps, url: string, options?: RefundOptions): Promise<SettleResponse>;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Client-side implementation of the `batch-settlement` scheme for EVM networks.
|
|
205
|
+
*
|
|
206
|
+
* Builds payment payloads (deposit + voucher or voucher-only), processes server
|
|
207
|
+
* responses to update local session state via {@link processSettleResponse},
|
|
208
|
+
* handles corrective 402 resynchronisation via
|
|
209
|
+
* {@link processCorrectivePaymentRequired}, and supports on-demand cooperative
|
|
210
|
+
* refund requests via {@link refundChannel}.
|
|
211
|
+
*/
|
|
212
|
+
declare class BatchSettlementEvmScheme implements SchemeNetworkClient {
|
|
213
|
+
private readonly signer;
|
|
214
|
+
readonly scheme: "batch-settlement";
|
|
215
|
+
readonly schemeHooks: SchemeClientHooks;
|
|
216
|
+
private readonly storage;
|
|
217
|
+
private readonly depositPolicy;
|
|
218
|
+
private readonly depositStrategy;
|
|
219
|
+
private readonly salt;
|
|
220
|
+
private readonly payerAuthorizer;
|
|
221
|
+
private readonly voucherSigner;
|
|
222
|
+
private readonly extensionRpcOptions;
|
|
223
|
+
/**
|
|
224
|
+
* Constructs a batched client scheme.
|
|
225
|
+
*
|
|
226
|
+
* @param signer - Client EVM wallet used for signing vouchers and ERC-3009 authorizations.
|
|
227
|
+
* @param optionsOrPolicy - Either a full options object or a bare deposit-policy.
|
|
228
|
+
*/
|
|
229
|
+
constructor(signer: ClientEvmSigner, optionsOrPolicy?: BatchSettlementEvmSchemeOptions | BatchSettlementDepositPolicy);
|
|
230
|
+
/**
|
|
231
|
+
* Creates the payment payload for a batched request.
|
|
232
|
+
*
|
|
233
|
+
* If the channel has no onchain deposit (or needs a top-up), builds an
|
|
234
|
+
* ERC-3009 deposit payload bundled with a voucher. Otherwise, signs and
|
|
235
|
+
* returns a voucher-only payload.
|
|
236
|
+
*
|
|
237
|
+
* @param x402Version - Protocol version for the payload envelope.
|
|
238
|
+
* @param paymentRequirements - Server payment requirements (scheme, network, asset, amount).
|
|
239
|
+
* @param context - Optional payment payload context with extension hints.
|
|
240
|
+
* @returns A {@link PaymentPayloadResult} ready to be sent as the `X-PAYMENT` header.
|
|
241
|
+
*/
|
|
242
|
+
createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements, context?: PaymentPayloadContext): Promise<PaymentPayloadResult>;
|
|
243
|
+
/**
|
|
244
|
+
* Sends a cooperative refund request.
|
|
245
|
+
*
|
|
246
|
+
* @param url - The route URL backing the channel to refund.
|
|
247
|
+
* @param options - Optional `amount` (partial refund) and `fetch` override.
|
|
248
|
+
* @returns The settle response describing the refund outcome.
|
|
249
|
+
*/
|
|
250
|
+
refund(url: string, options?: RefundOptions): Promise<SettleResponse>;
|
|
251
|
+
/**
|
|
252
|
+
* Updates local channel state from a settle response.
|
|
253
|
+
*
|
|
254
|
+
* @param settle - The parsed settle response from the server.
|
|
255
|
+
* @returns Resolves when local channel state has been updated.
|
|
256
|
+
*/
|
|
257
|
+
processSettleResponse(settle: SettleResponse): Promise<void>;
|
|
258
|
+
/**
|
|
259
|
+
* Resyncs local channel state from a corrective 402 response.
|
|
260
|
+
*
|
|
261
|
+
* @param paymentRequired - The decoded 402 response body.
|
|
262
|
+
* @returns `true` if local state was successfully resynced and a retry is warranted.
|
|
263
|
+
*/
|
|
264
|
+
processCorrectivePaymentRequired(paymentRequired: PaymentRequired): Promise<boolean>;
|
|
265
|
+
/**
|
|
266
|
+
* Builds the immutable {@link ChannelConfig} for a given set of payment
|
|
267
|
+
* requirements, using the scheme's own signer and salt.
|
|
268
|
+
*
|
|
269
|
+
* @param paymentRequirements - Server payment requirements for the channel.
|
|
270
|
+
* @returns The channel config that uniquely identifies the payment channel.
|
|
271
|
+
*/
|
|
272
|
+
buildChannelConfig(paymentRequirements: PaymentRequirements): ChannelConfig;
|
|
273
|
+
/**
|
|
274
|
+
* Resolves the deposit amount after applying the optional custom strategy.
|
|
275
|
+
*
|
|
276
|
+
* @param context - Deposit attempt context exposed to the strategy.
|
|
277
|
+
* @returns The deposit amount to sign, or `false` to skip this deposit attempt.
|
|
278
|
+
*/
|
|
279
|
+
private resolveDepositAmount;
|
|
280
|
+
/**
|
|
281
|
+
* Normalizes and validates a strategy-provided base-unit deposit amount.
|
|
282
|
+
*
|
|
283
|
+
* @param value - Strategy-provided string or bigint amount.
|
|
284
|
+
* @returns Normalized decimal string.
|
|
285
|
+
*/
|
|
286
|
+
private normalizeStrategyDepositAmount;
|
|
287
|
+
/**
|
|
288
|
+
* Signs a voucher-only payment payload for the current channel.
|
|
289
|
+
*
|
|
290
|
+
* @param x402Version - Protocol version for the payload envelope.
|
|
291
|
+
* @param channelId - Channel identifier for the voucher.
|
|
292
|
+
* @param maxClaimableAmount - Cumulative ceiling for the voucher.
|
|
293
|
+
* @param network - CAIP-2 network identifier.
|
|
294
|
+
* @param config - Immutable channel configuration.
|
|
295
|
+
* @returns Voucher-only payment payload.
|
|
296
|
+
*/
|
|
297
|
+
private createVoucherPayload;
|
|
298
|
+
/**
|
|
299
|
+
* Bundles the class state into the {@link BatchSettlementClientDeps} shape
|
|
300
|
+
* consumed by the `channel`, `recovery`, and `refund` modules.
|
|
301
|
+
*
|
|
302
|
+
* @returns Client deps wrapping the scheme's own signer and storage.
|
|
303
|
+
*/
|
|
304
|
+
private deps;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export { BatchSettlementEvmScheme as B, type RefundOptions as R, type BatchSettlementClientDeps as a, type BatchSettlementDepositPolicy as b, type BatchSettlementDepositStrategy as c, type BatchSettlementDepositStrategyContext as d, type BatchSettlementDepositStrategyResult as e, type BatchSettlementEvmSchemeOptions as f, depositAmountForRequest as g, resolveClientOptions as h, isBatchSettlementEvmSchemeOptions as i, type ResolvedClientOptions as j, buildChannelConfig as k, getChannel as l, hasChannel as m, processSettleResponse as n, readChannelBalanceAndTotalClaimed as o, processPaymentResponse as p, recoverChannel as q, refundChannel as r, updateChannelAfterRefund as u, validateDepositPolicy as v };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SchemeNetworkClient, PaymentRequirements, PaymentPayloadContext, PaymentPayloadResult } from '@payai/x402/types';
|
|
2
|
-
import { C as ClientEvmSigner } from './signer-
|
|
3
|
-
import { E as ExactEvmSchemeOptions } from './
|
|
2
|
+
import { C as ClientEvmSigner } from './signer-tYS6Y46X.js';
|
|
3
|
+
import { E as ExactEvmSchemeOptions } from './rpc-DULZzRne.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* EVM client implementation for the Exact payment scheme.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Log } from 'viem';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* ClientEvmSigner - Used by x402 clients to sign payment authorizations.
|
|
3
5
|
*
|
|
@@ -102,6 +104,7 @@ type FacilitatorEvmSigner = {
|
|
|
102
104
|
hash: `0x${string}`;
|
|
103
105
|
}): Promise<{
|
|
104
106
|
status: string;
|
|
107
|
+
logs?: readonly Log[];
|
|
105
108
|
}>;
|
|
106
109
|
getCode(args: {
|
|
107
110
|
address: `0x${string}`;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side channel fields mirrored from PAYMENT-RESPONSE / recovery flows.
|
|
3
|
+
*/
|
|
4
|
+
interface BatchSettlementClientContext {
|
|
5
|
+
/** Current cumulative amount charged by the server for this channel */
|
|
6
|
+
chargedCumulativeAmount?: string;
|
|
7
|
+
/** Current onchain channel balance */
|
|
8
|
+
balance?: string;
|
|
9
|
+
/** Total claimed onchain */
|
|
10
|
+
totalClaimed?: string;
|
|
11
|
+
/** Latest client-signed maxClaimableAmount cap (after corrective recovery, optional) */
|
|
12
|
+
signedMaxClaimable?: string;
|
|
13
|
+
/** Client voucher signature for {@link signedMaxClaimable} (optional) */
|
|
14
|
+
signature?: `0x${string}`;
|
|
15
|
+
}
|
|
16
|
+
interface ClientChannelStorage {
|
|
17
|
+
get(key: string): Promise<BatchSettlementClientContext | undefined>;
|
|
18
|
+
set(key: string, context: BatchSettlementClientContext): Promise<void>;
|
|
19
|
+
delete(key: string): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Default in-memory {@link ClientChannelStorage} (channel records do not survive process restart).
|
|
23
|
+
*/
|
|
24
|
+
declare class InMemoryClientChannelStorage implements ClientChannelStorage {
|
|
25
|
+
private readonly channels;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the channel record for `key` if present.
|
|
28
|
+
*
|
|
29
|
+
* @param key - Channel storage key (channelId).
|
|
30
|
+
* @returns Persisted context or undefined.
|
|
31
|
+
*/
|
|
32
|
+
get(key: string): Promise<BatchSettlementClientContext | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Stores or replaces the channel record for `key`.
|
|
35
|
+
*
|
|
36
|
+
* @param key - Channel storage key.
|
|
37
|
+
* @param context - Channel fields to persist.
|
|
38
|
+
* @returns Resolves when stored.
|
|
39
|
+
*/
|
|
40
|
+
set(key: string, context: BatchSettlementClientContext): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Removes the channel record for `key` if it exists.
|
|
43
|
+
*
|
|
44
|
+
* @param key - Channel storage key.
|
|
45
|
+
* @returns Resolves when removed.
|
|
46
|
+
*/
|
|
47
|
+
delete(key: string): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { type BatchSettlementClientContext as B, type ClientChannelStorage as C, InMemoryClientChannelStorage as I };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { C as ChannelConfig } from './types-CF8P2-NM.js';
|
|
2
|
+
|
|
3
|
+
interface Channel {
|
|
4
|
+
channelId: string;
|
|
5
|
+
channelConfig: ChannelConfig;
|
|
6
|
+
chargedCumulativeAmount: string;
|
|
7
|
+
signedMaxClaimable: string;
|
|
8
|
+
signature: string;
|
|
9
|
+
balance: string;
|
|
10
|
+
totalClaimed: string;
|
|
11
|
+
withdrawRequestedAt: number;
|
|
12
|
+
refundNonce: number;
|
|
13
|
+
onchainSyncedAt?: number;
|
|
14
|
+
lastRequestTimestamp: number;
|
|
15
|
+
pendingRequest?: PendingRequest;
|
|
16
|
+
}
|
|
17
|
+
interface PendingRequest {
|
|
18
|
+
pendingId: string;
|
|
19
|
+
signedMaxClaimable: string;
|
|
20
|
+
expiresAt: number;
|
|
21
|
+
}
|
|
22
|
+
interface ChannelUpdateResult {
|
|
23
|
+
channel: Channel | undefined;
|
|
24
|
+
status: "updated" | "unchanged" | "deleted";
|
|
25
|
+
}
|
|
26
|
+
interface ChannelStorage {
|
|
27
|
+
get(channelId: string): Promise<Channel | undefined>;
|
|
28
|
+
list(): Promise<Channel[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Atomically inspects and mutates a channel record.
|
|
31
|
+
*
|
|
32
|
+
* Implementations must guarantee that no concurrent mutation can interleave between
|
|
33
|
+
* reading `current` and writing the callback result for all application instances that
|
|
34
|
+
* share the backend. The in-memory backend only provides this guarantee inside one JS
|
|
35
|
+
* runtime; production multi-instance deployments need storage with backend-level atomic
|
|
36
|
+
* conditional mutation, such as Redis/Valkey Lua scripts, SQL transactions, or Durable Objects.
|
|
37
|
+
*
|
|
38
|
+
* @param channelId - The channel identifier.
|
|
39
|
+
* @param update - Mutation callback. Return `undefined` to delete, or `current` to leave unchanged.
|
|
40
|
+
* @returns The final stored channel and whether storage updated, stayed unchanged, or deleted.
|
|
41
|
+
*/
|
|
42
|
+
updateChannel(channelId: string, update: (current: Channel | undefined) => Channel | undefined): Promise<ChannelUpdateResult>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* In-memory {@link ChannelStorage} backed by a Map keyed by `channelId`.
|
|
46
|
+
*/
|
|
47
|
+
declare class InMemoryChannelStorage implements ChannelStorage {
|
|
48
|
+
private readonly channels;
|
|
49
|
+
private readonly channelLocks;
|
|
50
|
+
/**
|
|
51
|
+
* Returns the channel record for a channel, if present.
|
|
52
|
+
*
|
|
53
|
+
* @param channelId - The channel identifier.
|
|
54
|
+
* @returns The channel record or undefined when not found.
|
|
55
|
+
*/
|
|
56
|
+
get(channelId: string): Promise<Channel | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Lists all stored channel records.
|
|
59
|
+
*
|
|
60
|
+
* @returns All channel records in storage.
|
|
61
|
+
*/
|
|
62
|
+
list(): Promise<Channel[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Atomically inspects and mutates a channel record while holding a per-channel lock.
|
|
65
|
+
*
|
|
66
|
+
* @param channelId - The channel identifier.
|
|
67
|
+
* @param update - Mutation callback. Return `undefined` to delete, or `current` to leave unchanged.
|
|
68
|
+
* @returns The final stored channel and whether storage updated, stayed unchanged, or deleted.
|
|
69
|
+
*/
|
|
70
|
+
updateChannel(channelId: string, update: (current: Channel | undefined) => Channel | undefined): Promise<ChannelUpdateResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Runs `fn` after any prior locked work for the same channel key has finished.
|
|
73
|
+
*
|
|
74
|
+
* @param key - Lowercased channel id used as the lock key.
|
|
75
|
+
* @param fn - Async work to run while holding the logical per-channel lock.
|
|
76
|
+
* @returns The resolved result of `fn`.
|
|
77
|
+
*/
|
|
78
|
+
private withChannelLock;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { type ChannelStorage as C, InMemoryChannelStorage as I, type PendingRequest as P, type Channel as a, type ChannelUpdateResult as b };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { TypedData } from 'viem';
|
|
2
|
+
|
|
3
|
+
interface AuthorizerSigner {
|
|
4
|
+
address: `0x${string}`;
|
|
5
|
+
signTypedData(params: {
|
|
6
|
+
domain: Record<string, unknown>;
|
|
7
|
+
types: TypedData;
|
|
8
|
+
primaryType: string;
|
|
9
|
+
message: Record<string, unknown>;
|
|
10
|
+
}): Promise<`0x${string}`>;
|
|
11
|
+
}
|
|
12
|
+
type ChannelState = {
|
|
13
|
+
balance: bigint;
|
|
14
|
+
totalClaimed: bigint;
|
|
15
|
+
withdrawRequestedAt: number;
|
|
16
|
+
refundNonce: bigint;
|
|
17
|
+
};
|
|
18
|
+
type ChannelConfig = {
|
|
19
|
+
payer: `0x${string}`;
|
|
20
|
+
payerAuthorizer: `0x${string}`;
|
|
21
|
+
receiver: `0x${string}`;
|
|
22
|
+
receiverAuthorizer: `0x${string}`;
|
|
23
|
+
token: `0x${string}`;
|
|
24
|
+
withdrawDelay: number;
|
|
25
|
+
salt: `0x${string}`;
|
|
26
|
+
};
|
|
27
|
+
type BatchSettlementErc3009Authorization = {
|
|
28
|
+
validAfter: string;
|
|
29
|
+
validBefore: string;
|
|
30
|
+
salt: `0x${string}`;
|
|
31
|
+
signature: `0x${string}`;
|
|
32
|
+
};
|
|
33
|
+
type BatchSettlementPermit2Authorization = {
|
|
34
|
+
from: `0x${string}`;
|
|
35
|
+
permitted: {
|
|
36
|
+
token: `0x${string}`;
|
|
37
|
+
amount: string;
|
|
38
|
+
};
|
|
39
|
+
spender: `0x${string}`;
|
|
40
|
+
nonce: string;
|
|
41
|
+
deadline: string;
|
|
42
|
+
witness: {
|
|
43
|
+
channelId: `0x${string}`;
|
|
44
|
+
};
|
|
45
|
+
signature: `0x${string}`;
|
|
46
|
+
};
|
|
47
|
+
type BatchSettlementAssetTransferMethod = "eip3009" | "permit2";
|
|
48
|
+
type BatchSettlementDepositAuthorization = {
|
|
49
|
+
erc3009Authorization: BatchSettlementErc3009Authorization;
|
|
50
|
+
permit2Authorization?: never;
|
|
51
|
+
} | {
|
|
52
|
+
erc3009Authorization?: never;
|
|
53
|
+
permit2Authorization: BatchSettlementPermit2Authorization;
|
|
54
|
+
};
|
|
55
|
+
type BatchSettlementDepositPayload = {
|
|
56
|
+
type: "deposit";
|
|
57
|
+
channelConfig: ChannelConfig;
|
|
58
|
+
voucher: BatchSettlementVoucherFields;
|
|
59
|
+
deposit: {
|
|
60
|
+
amount: string;
|
|
61
|
+
authorization: BatchSettlementDepositAuthorization;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
type BatchSettlementVoucherPayload = {
|
|
65
|
+
type: "voucher";
|
|
66
|
+
channelConfig: ChannelConfig;
|
|
67
|
+
voucher: BatchSettlementVoucherFields;
|
|
68
|
+
};
|
|
69
|
+
type BatchSettlementRefundPayload = {
|
|
70
|
+
type: "refund";
|
|
71
|
+
channelConfig: ChannelConfig;
|
|
72
|
+
voucher: BatchSettlementVoucherFields;
|
|
73
|
+
amount?: string;
|
|
74
|
+
};
|
|
75
|
+
type BatchSettlementVoucherFields = {
|
|
76
|
+
channelId: `0x${string}`;
|
|
77
|
+
maxClaimableAmount: string;
|
|
78
|
+
signature: `0x${string}`;
|
|
79
|
+
};
|
|
80
|
+
type BatchSettlementVoucherClaim = {
|
|
81
|
+
voucher: {
|
|
82
|
+
channel: ChannelConfig;
|
|
83
|
+
maxClaimableAmount: string;
|
|
84
|
+
};
|
|
85
|
+
signature: `0x${string}`;
|
|
86
|
+
totalClaimed: string;
|
|
87
|
+
};
|
|
88
|
+
type BatchSettlementChannelStateExtra = {
|
|
89
|
+
channelId: `0x${string}`;
|
|
90
|
+
balance: string;
|
|
91
|
+
totalClaimed: string;
|
|
92
|
+
withdrawRequestedAt: number;
|
|
93
|
+
refundNonce: string;
|
|
94
|
+
chargedCumulativeAmount?: string;
|
|
95
|
+
};
|
|
96
|
+
type BatchSettlementVoucherStateExtra = {
|
|
97
|
+
signedMaxClaimable?: string;
|
|
98
|
+
signature?: `0x${string}`;
|
|
99
|
+
};
|
|
100
|
+
type BatchSettlementPaymentRequirementsExtra = {
|
|
101
|
+
receiverAuthorizer: `0x${string}`;
|
|
102
|
+
withdrawDelay: number;
|
|
103
|
+
name: string;
|
|
104
|
+
version: string;
|
|
105
|
+
assetTransferMethod?: BatchSettlementAssetTransferMethod;
|
|
106
|
+
channelState?: BatchSettlementChannelStateExtra;
|
|
107
|
+
voucherState?: BatchSettlementVoucherStateExtra;
|
|
108
|
+
};
|
|
109
|
+
type FileChannelStorageOptions = {
|
|
110
|
+
/** Root directory; channels are stored under `{directory}/{client|server}/{channelId}.json`. */
|
|
111
|
+
directory: string;
|
|
112
|
+
};
|
|
113
|
+
type BatchSettlementPaymentResponseExtra = {
|
|
114
|
+
chargedAmount?: string;
|
|
115
|
+
channelState?: BatchSettlementChannelStateExtra;
|
|
116
|
+
voucherState?: BatchSettlementVoucherStateExtra;
|
|
117
|
+
};
|
|
118
|
+
type BatchSettlementClaimPayload = {
|
|
119
|
+
type: "claim";
|
|
120
|
+
claims: BatchSettlementVoucherClaim[];
|
|
121
|
+
claimAuthorizerSignature?: `0x${string}`;
|
|
122
|
+
};
|
|
123
|
+
type BatchSettlementSettlePayload = {
|
|
124
|
+
type: "settle";
|
|
125
|
+
receiver: `0x${string}`;
|
|
126
|
+
token: `0x${string}`;
|
|
127
|
+
};
|
|
128
|
+
type BatchSettlementEnrichedRefundPayload = BatchSettlementRefundPayload & {
|
|
129
|
+
amount: string;
|
|
130
|
+
refundNonce: string;
|
|
131
|
+
claims: BatchSettlementVoucherClaim[];
|
|
132
|
+
refundAuthorizerSignature?: `0x${string}`;
|
|
133
|
+
claimAuthorizerSignature?: `0x${string}`;
|
|
134
|
+
};
|
|
135
|
+
type BatchSettlementPayload = BatchSettlementDepositPayload | BatchSettlementVoucherPayload | BatchSettlementRefundPayload;
|
|
136
|
+
type BatchSettlementFacilitatorSettlePayload = BatchSettlementDepositPayload | BatchSettlementClaimPayload | BatchSettlementSettlePayload | BatchSettlementEnrichedRefundPayload;
|
|
137
|
+
/**
|
|
138
|
+
* Type guard for {@link BatchSettlementDepositPayload}.
|
|
139
|
+
*
|
|
140
|
+
* @param payload - Unknown payload to check.
|
|
141
|
+
* @returns True if `payload` is a deposit payload (carries `deposit` and `voucher`).
|
|
142
|
+
*/
|
|
143
|
+
declare function isBatchSettlementDepositPayload(payload: unknown): payload is BatchSettlementDepositPayload;
|
|
144
|
+
/**
|
|
145
|
+
* Type guard for {@link BatchSettlementVoucherPayload}.
|
|
146
|
+
*
|
|
147
|
+
* @param payload - Unknown payload to check.
|
|
148
|
+
* @returns True if `payload` is a voucher payload with channel and signature fields.
|
|
149
|
+
*/
|
|
150
|
+
declare function isBatchSettlementVoucherPayload(payload: unknown): payload is BatchSettlementVoucherPayload;
|
|
151
|
+
/**
|
|
152
|
+
* Type guard for {@link BatchSettlementRefundPayload}.
|
|
153
|
+
*
|
|
154
|
+
* @param payload - Unknown payload to check.
|
|
155
|
+
* @returns True if `payload` is a refund payload with channel config and voucher fields.
|
|
156
|
+
*/
|
|
157
|
+
declare function isBatchSettlementRefundPayload(payload: unknown): payload is BatchSettlementRefundPayload;
|
|
158
|
+
/**
|
|
159
|
+
* Type guard for {@link BatchSettlementClaimPayload}.
|
|
160
|
+
*
|
|
161
|
+
* @param payload - Unknown payload to check.
|
|
162
|
+
* @returns True if `payload` is a settle-action `claimWithSignature` payload.
|
|
163
|
+
*/
|
|
164
|
+
declare function isBatchSettlementClaimPayload(payload: unknown): payload is BatchSettlementClaimPayload;
|
|
165
|
+
/**
|
|
166
|
+
* Type guard for {@link BatchSettlementSettlePayload}.
|
|
167
|
+
*
|
|
168
|
+
* @param payload - Unknown payload to check.
|
|
169
|
+
* @returns True if `payload` is a settle-action `settle` payload.
|
|
170
|
+
*/
|
|
171
|
+
declare function isBatchSettlementSettlePayload(payload: unknown): payload is BatchSettlementSettlePayload;
|
|
172
|
+
/**
|
|
173
|
+
* Type guard for {@link BatchSettlementEnrichedRefundPayload}.
|
|
174
|
+
*
|
|
175
|
+
* @param payload - Unknown payload to check.
|
|
176
|
+
* @returns True if `payload` is a settle-action `refundWithSignature` payload.
|
|
177
|
+
*/
|
|
178
|
+
declare function isBatchSettlementEnrichedRefundPayload(payload: unknown): payload is BatchSettlementEnrichedRefundPayload;
|
|
179
|
+
|
|
180
|
+
export { type AuthorizerSigner as A, type BatchSettlementDepositPayload as B, type ChannelConfig as C, type FileChannelStorageOptions as F, type ChannelState as a, type BatchSettlementVoucherPayload as b, type BatchSettlementRefundPayload as c, type BatchSettlementVoucherFields as d, type BatchSettlementErc3009Authorization as e, type BatchSettlementClaimPayload as f, type BatchSettlementEnrichedRefundPayload as g, type BatchSettlementVoucherClaim as h, type BatchSettlementPayload as i, type BatchSettlementSettlePayload as j, type BatchSettlementFacilitatorSettlePayload as k, type BatchSettlementPaymentRequirementsExtra as l, type BatchSettlementPaymentResponseExtra as m, isBatchSettlementDepositPayload as n, isBatchSettlementVoucherPayload as o, isBatchSettlementRefundPayload as p, isBatchSettlementClaimPayload as q, isBatchSettlementSettlePayload as r, isBatchSettlementEnrichedRefundPayload as s, type BatchSettlementChannelStateExtra as t, type BatchSettlementVoucherStateExtra as u };
|