@perkos/scheme-deferred 1.0.0
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.mts +344 -0
- package/dist/index.d.ts +344 -0
- package/dist/index.js +376 -0
- package/dist/index.mjs +347 -0
- package/package.json +47 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { Address, Hex, DeferredPayload, PaymentRequirements, VerifyResponse, Voucher } from '@perkos/types-x402';
|
|
2
|
+
export { Address, DeferredPayload, Hex, PaymentRequirements, VerifyResponse, Voucher } from '@perkos/types-x402';
|
|
3
|
+
import { SupportedNetwork } from '@perkos/util-chains';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @perkos/scheme-deferred
|
|
7
|
+
* EIP-712 Voucher-based deferred payment verification utilities for x402 deferred scheme
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const VOUCHER_TYPE_DEF: readonly [{
|
|
11
|
+
readonly name: "id";
|
|
12
|
+
readonly type: "bytes32";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "buyer";
|
|
15
|
+
readonly type: "address";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "seller";
|
|
18
|
+
readonly type: "address";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "valueAggregate";
|
|
21
|
+
readonly type: "uint256";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "asset";
|
|
24
|
+
readonly type: "address";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "timestamp";
|
|
27
|
+
readonly type: "uint64";
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "nonce";
|
|
30
|
+
readonly type: "uint256";
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "escrow";
|
|
33
|
+
readonly type: "address";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "chainId";
|
|
36
|
+
readonly type: "uint256";
|
|
37
|
+
}];
|
|
38
|
+
type VoucherTypes = {
|
|
39
|
+
Voucher: typeof VOUCHER_TYPE_DEF;
|
|
40
|
+
};
|
|
41
|
+
declare const VOUCHER_TYPES: {
|
|
42
|
+
readonly Voucher: readonly [{
|
|
43
|
+
readonly name: "id";
|
|
44
|
+
readonly type: "bytes32";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "buyer";
|
|
47
|
+
readonly type: "address";
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: "seller";
|
|
50
|
+
readonly type: "address";
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "valueAggregate";
|
|
53
|
+
readonly type: "uint256";
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "asset";
|
|
56
|
+
readonly type: "address";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "timestamp";
|
|
59
|
+
readonly type: "uint64";
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "nonce";
|
|
62
|
+
readonly type: "uint256";
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "escrow";
|
|
65
|
+
readonly type: "address";
|
|
66
|
+
}, {
|
|
67
|
+
readonly name: "chainId";
|
|
68
|
+
readonly type: "uint256";
|
|
69
|
+
}];
|
|
70
|
+
};
|
|
71
|
+
interface EIP712Domain {
|
|
72
|
+
name: string;
|
|
73
|
+
version: string;
|
|
74
|
+
chainId: number;
|
|
75
|
+
verifyingContract: Address;
|
|
76
|
+
}
|
|
77
|
+
interface SignatureParts {
|
|
78
|
+
v: number;
|
|
79
|
+
r: Hex;
|
|
80
|
+
s: Hex;
|
|
81
|
+
}
|
|
82
|
+
interface DeferredSchemeConfig {
|
|
83
|
+
network: SupportedNetwork;
|
|
84
|
+
escrowAddress: Address;
|
|
85
|
+
rpcUrl?: string;
|
|
86
|
+
domainName?: string;
|
|
87
|
+
domainVersion?: string;
|
|
88
|
+
}
|
|
89
|
+
interface VerificationResult {
|
|
90
|
+
isValid: boolean;
|
|
91
|
+
invalidReason: string | null;
|
|
92
|
+
payer: Address | null;
|
|
93
|
+
recoveredSigner?: Address | null;
|
|
94
|
+
}
|
|
95
|
+
declare const ERC20_BALANCE_ABI: readonly [{
|
|
96
|
+
readonly name: "balanceOf";
|
|
97
|
+
readonly type: "function";
|
|
98
|
+
readonly stateMutability: "view";
|
|
99
|
+
readonly inputs: readonly [{
|
|
100
|
+
readonly name: "account";
|
|
101
|
+
readonly type: "address";
|
|
102
|
+
}];
|
|
103
|
+
readonly outputs: readonly [{
|
|
104
|
+
readonly name: "";
|
|
105
|
+
readonly type: "uint256";
|
|
106
|
+
}];
|
|
107
|
+
}];
|
|
108
|
+
declare const DEFERRED_ESCROW_GET_BALANCE_ABI: readonly [{
|
|
109
|
+
readonly name: "getAvailableBalance";
|
|
110
|
+
readonly type: "function";
|
|
111
|
+
readonly stateMutability: "view";
|
|
112
|
+
readonly inputs: readonly [{
|
|
113
|
+
readonly name: "buyer";
|
|
114
|
+
readonly type: "address";
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "seller";
|
|
117
|
+
readonly type: "address";
|
|
118
|
+
}, {
|
|
119
|
+
readonly name: "asset";
|
|
120
|
+
readonly type: "address";
|
|
121
|
+
}];
|
|
122
|
+
readonly outputs: readonly [{
|
|
123
|
+
readonly name: "";
|
|
124
|
+
readonly type: "uint256";
|
|
125
|
+
}];
|
|
126
|
+
}];
|
|
127
|
+
declare const DEFERRED_ESCROW_VOUCHER_CLAIMED_ABI: readonly [{
|
|
128
|
+
readonly name: "voucherClaimed";
|
|
129
|
+
readonly type: "function";
|
|
130
|
+
readonly stateMutability: "view";
|
|
131
|
+
readonly inputs: readonly [{
|
|
132
|
+
readonly name: "voucherId";
|
|
133
|
+
readonly type: "bytes32";
|
|
134
|
+
}, {
|
|
135
|
+
readonly name: "nonce";
|
|
136
|
+
readonly type: "uint256";
|
|
137
|
+
}];
|
|
138
|
+
readonly outputs: readonly [{
|
|
139
|
+
readonly name: "";
|
|
140
|
+
readonly type: "bool";
|
|
141
|
+
}];
|
|
142
|
+
}];
|
|
143
|
+
declare const DEFERRED_ESCROW_CLAIM_VOUCHER_ABI: readonly [{
|
|
144
|
+
readonly name: "claimVoucher";
|
|
145
|
+
readonly type: "function";
|
|
146
|
+
readonly stateMutability: "nonpayable";
|
|
147
|
+
readonly inputs: readonly [{
|
|
148
|
+
readonly name: "voucher";
|
|
149
|
+
readonly type: "tuple";
|
|
150
|
+
readonly components: readonly [{
|
|
151
|
+
readonly name: "id";
|
|
152
|
+
readonly type: "bytes32";
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "buyer";
|
|
155
|
+
readonly type: "address";
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "seller";
|
|
158
|
+
readonly type: "address";
|
|
159
|
+
}, {
|
|
160
|
+
readonly name: "valueAggregate";
|
|
161
|
+
readonly type: "uint256";
|
|
162
|
+
}, {
|
|
163
|
+
readonly name: "asset";
|
|
164
|
+
readonly type: "address";
|
|
165
|
+
}, {
|
|
166
|
+
readonly name: "timestamp";
|
|
167
|
+
readonly type: "uint64";
|
|
168
|
+
}, {
|
|
169
|
+
readonly name: "nonce";
|
|
170
|
+
readonly type: "uint256";
|
|
171
|
+
}, {
|
|
172
|
+
readonly name: "escrow";
|
|
173
|
+
readonly type: "address";
|
|
174
|
+
}, {
|
|
175
|
+
readonly name: "chainId";
|
|
176
|
+
readonly type: "uint256";
|
|
177
|
+
}];
|
|
178
|
+
}, {
|
|
179
|
+
readonly name: "signature";
|
|
180
|
+
readonly type: "bytes";
|
|
181
|
+
}];
|
|
182
|
+
readonly outputs: readonly [];
|
|
183
|
+
}];
|
|
184
|
+
declare const DEFERRED_ESCROW_ABI: readonly [{
|
|
185
|
+
readonly name: "getAvailableBalance";
|
|
186
|
+
readonly type: "function";
|
|
187
|
+
readonly stateMutability: "view";
|
|
188
|
+
readonly inputs: readonly [{
|
|
189
|
+
readonly name: "buyer";
|
|
190
|
+
readonly type: "address";
|
|
191
|
+
}, {
|
|
192
|
+
readonly name: "seller";
|
|
193
|
+
readonly type: "address";
|
|
194
|
+
}, {
|
|
195
|
+
readonly name: "asset";
|
|
196
|
+
readonly type: "address";
|
|
197
|
+
}];
|
|
198
|
+
readonly outputs: readonly [{
|
|
199
|
+
readonly name: "";
|
|
200
|
+
readonly type: "uint256";
|
|
201
|
+
}];
|
|
202
|
+
}, {
|
|
203
|
+
readonly name: "voucherClaimed";
|
|
204
|
+
readonly type: "function";
|
|
205
|
+
readonly stateMutability: "view";
|
|
206
|
+
readonly inputs: readonly [{
|
|
207
|
+
readonly name: "voucherId";
|
|
208
|
+
readonly type: "bytes32";
|
|
209
|
+
}, {
|
|
210
|
+
readonly name: "nonce";
|
|
211
|
+
readonly type: "uint256";
|
|
212
|
+
}];
|
|
213
|
+
readonly outputs: readonly [{
|
|
214
|
+
readonly name: "";
|
|
215
|
+
readonly type: "bool";
|
|
216
|
+
}];
|
|
217
|
+
}, {
|
|
218
|
+
readonly name: "claimVoucher";
|
|
219
|
+
readonly type: "function";
|
|
220
|
+
readonly stateMutability: "nonpayable";
|
|
221
|
+
readonly inputs: readonly [{
|
|
222
|
+
readonly name: "voucher";
|
|
223
|
+
readonly type: "tuple";
|
|
224
|
+
readonly components: readonly [{
|
|
225
|
+
readonly name: "id";
|
|
226
|
+
readonly type: "bytes32";
|
|
227
|
+
}, {
|
|
228
|
+
readonly name: "buyer";
|
|
229
|
+
readonly type: "address";
|
|
230
|
+
}, {
|
|
231
|
+
readonly name: "seller";
|
|
232
|
+
readonly type: "address";
|
|
233
|
+
}, {
|
|
234
|
+
readonly name: "valueAggregate";
|
|
235
|
+
readonly type: "uint256";
|
|
236
|
+
}, {
|
|
237
|
+
readonly name: "asset";
|
|
238
|
+
readonly type: "address";
|
|
239
|
+
}, {
|
|
240
|
+
readonly name: "timestamp";
|
|
241
|
+
readonly type: "uint64";
|
|
242
|
+
}, {
|
|
243
|
+
readonly name: "nonce";
|
|
244
|
+
readonly type: "uint256";
|
|
245
|
+
}, {
|
|
246
|
+
readonly name: "escrow";
|
|
247
|
+
readonly type: "address";
|
|
248
|
+
}, {
|
|
249
|
+
readonly name: "chainId";
|
|
250
|
+
readonly type: "uint256";
|
|
251
|
+
}];
|
|
252
|
+
}, {
|
|
253
|
+
readonly name: "signature";
|
|
254
|
+
readonly type: "bytes";
|
|
255
|
+
}];
|
|
256
|
+
readonly outputs: readonly [];
|
|
257
|
+
}];
|
|
258
|
+
declare class DeferredSchemeVerifier {
|
|
259
|
+
private network;
|
|
260
|
+
private chainId;
|
|
261
|
+
private publicClient;
|
|
262
|
+
private escrowAddress;
|
|
263
|
+
private domainName;
|
|
264
|
+
private domainVersion;
|
|
265
|
+
constructor(config: DeferredSchemeConfig);
|
|
266
|
+
/**
|
|
267
|
+
* Verify a deferred scheme payment voucher
|
|
268
|
+
*/
|
|
269
|
+
verify(payload: DeferredPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
|
|
270
|
+
/**
|
|
271
|
+
* Validate voucher fields against requirements
|
|
272
|
+
*/
|
|
273
|
+
validateVoucher(voucher: Voucher, requirements: PaymentRequirements): boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Recover signer from EIP-712 typed data signature
|
|
276
|
+
*/
|
|
277
|
+
recoverSigner(voucher: Voucher, signature: Hex): Promise<Address | null>;
|
|
278
|
+
/**
|
|
279
|
+
* Get EIP-712 domain for escrow contract
|
|
280
|
+
*/
|
|
281
|
+
getEIP712Domain(): EIP712Domain;
|
|
282
|
+
/**
|
|
283
|
+
* Check if voucher has been claimed
|
|
284
|
+
*/
|
|
285
|
+
isVoucherClaimed(voucherId: Hex, nonce: bigint): Promise<boolean>;
|
|
286
|
+
/**
|
|
287
|
+
* Get available escrow balance
|
|
288
|
+
*/
|
|
289
|
+
getEscrowBalance(buyer: Address, seller: Address, asset: Address): Promise<bigint>;
|
|
290
|
+
/**
|
|
291
|
+
* Get network name
|
|
292
|
+
*/
|
|
293
|
+
getNetwork(): SupportedNetwork;
|
|
294
|
+
/**
|
|
295
|
+
* Get chain ID
|
|
296
|
+
*/
|
|
297
|
+
getChainId(): number;
|
|
298
|
+
/**
|
|
299
|
+
* Get escrow address
|
|
300
|
+
*/
|
|
301
|
+
getEscrowAddress(): Address;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Parse signature into v, r, s components
|
|
305
|
+
*/
|
|
306
|
+
declare function parseSignature(signature: Hex): SignatureParts;
|
|
307
|
+
/**
|
|
308
|
+
* Create EIP-712 domain for deferred escrow
|
|
309
|
+
*/
|
|
310
|
+
declare function createEIP712Domain(chainId: number, escrowAddress: Address, domainName?: string, domainVersion?: string): EIP712Domain;
|
|
311
|
+
/**
|
|
312
|
+
* Generate a random voucher ID (bytes32)
|
|
313
|
+
*/
|
|
314
|
+
declare function generateVoucherId(): Hex;
|
|
315
|
+
/**
|
|
316
|
+
* Create voucher message for signing
|
|
317
|
+
*/
|
|
318
|
+
declare function createVoucherMessage(id: Hex, buyer: Address, seller: Address, valueAggregate: bigint | string, asset: Address, timestamp: bigint | string, nonce: bigint | string, escrow: Address, chainId: number): {
|
|
319
|
+
id: `0x${string}`;
|
|
320
|
+
buyer: `0x${string}`;
|
|
321
|
+
seller: `0x${string}`;
|
|
322
|
+
valueAggregate: bigint;
|
|
323
|
+
asset: `0x${string}`;
|
|
324
|
+
timestamp: bigint;
|
|
325
|
+
nonce: bigint;
|
|
326
|
+
escrow: `0x${string}`;
|
|
327
|
+
chainId: bigint;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Create a voucher tuple for contract calls
|
|
331
|
+
*/
|
|
332
|
+
declare function createVoucherTuple(voucher: Voucher): {
|
|
333
|
+
id: `0x${string}`;
|
|
334
|
+
buyer: `0x${string}`;
|
|
335
|
+
seller: `0x${string}`;
|
|
336
|
+
valueAggregate: bigint;
|
|
337
|
+
asset: `0x${string}`;
|
|
338
|
+
timestamp: bigint;
|
|
339
|
+
nonce: bigint;
|
|
340
|
+
escrow: `0x${string}`;
|
|
341
|
+
chainId: bigint;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
export { DEFERRED_ESCROW_ABI, DEFERRED_ESCROW_CLAIM_VOUCHER_ABI, DEFERRED_ESCROW_GET_BALANCE_ABI, DEFERRED_ESCROW_VOUCHER_CLAIMED_ABI, type DeferredSchemeConfig, DeferredSchemeVerifier, type EIP712Domain, ERC20_BALANCE_ABI, type SignatureParts, VOUCHER_TYPES, VOUCHER_TYPE_DEF, type VerificationResult, type VoucherTypes, createEIP712Domain, createVoucherMessage, createVoucherTuple, generateVoucherId, parseSignature };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { Address, Hex, DeferredPayload, PaymentRequirements, VerifyResponse, Voucher } from '@perkos/types-x402';
|
|
2
|
+
export { Address, DeferredPayload, Hex, PaymentRequirements, VerifyResponse, Voucher } from '@perkos/types-x402';
|
|
3
|
+
import { SupportedNetwork } from '@perkos/util-chains';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @perkos/scheme-deferred
|
|
7
|
+
* EIP-712 Voucher-based deferred payment verification utilities for x402 deferred scheme
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const VOUCHER_TYPE_DEF: readonly [{
|
|
11
|
+
readonly name: "id";
|
|
12
|
+
readonly type: "bytes32";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "buyer";
|
|
15
|
+
readonly type: "address";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "seller";
|
|
18
|
+
readonly type: "address";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "valueAggregate";
|
|
21
|
+
readonly type: "uint256";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "asset";
|
|
24
|
+
readonly type: "address";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "timestamp";
|
|
27
|
+
readonly type: "uint64";
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: "nonce";
|
|
30
|
+
readonly type: "uint256";
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "escrow";
|
|
33
|
+
readonly type: "address";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "chainId";
|
|
36
|
+
readonly type: "uint256";
|
|
37
|
+
}];
|
|
38
|
+
type VoucherTypes = {
|
|
39
|
+
Voucher: typeof VOUCHER_TYPE_DEF;
|
|
40
|
+
};
|
|
41
|
+
declare const VOUCHER_TYPES: {
|
|
42
|
+
readonly Voucher: readonly [{
|
|
43
|
+
readonly name: "id";
|
|
44
|
+
readonly type: "bytes32";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "buyer";
|
|
47
|
+
readonly type: "address";
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: "seller";
|
|
50
|
+
readonly type: "address";
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "valueAggregate";
|
|
53
|
+
readonly type: "uint256";
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "asset";
|
|
56
|
+
readonly type: "address";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "timestamp";
|
|
59
|
+
readonly type: "uint64";
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "nonce";
|
|
62
|
+
readonly type: "uint256";
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "escrow";
|
|
65
|
+
readonly type: "address";
|
|
66
|
+
}, {
|
|
67
|
+
readonly name: "chainId";
|
|
68
|
+
readonly type: "uint256";
|
|
69
|
+
}];
|
|
70
|
+
};
|
|
71
|
+
interface EIP712Domain {
|
|
72
|
+
name: string;
|
|
73
|
+
version: string;
|
|
74
|
+
chainId: number;
|
|
75
|
+
verifyingContract: Address;
|
|
76
|
+
}
|
|
77
|
+
interface SignatureParts {
|
|
78
|
+
v: number;
|
|
79
|
+
r: Hex;
|
|
80
|
+
s: Hex;
|
|
81
|
+
}
|
|
82
|
+
interface DeferredSchemeConfig {
|
|
83
|
+
network: SupportedNetwork;
|
|
84
|
+
escrowAddress: Address;
|
|
85
|
+
rpcUrl?: string;
|
|
86
|
+
domainName?: string;
|
|
87
|
+
domainVersion?: string;
|
|
88
|
+
}
|
|
89
|
+
interface VerificationResult {
|
|
90
|
+
isValid: boolean;
|
|
91
|
+
invalidReason: string | null;
|
|
92
|
+
payer: Address | null;
|
|
93
|
+
recoveredSigner?: Address | null;
|
|
94
|
+
}
|
|
95
|
+
declare const ERC20_BALANCE_ABI: readonly [{
|
|
96
|
+
readonly name: "balanceOf";
|
|
97
|
+
readonly type: "function";
|
|
98
|
+
readonly stateMutability: "view";
|
|
99
|
+
readonly inputs: readonly [{
|
|
100
|
+
readonly name: "account";
|
|
101
|
+
readonly type: "address";
|
|
102
|
+
}];
|
|
103
|
+
readonly outputs: readonly [{
|
|
104
|
+
readonly name: "";
|
|
105
|
+
readonly type: "uint256";
|
|
106
|
+
}];
|
|
107
|
+
}];
|
|
108
|
+
declare const DEFERRED_ESCROW_GET_BALANCE_ABI: readonly [{
|
|
109
|
+
readonly name: "getAvailableBalance";
|
|
110
|
+
readonly type: "function";
|
|
111
|
+
readonly stateMutability: "view";
|
|
112
|
+
readonly inputs: readonly [{
|
|
113
|
+
readonly name: "buyer";
|
|
114
|
+
readonly type: "address";
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "seller";
|
|
117
|
+
readonly type: "address";
|
|
118
|
+
}, {
|
|
119
|
+
readonly name: "asset";
|
|
120
|
+
readonly type: "address";
|
|
121
|
+
}];
|
|
122
|
+
readonly outputs: readonly [{
|
|
123
|
+
readonly name: "";
|
|
124
|
+
readonly type: "uint256";
|
|
125
|
+
}];
|
|
126
|
+
}];
|
|
127
|
+
declare const DEFERRED_ESCROW_VOUCHER_CLAIMED_ABI: readonly [{
|
|
128
|
+
readonly name: "voucherClaimed";
|
|
129
|
+
readonly type: "function";
|
|
130
|
+
readonly stateMutability: "view";
|
|
131
|
+
readonly inputs: readonly [{
|
|
132
|
+
readonly name: "voucherId";
|
|
133
|
+
readonly type: "bytes32";
|
|
134
|
+
}, {
|
|
135
|
+
readonly name: "nonce";
|
|
136
|
+
readonly type: "uint256";
|
|
137
|
+
}];
|
|
138
|
+
readonly outputs: readonly [{
|
|
139
|
+
readonly name: "";
|
|
140
|
+
readonly type: "bool";
|
|
141
|
+
}];
|
|
142
|
+
}];
|
|
143
|
+
declare const DEFERRED_ESCROW_CLAIM_VOUCHER_ABI: readonly [{
|
|
144
|
+
readonly name: "claimVoucher";
|
|
145
|
+
readonly type: "function";
|
|
146
|
+
readonly stateMutability: "nonpayable";
|
|
147
|
+
readonly inputs: readonly [{
|
|
148
|
+
readonly name: "voucher";
|
|
149
|
+
readonly type: "tuple";
|
|
150
|
+
readonly components: readonly [{
|
|
151
|
+
readonly name: "id";
|
|
152
|
+
readonly type: "bytes32";
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "buyer";
|
|
155
|
+
readonly type: "address";
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "seller";
|
|
158
|
+
readonly type: "address";
|
|
159
|
+
}, {
|
|
160
|
+
readonly name: "valueAggregate";
|
|
161
|
+
readonly type: "uint256";
|
|
162
|
+
}, {
|
|
163
|
+
readonly name: "asset";
|
|
164
|
+
readonly type: "address";
|
|
165
|
+
}, {
|
|
166
|
+
readonly name: "timestamp";
|
|
167
|
+
readonly type: "uint64";
|
|
168
|
+
}, {
|
|
169
|
+
readonly name: "nonce";
|
|
170
|
+
readonly type: "uint256";
|
|
171
|
+
}, {
|
|
172
|
+
readonly name: "escrow";
|
|
173
|
+
readonly type: "address";
|
|
174
|
+
}, {
|
|
175
|
+
readonly name: "chainId";
|
|
176
|
+
readonly type: "uint256";
|
|
177
|
+
}];
|
|
178
|
+
}, {
|
|
179
|
+
readonly name: "signature";
|
|
180
|
+
readonly type: "bytes";
|
|
181
|
+
}];
|
|
182
|
+
readonly outputs: readonly [];
|
|
183
|
+
}];
|
|
184
|
+
declare const DEFERRED_ESCROW_ABI: readonly [{
|
|
185
|
+
readonly name: "getAvailableBalance";
|
|
186
|
+
readonly type: "function";
|
|
187
|
+
readonly stateMutability: "view";
|
|
188
|
+
readonly inputs: readonly [{
|
|
189
|
+
readonly name: "buyer";
|
|
190
|
+
readonly type: "address";
|
|
191
|
+
}, {
|
|
192
|
+
readonly name: "seller";
|
|
193
|
+
readonly type: "address";
|
|
194
|
+
}, {
|
|
195
|
+
readonly name: "asset";
|
|
196
|
+
readonly type: "address";
|
|
197
|
+
}];
|
|
198
|
+
readonly outputs: readonly [{
|
|
199
|
+
readonly name: "";
|
|
200
|
+
readonly type: "uint256";
|
|
201
|
+
}];
|
|
202
|
+
}, {
|
|
203
|
+
readonly name: "voucherClaimed";
|
|
204
|
+
readonly type: "function";
|
|
205
|
+
readonly stateMutability: "view";
|
|
206
|
+
readonly inputs: readonly [{
|
|
207
|
+
readonly name: "voucherId";
|
|
208
|
+
readonly type: "bytes32";
|
|
209
|
+
}, {
|
|
210
|
+
readonly name: "nonce";
|
|
211
|
+
readonly type: "uint256";
|
|
212
|
+
}];
|
|
213
|
+
readonly outputs: readonly [{
|
|
214
|
+
readonly name: "";
|
|
215
|
+
readonly type: "bool";
|
|
216
|
+
}];
|
|
217
|
+
}, {
|
|
218
|
+
readonly name: "claimVoucher";
|
|
219
|
+
readonly type: "function";
|
|
220
|
+
readonly stateMutability: "nonpayable";
|
|
221
|
+
readonly inputs: readonly [{
|
|
222
|
+
readonly name: "voucher";
|
|
223
|
+
readonly type: "tuple";
|
|
224
|
+
readonly components: readonly [{
|
|
225
|
+
readonly name: "id";
|
|
226
|
+
readonly type: "bytes32";
|
|
227
|
+
}, {
|
|
228
|
+
readonly name: "buyer";
|
|
229
|
+
readonly type: "address";
|
|
230
|
+
}, {
|
|
231
|
+
readonly name: "seller";
|
|
232
|
+
readonly type: "address";
|
|
233
|
+
}, {
|
|
234
|
+
readonly name: "valueAggregate";
|
|
235
|
+
readonly type: "uint256";
|
|
236
|
+
}, {
|
|
237
|
+
readonly name: "asset";
|
|
238
|
+
readonly type: "address";
|
|
239
|
+
}, {
|
|
240
|
+
readonly name: "timestamp";
|
|
241
|
+
readonly type: "uint64";
|
|
242
|
+
}, {
|
|
243
|
+
readonly name: "nonce";
|
|
244
|
+
readonly type: "uint256";
|
|
245
|
+
}, {
|
|
246
|
+
readonly name: "escrow";
|
|
247
|
+
readonly type: "address";
|
|
248
|
+
}, {
|
|
249
|
+
readonly name: "chainId";
|
|
250
|
+
readonly type: "uint256";
|
|
251
|
+
}];
|
|
252
|
+
}, {
|
|
253
|
+
readonly name: "signature";
|
|
254
|
+
readonly type: "bytes";
|
|
255
|
+
}];
|
|
256
|
+
readonly outputs: readonly [];
|
|
257
|
+
}];
|
|
258
|
+
declare class DeferredSchemeVerifier {
|
|
259
|
+
private network;
|
|
260
|
+
private chainId;
|
|
261
|
+
private publicClient;
|
|
262
|
+
private escrowAddress;
|
|
263
|
+
private domainName;
|
|
264
|
+
private domainVersion;
|
|
265
|
+
constructor(config: DeferredSchemeConfig);
|
|
266
|
+
/**
|
|
267
|
+
* Verify a deferred scheme payment voucher
|
|
268
|
+
*/
|
|
269
|
+
verify(payload: DeferredPayload, requirements: PaymentRequirements): Promise<VerifyResponse>;
|
|
270
|
+
/**
|
|
271
|
+
* Validate voucher fields against requirements
|
|
272
|
+
*/
|
|
273
|
+
validateVoucher(voucher: Voucher, requirements: PaymentRequirements): boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Recover signer from EIP-712 typed data signature
|
|
276
|
+
*/
|
|
277
|
+
recoverSigner(voucher: Voucher, signature: Hex): Promise<Address | null>;
|
|
278
|
+
/**
|
|
279
|
+
* Get EIP-712 domain for escrow contract
|
|
280
|
+
*/
|
|
281
|
+
getEIP712Domain(): EIP712Domain;
|
|
282
|
+
/**
|
|
283
|
+
* Check if voucher has been claimed
|
|
284
|
+
*/
|
|
285
|
+
isVoucherClaimed(voucherId: Hex, nonce: bigint): Promise<boolean>;
|
|
286
|
+
/**
|
|
287
|
+
* Get available escrow balance
|
|
288
|
+
*/
|
|
289
|
+
getEscrowBalance(buyer: Address, seller: Address, asset: Address): Promise<bigint>;
|
|
290
|
+
/**
|
|
291
|
+
* Get network name
|
|
292
|
+
*/
|
|
293
|
+
getNetwork(): SupportedNetwork;
|
|
294
|
+
/**
|
|
295
|
+
* Get chain ID
|
|
296
|
+
*/
|
|
297
|
+
getChainId(): number;
|
|
298
|
+
/**
|
|
299
|
+
* Get escrow address
|
|
300
|
+
*/
|
|
301
|
+
getEscrowAddress(): Address;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Parse signature into v, r, s components
|
|
305
|
+
*/
|
|
306
|
+
declare function parseSignature(signature: Hex): SignatureParts;
|
|
307
|
+
/**
|
|
308
|
+
* Create EIP-712 domain for deferred escrow
|
|
309
|
+
*/
|
|
310
|
+
declare function createEIP712Domain(chainId: number, escrowAddress: Address, domainName?: string, domainVersion?: string): EIP712Domain;
|
|
311
|
+
/**
|
|
312
|
+
* Generate a random voucher ID (bytes32)
|
|
313
|
+
*/
|
|
314
|
+
declare function generateVoucherId(): Hex;
|
|
315
|
+
/**
|
|
316
|
+
* Create voucher message for signing
|
|
317
|
+
*/
|
|
318
|
+
declare function createVoucherMessage(id: Hex, buyer: Address, seller: Address, valueAggregate: bigint | string, asset: Address, timestamp: bigint | string, nonce: bigint | string, escrow: Address, chainId: number): {
|
|
319
|
+
id: `0x${string}`;
|
|
320
|
+
buyer: `0x${string}`;
|
|
321
|
+
seller: `0x${string}`;
|
|
322
|
+
valueAggregate: bigint;
|
|
323
|
+
asset: `0x${string}`;
|
|
324
|
+
timestamp: bigint;
|
|
325
|
+
nonce: bigint;
|
|
326
|
+
escrow: `0x${string}`;
|
|
327
|
+
chainId: bigint;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Create a voucher tuple for contract calls
|
|
331
|
+
*/
|
|
332
|
+
declare function createVoucherTuple(voucher: Voucher): {
|
|
333
|
+
id: `0x${string}`;
|
|
334
|
+
buyer: `0x${string}`;
|
|
335
|
+
seller: `0x${string}`;
|
|
336
|
+
valueAggregate: bigint;
|
|
337
|
+
asset: `0x${string}`;
|
|
338
|
+
timestamp: bigint;
|
|
339
|
+
nonce: bigint;
|
|
340
|
+
escrow: `0x${string}`;
|
|
341
|
+
chainId: bigint;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
export { DEFERRED_ESCROW_ABI, DEFERRED_ESCROW_CLAIM_VOUCHER_ABI, DEFERRED_ESCROW_GET_BALANCE_ABI, DEFERRED_ESCROW_VOUCHER_CLAIMED_ABI, type DeferredSchemeConfig, DeferredSchemeVerifier, type EIP712Domain, ERC20_BALANCE_ABI, type SignatureParts, VOUCHER_TYPES, VOUCHER_TYPE_DEF, type VerificationResult, type VoucherTypes, createEIP712Domain, createVoucherMessage, createVoucherTuple, generateVoucherId, parseSignature };
|