x402z-shared-web 0.0.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.
@@ -0,0 +1,391 @@
1
+ import { WalletClient } from 'viem';
2
+ export * from '@x402/core/types';
3
+
4
+ declare const confidentialTokenAbi: readonly [{
5
+ readonly inputs: readonly [{
6
+ readonly internalType: "address";
7
+ readonly name: "to";
8
+ readonly type: "address";
9
+ }, {
10
+ readonly internalType: "bytes32";
11
+ readonly name: "encryptedAmountInput";
12
+ readonly type: "bytes32";
13
+ }, {
14
+ readonly internalType: "bytes";
15
+ readonly name: "inputProof";
16
+ readonly type: "bytes";
17
+ }];
18
+ readonly name: "confidentialTransfer";
19
+ readonly outputs: readonly [{
20
+ readonly internalType: "euint64";
21
+ readonly name: "transferred";
22
+ readonly type: "bytes32";
23
+ }];
24
+ readonly stateMutability: "nonpayable";
25
+ readonly type: "function";
26
+ }, {
27
+ readonly inputs: readonly [{
28
+ readonly components: readonly [{
29
+ readonly internalType: "address";
30
+ readonly name: "holder";
31
+ readonly type: "address";
32
+ }, {
33
+ readonly internalType: "address";
34
+ readonly name: "payee";
35
+ readonly type: "address";
36
+ }, {
37
+ readonly internalType: "uint256";
38
+ readonly name: "maxClearAmount";
39
+ readonly type: "uint256";
40
+ }, {
41
+ readonly internalType: "bytes32";
42
+ readonly name: "resourceHash";
43
+ readonly type: "bytes32";
44
+ }, {
45
+ readonly internalType: "uint48";
46
+ readonly name: "validAfter";
47
+ readonly type: "uint48";
48
+ }, {
49
+ readonly internalType: "uint48";
50
+ readonly name: "validBefore";
51
+ readonly type: "uint48";
52
+ }, {
53
+ readonly internalType: "bytes32";
54
+ readonly name: "nonce";
55
+ readonly type: "bytes32";
56
+ }, {
57
+ readonly internalType: "bytes32";
58
+ readonly name: "encryptedAmountHash";
59
+ readonly type: "bytes32";
60
+ }];
61
+ readonly internalType: "struct FHEToken.ConfidentialPayment";
62
+ readonly name: "p";
63
+ readonly type: "tuple";
64
+ }, {
65
+ readonly internalType: "externalEuint64";
66
+ readonly name: "encryptedAmountInput";
67
+ readonly type: "bytes32";
68
+ }, {
69
+ readonly internalType: "bytes";
70
+ readonly name: "inputProof";
71
+ readonly type: "bytes";
72
+ }, {
73
+ readonly internalType: "bytes";
74
+ readonly name: "sig";
75
+ readonly type: "bytes";
76
+ }];
77
+ readonly name: "confidentialTransferWithAuthorization";
78
+ readonly outputs: readonly [{
79
+ readonly internalType: "euint64";
80
+ readonly name: "transferred";
81
+ readonly type: "bytes32";
82
+ }];
83
+ readonly stateMutability: "nonpayable";
84
+ readonly type: "function";
85
+ }, {
86
+ readonly inputs: readonly [{
87
+ readonly internalType: "address";
88
+ readonly name: "to";
89
+ readonly type: "address";
90
+ }, {
91
+ readonly internalType: "uint256";
92
+ readonly name: "amount";
93
+ readonly type: "uint256";
94
+ }];
95
+ readonly name: "wrap";
96
+ readonly outputs: readonly [];
97
+ readonly stateMutability: "nonpayable";
98
+ readonly type: "function";
99
+ }, {
100
+ readonly inputs: readonly [{
101
+ readonly internalType: "address";
102
+ readonly name: "from";
103
+ readonly type: "address";
104
+ }, {
105
+ readonly internalType: "address";
106
+ readonly name: "to";
107
+ readonly type: "address";
108
+ }, {
109
+ readonly internalType: "bytes32";
110
+ readonly name: "encryptedAmountInput";
111
+ readonly type: "bytes32";
112
+ }, {
113
+ readonly internalType: "bytes";
114
+ readonly name: "inputProof";
115
+ readonly type: "bytes";
116
+ }];
117
+ readonly name: "unwrap";
118
+ readonly outputs: readonly [];
119
+ readonly stateMutability: "nonpayable";
120
+ readonly type: "function";
121
+ }, {
122
+ readonly anonymous: false;
123
+ readonly inputs: readonly [{
124
+ readonly indexed: true;
125
+ readonly internalType: "address";
126
+ readonly name: "holder";
127
+ readonly type: "address";
128
+ }, {
129
+ readonly indexed: true;
130
+ readonly internalType: "address";
131
+ readonly name: "payee";
132
+ readonly type: "address";
133
+ }, {
134
+ readonly indexed: false;
135
+ readonly internalType: "uint256";
136
+ readonly name: "maxClearAmount";
137
+ readonly type: "uint256";
138
+ }, {
139
+ readonly indexed: true;
140
+ readonly internalType: "bytes32";
141
+ readonly name: "resourceHash";
142
+ readonly type: "bytes32";
143
+ }, {
144
+ readonly indexed: false;
145
+ readonly internalType: "bytes32";
146
+ readonly name: "nonce";
147
+ readonly type: "bytes32";
148
+ }, {
149
+ readonly indexed: false;
150
+ readonly internalType: "bytes32";
151
+ readonly name: "transferredAmount";
152
+ readonly type: "bytes32";
153
+ }];
154
+ readonly name: "ConfidentialPaymentExecuted";
155
+ readonly type: "event";
156
+ }, {
157
+ readonly inputs: readonly [{
158
+ readonly internalType: "address";
159
+ readonly name: "";
160
+ readonly type: "address";
161
+ }, {
162
+ readonly internalType: "bytes32";
163
+ readonly name: "";
164
+ readonly type: "bytes32";
165
+ }];
166
+ readonly name: "usedNonces";
167
+ readonly outputs: readonly [{
168
+ readonly internalType: "bool";
169
+ readonly name: "";
170
+ readonly type: "bool";
171
+ }];
172
+ readonly stateMutability: "view";
173
+ readonly type: "function";
174
+ }, {
175
+ readonly inputs: readonly [{
176
+ readonly internalType: "address";
177
+ readonly name: "account";
178
+ readonly type: "address";
179
+ }];
180
+ readonly name: "observer";
181
+ readonly outputs: readonly [{
182
+ readonly internalType: "address";
183
+ readonly name: "";
184
+ readonly type: "address";
185
+ }];
186
+ readonly stateMutability: "view";
187
+ readonly type: "function";
188
+ }, {
189
+ readonly inputs: readonly [{
190
+ readonly internalType: "address";
191
+ readonly name: "account";
192
+ readonly type: "address";
193
+ }, {
194
+ readonly internalType: "address";
195
+ readonly name: "newObserver";
196
+ readonly type: "address";
197
+ }];
198
+ readonly name: "setObserver";
199
+ readonly outputs: readonly [];
200
+ readonly stateMutability: "nonpayable";
201
+ readonly type: "function";
202
+ }];
203
+
204
+ declare const confidentialPaymentTypes: {
205
+ readonly ConfidentialPayment: readonly [{
206
+ readonly name: "holder";
207
+ readonly type: "address";
208
+ }, {
209
+ readonly name: "payee";
210
+ readonly type: "address";
211
+ }, {
212
+ readonly name: "maxClearAmount";
213
+ readonly type: "uint256";
214
+ }, {
215
+ readonly name: "resourceHash";
216
+ readonly type: "bytes32";
217
+ }, {
218
+ readonly name: "validAfter";
219
+ readonly type: "uint48";
220
+ }, {
221
+ readonly name: "validBefore";
222
+ readonly type: "uint48";
223
+ }, {
224
+ readonly name: "nonce";
225
+ readonly type: "bytes32";
226
+ }, {
227
+ readonly name: "encryptedAmountHash";
228
+ readonly type: "bytes32";
229
+ }];
230
+ };
231
+ declare const confidentialErrorCodes: {
232
+ readonly observerNotAuthorized: "observer_not_authorized";
233
+ };
234
+ type ConfidentialErrorCode = (typeof confidentialErrorCodes)[keyof typeof confidentialErrorCodes];
235
+
236
+ declare function createNonce(): `0x${string}`;
237
+ declare function hashEncryptedAmountInput(encryptedAmountInput: `0x${string}`): `0x${string}`;
238
+ declare function normalizeAmount(amount: string | number | bigint): string;
239
+
240
+ interface RelayerInstance {
241
+ createEncryptedInput: (contractAddress: string, senderAddress: string) => {
242
+ add64: (amount: number) => {
243
+ encrypt: () => Promise<{
244
+ handles: Array<string | Uint8Array>;
245
+ inputProof: string | Uint8Array;
246
+ }>;
247
+ };
248
+ };
249
+ generateKeypair: () => {
250
+ publicKey: string;
251
+ privateKey: string;
252
+ };
253
+ createEIP712: (publicKey: string, contractAddresses: string[], startTimestamp: string, durationDays: string) => {
254
+ domain: Record<string, unknown>;
255
+ types: {
256
+ UserDecryptRequestVerification: Array<{
257
+ name: string;
258
+ type: string;
259
+ }>;
260
+ };
261
+ message: Record<string, unknown>;
262
+ };
263
+ userDecrypt: (handles: Array<{
264
+ handle: string;
265
+ contractAddress: string;
266
+ }>, privateKey: string, publicKey: string, signature: string, contractAddresses: string[], address: string, startTimestamp: string, durationDays: string) => Promise<Record<string, bigint> | {
267
+ clearValues?: Record<string, bigint>;
268
+ }>;
269
+ publicDecrypt: (handles: string[]) => Promise<{
270
+ clearValues: Record<string, bigint>;
271
+ decryptionProof: string;
272
+ }>;
273
+ }
274
+ type RelayerSdkModule = {
275
+ createInstance: (config: unknown) => Promise<RelayerInstance>;
276
+ initSDK: (params?: unknown) => Promise<boolean>;
277
+ SepoliaConfig: unknown;
278
+ };
279
+ declare let SepoliaConfig: RelayerSdkModule["SepoliaConfig"] | undefined;
280
+ declare function configureRelayerSdk(sdk: RelayerSdkModule): void;
281
+ declare function getSepoliaConfig(): RelayerSdkModule["SepoliaConfig"];
282
+ type RelayerSigner = {
283
+ address: string;
284
+ signTypedData: ((domain: Record<string, unknown>, types: Record<string, Array<{
285
+ name: string;
286
+ type: string;
287
+ }>>, message: Record<string, unknown>) => Promise<string>) | ((args: {
288
+ domain: Record<string, unknown>;
289
+ types: Record<string, Array<{
290
+ name: string;
291
+ type: string;
292
+ }>>;
293
+ primaryType: string;
294
+ message: Record<string, unknown>;
295
+ }) => Promise<string>);
296
+ };
297
+ declare function createRelayer(config: unknown): Promise<RelayerInstance>;
298
+ declare function initSDK(params?: unknown): Promise<boolean>;
299
+ declare function createEncryptedAmountInput(relayer: RelayerInstance, contractAddress: string, senderAddress: string, amount: number): Promise<{
300
+ handle: `0x${string}`;
301
+ inputProof: `0x${string}`;
302
+ }>;
303
+ declare function decryptEuint64(relayer: RelayerInstance, handle: string, contractAddress: string, signer: RelayerSigner, options?: {
304
+ durationDays?: string;
305
+ startTimestamp?: string;
306
+ }): Promise<bigint>;
307
+ declare function publicDecrypt(relayer: RelayerInstance, handles: string[]): Promise<{
308
+ clearValues: Record<string, bigint>;
309
+ decryptionProof: string;
310
+ }>;
311
+
312
+ type TransferAmount = {
313
+ holder: `0x${string}`;
314
+ payee: `0x${string}`;
315
+ maxClearAmount: bigint;
316
+ resourceHash: `0x${string}`;
317
+ nonce: `0x${string}`;
318
+ handle: `0x${string}`;
319
+ amount?: bigint;
320
+ };
321
+ type TransferQueryOptions = {
322
+ rpcUrl: string;
323
+ tokenAddress: `0x${string}`;
324
+ txHash: `0x${string}`;
325
+ from?: `0x${string}`;
326
+ to?: `0x${string}`;
327
+ relayer: RelayerInstance;
328
+ signer?: RelayerSigner;
329
+ decrypt?: boolean;
330
+ };
331
+ declare function getTransferAmounts(options: TransferQueryOptions): Promise<TransferAmount[]>;
332
+
333
+ type ConfidentialTokenOptions = {
334
+ rpcUrl: string;
335
+ tokenAddress: `0x${string}`;
336
+ relayer: RelayerInstance;
337
+ walletClient: WalletClient;
338
+ signer?: RelayerSigner;
339
+ };
340
+ declare class ConfidentialToken {
341
+ private readonly rpcUrl;
342
+ private readonly tokenAddress;
343
+ private readonly relayer;
344
+ private readonly walletClient;
345
+ private readonly signer?;
346
+ constructor(config: ConfidentialTokenOptions);
347
+ balanceOf(account?: `0x${string}`): Promise<bigint>;
348
+ setObserver(account: `0x${string}`, observer: `0x${string}`): Promise<`0x${string}`>;
349
+ transfer(to: `0x${string}`, amount: number): Promise<`0x${string}`>;
350
+ wrap(to: `0x${string}`, amount: string | number | bigint): Promise<`0x${string}`>;
351
+ unwrap(from: `0x${string}`, to: `0x${string}`, amount: number): Promise<`0x${string}`>;
352
+ }
353
+
354
+ type ConfidentialPaymentAuthorization = {
355
+ holder: `0x${string}`;
356
+ payee: `0x${string}`;
357
+ maxClearAmount: string;
358
+ resourceHash: `0x${string}`;
359
+ validAfter: string;
360
+ validBefore: string;
361
+ nonce: `0x${string}`;
362
+ encryptedAmountHash: `0x${string}`;
363
+ };
364
+ type ConfidentialPaymentPayload = {
365
+ authorization: ConfidentialPaymentAuthorization;
366
+ signature: `0x${string}`;
367
+ encryptedAmountInput: `0x${string}`;
368
+ inputProof: `0x${string}`;
369
+ };
370
+ type ConfidentialRequirementsExtra = {
371
+ eip712: {
372
+ name: string;
373
+ version: string;
374
+ };
375
+ confidential?: {
376
+ maxClearAmount?: string;
377
+ resourceHash?: `0x${string}`;
378
+ batcherAddress?: `0x${string}`;
379
+ };
380
+ };
381
+ type ConfidentialPaymentInput = {
382
+ encryptedAmountInput: `0x${string}`;
383
+ inputProof: `0x${string}`;
384
+ maxClearAmount?: string;
385
+ resourceHash?: `0x${string}`;
386
+ validAfter?: number;
387
+ validBefore?: number;
388
+ nonce?: `0x${string}`;
389
+ };
390
+
391
+ export { type ConfidentialErrorCode, type ConfidentialPaymentAuthorization, type ConfidentialPaymentInput, type ConfidentialPaymentPayload, type ConfidentialRequirementsExtra, ConfidentialToken, type ConfidentialTokenOptions, type RelayerInstance, type RelayerSdkModule, type RelayerSigner, SepoliaConfig, type TransferAmount, type TransferQueryOptions, confidentialErrorCodes, confidentialPaymentTypes, confidentialTokenAbi, configureRelayerSdk, createEncryptedAmountInput, createNonce, createRelayer, decryptEuint64, getSepoliaConfig, getTransferAmounts, hashEncryptedAmountInput, initSDK, normalizeAmount, publicDecrypt };