x402z-shared 0.0.10 → 0.0.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/dist/index.d.mts CHANGED
@@ -119,6 +119,71 @@ declare const confidentialTokenAbi: readonly [{
119
119
  readonly outputs: readonly [];
120
120
  readonly stateMutability: "nonpayable";
121
121
  readonly type: "function";
122
+ }, {
123
+ readonly inputs: readonly [{
124
+ readonly components: readonly [{
125
+ readonly internalType: "address";
126
+ readonly name: "holder";
127
+ readonly type: "address";
128
+ }, {
129
+ readonly internalType: "address";
130
+ readonly name: "to";
131
+ readonly type: "address";
132
+ }, {
133
+ readonly internalType: "uint48";
134
+ readonly name: "validAfter";
135
+ readonly type: "uint48";
136
+ }, {
137
+ readonly internalType: "uint48";
138
+ readonly name: "validBefore";
139
+ readonly type: "uint48";
140
+ }, {
141
+ readonly internalType: "bytes32";
142
+ readonly name: "nonce";
143
+ readonly type: "bytes32";
144
+ }, {
145
+ readonly internalType: "bytes32";
146
+ readonly name: "encryptedAmountHash";
147
+ readonly type: "bytes32";
148
+ }];
149
+ readonly internalType: "struct FHEToken.UnwrapAuthorization";
150
+ readonly name: "p";
151
+ readonly type: "tuple";
152
+ }, {
153
+ readonly internalType: "bytes";
154
+ readonly name: "encryptedAmountInput";
155
+ readonly type: "bytes";
156
+ }, {
157
+ readonly internalType: "bytes";
158
+ readonly name: "inputProof";
159
+ readonly type: "bytes";
160
+ }, {
161
+ readonly internalType: "bytes";
162
+ readonly name: "sig";
163
+ readonly type: "bytes";
164
+ }];
165
+ readonly name: "unwrapWithAuthorization";
166
+ readonly outputs: readonly [];
167
+ readonly stateMutability: "nonpayable";
168
+ readonly type: "function";
169
+ }, {
170
+ readonly inputs: readonly [{
171
+ readonly internalType: "bytes32";
172
+ readonly name: "burntAmount";
173
+ readonly type: "bytes32";
174
+ }, {
175
+ readonly internalType: "uint64";
176
+ readonly name: "burntAmountCleartext";
177
+ readonly type: "uint64";
178
+ }, {
179
+ readonly internalType: "bytes";
180
+ readonly name: "decryptionProof";
181
+ readonly type: "bytes";
182
+ }];
183
+ readonly name: "finalizeUnwrap";
184
+ readonly outputs: readonly [];
185
+ readonly stateMutability: "nonpayable";
186
+ readonly type: "function";
122
187
  }, {
123
188
  readonly anonymous: false;
124
189
  readonly inputs: readonly [{
@@ -291,33 +356,6 @@ type TransferQueryOptions = {
291
356
  };
292
357
  declare function getTransferAmounts(options: TransferQueryOptions): Promise<TransferAmount[]>;
293
358
 
294
- type TokenWriteSigner = RelayerSigner & {
295
- writeContract?: (args: {
296
- address: `0x${string}`;
297
- abi: typeof confidentialTokenAbi;
298
- functionName: "confidentialTransfer" | "wrap" | "unwrap" | "setObserver";
299
- args: readonly unknown[];
300
- }) => Promise<`0x${string}`>;
301
- };
302
- type ConfidentialTokenOptions = {
303
- rpcUrl: string;
304
- tokenAddress: `0x${string}`;
305
- relayer: RelayerInstance;
306
- signer: TokenWriteSigner;
307
- };
308
- declare class ConfidentialToken {
309
- private readonly rpcUrl;
310
- private readonly tokenAddress;
311
- private readonly relayer;
312
- private readonly signer;
313
- constructor(config: ConfidentialTokenOptions);
314
- balanceOf(account?: `0x${string}`): Promise<bigint>;
315
- setObserver(account: `0x${string}`, observer: `0x${string}`): Promise<`0x${string}`>;
316
- transfer(to: `0x${string}`, amount: number): Promise<`0x${string}`>;
317
- wrap(to: `0x${string}`, amount: string | number | bigint): Promise<`0x${string}`>;
318
- unwrap(from: `0x${string}`, to: `0x${string}`, amount: number): Promise<`0x${string}`>;
319
- }
320
-
321
359
  type ConfidentialPaymentAuthorization = {
322
360
  holder: `0x${string}`;
323
361
  payee: `0x${string}`;
@@ -328,6 +366,14 @@ type ConfidentialPaymentAuthorization = {
328
366
  nonce: `0x${string}`;
329
367
  encryptedAmountHash: `0x${string}`;
330
368
  };
369
+ type UnwrapAuthorization = {
370
+ holder: `0x${string}`;
371
+ to: `0x${string}`;
372
+ validAfter: number;
373
+ validBefore: number;
374
+ nonce: `0x${string}`;
375
+ encryptedAmountHash: `0x${string}`;
376
+ };
331
377
  type ConfidentialPaymentPayload = {
332
378
  authorization: ConfidentialPaymentAuthorization;
333
379
  signature: `0x${string}`;
@@ -355,4 +401,33 @@ type ConfidentialPaymentInput = {
355
401
  nonce?: `0x${string}`;
356
402
  };
357
403
 
358
- export { type ConfidentialErrorCode, type ConfidentialPaymentAuthorization, type ConfidentialPaymentInput, type ConfidentialPaymentPayload, type ConfidentialRequirementsExtra, ConfidentialToken, type ConfidentialTokenOptions, type RelayerInstance, type RelayerSigner, type TransferAmount, type TransferQueryOptions, confidentialErrorCodes, confidentialPaymentTypes, confidentialTokenAbi, createEncryptedAmountInput, createNonce, createRelayer, decryptEuint64, getTransferAmounts, hashEncryptedAmountInput, normalizeAmount, publicDecrypt };
404
+ type TokenWriteSigner = RelayerSigner & {
405
+ writeContract?: (args: {
406
+ address: `0x${string}`;
407
+ abi: typeof confidentialTokenAbi;
408
+ functionName: "confidentialTransfer" | "wrap" | "unwrap" | "setObserver" | "unwrapWithAuthorization" | "finalizeUnwrap";
409
+ args: readonly unknown[];
410
+ }) => Promise<`0x${string}`>;
411
+ };
412
+ type ConfidentialTokenOptions = {
413
+ rpcUrl: string;
414
+ tokenAddress: `0x${string}`;
415
+ relayer: RelayerInstance;
416
+ signer: TokenWriteSigner;
417
+ };
418
+ declare class ConfidentialToken {
419
+ private readonly rpcUrl;
420
+ private readonly tokenAddress;
421
+ private readonly relayer;
422
+ private readonly signer;
423
+ constructor(config: ConfidentialTokenOptions);
424
+ balanceOf(account?: `0x${string}`): Promise<bigint>;
425
+ setObserver(account: `0x${string}`, observer: `0x${string}`): Promise<`0x${string}`>;
426
+ transfer(to: `0x${string}`, amount: number): Promise<`0x${string}`>;
427
+ wrap(to: `0x${string}`, amount: string | number | bigint): Promise<`0x${string}`>;
428
+ unwrap(from: `0x${string}`, to: `0x${string}`, amount: number): Promise<`0x${string}`>;
429
+ unwrapWithAuthorization(authorization: UnwrapAuthorization, encryptedAmountInput: `0x${string}`, inputProof: `0x${string}`, signature: `0x${string}`): Promise<`0x${string}`>;
430
+ finalizeUnwrap(burntAmount: `0x${string}`, burntAmountCleartext: string | number | bigint, decryptionProof: `0x${string}`): Promise<`0x${string}`>;
431
+ }
432
+
433
+ export { type ConfidentialErrorCode, type ConfidentialPaymentAuthorization, type ConfidentialPaymentInput, type ConfidentialPaymentPayload, type ConfidentialRequirementsExtra, ConfidentialToken, type ConfidentialTokenOptions, type RelayerInstance, type RelayerSigner, type TransferAmount, type TransferQueryOptions, type UnwrapAuthorization, confidentialErrorCodes, confidentialPaymentTypes, confidentialTokenAbi, createEncryptedAmountInput, createNonce, createRelayer, decryptEuint64, getTransferAmounts, hashEncryptedAmountInput, normalizeAmount, publicDecrypt };
package/dist/index.d.ts CHANGED
@@ -119,6 +119,71 @@ declare const confidentialTokenAbi: readonly [{
119
119
  readonly outputs: readonly [];
120
120
  readonly stateMutability: "nonpayable";
121
121
  readonly type: "function";
122
+ }, {
123
+ readonly inputs: readonly [{
124
+ readonly components: readonly [{
125
+ readonly internalType: "address";
126
+ readonly name: "holder";
127
+ readonly type: "address";
128
+ }, {
129
+ readonly internalType: "address";
130
+ readonly name: "to";
131
+ readonly type: "address";
132
+ }, {
133
+ readonly internalType: "uint48";
134
+ readonly name: "validAfter";
135
+ readonly type: "uint48";
136
+ }, {
137
+ readonly internalType: "uint48";
138
+ readonly name: "validBefore";
139
+ readonly type: "uint48";
140
+ }, {
141
+ readonly internalType: "bytes32";
142
+ readonly name: "nonce";
143
+ readonly type: "bytes32";
144
+ }, {
145
+ readonly internalType: "bytes32";
146
+ readonly name: "encryptedAmountHash";
147
+ readonly type: "bytes32";
148
+ }];
149
+ readonly internalType: "struct FHEToken.UnwrapAuthorization";
150
+ readonly name: "p";
151
+ readonly type: "tuple";
152
+ }, {
153
+ readonly internalType: "bytes";
154
+ readonly name: "encryptedAmountInput";
155
+ readonly type: "bytes";
156
+ }, {
157
+ readonly internalType: "bytes";
158
+ readonly name: "inputProof";
159
+ readonly type: "bytes";
160
+ }, {
161
+ readonly internalType: "bytes";
162
+ readonly name: "sig";
163
+ readonly type: "bytes";
164
+ }];
165
+ readonly name: "unwrapWithAuthorization";
166
+ readonly outputs: readonly [];
167
+ readonly stateMutability: "nonpayable";
168
+ readonly type: "function";
169
+ }, {
170
+ readonly inputs: readonly [{
171
+ readonly internalType: "bytes32";
172
+ readonly name: "burntAmount";
173
+ readonly type: "bytes32";
174
+ }, {
175
+ readonly internalType: "uint64";
176
+ readonly name: "burntAmountCleartext";
177
+ readonly type: "uint64";
178
+ }, {
179
+ readonly internalType: "bytes";
180
+ readonly name: "decryptionProof";
181
+ readonly type: "bytes";
182
+ }];
183
+ readonly name: "finalizeUnwrap";
184
+ readonly outputs: readonly [];
185
+ readonly stateMutability: "nonpayable";
186
+ readonly type: "function";
122
187
  }, {
123
188
  readonly anonymous: false;
124
189
  readonly inputs: readonly [{
@@ -291,33 +356,6 @@ type TransferQueryOptions = {
291
356
  };
292
357
  declare function getTransferAmounts(options: TransferQueryOptions): Promise<TransferAmount[]>;
293
358
 
294
- type TokenWriteSigner = RelayerSigner & {
295
- writeContract?: (args: {
296
- address: `0x${string}`;
297
- abi: typeof confidentialTokenAbi;
298
- functionName: "confidentialTransfer" | "wrap" | "unwrap" | "setObserver";
299
- args: readonly unknown[];
300
- }) => Promise<`0x${string}`>;
301
- };
302
- type ConfidentialTokenOptions = {
303
- rpcUrl: string;
304
- tokenAddress: `0x${string}`;
305
- relayer: RelayerInstance;
306
- signer: TokenWriteSigner;
307
- };
308
- declare class ConfidentialToken {
309
- private readonly rpcUrl;
310
- private readonly tokenAddress;
311
- private readonly relayer;
312
- private readonly signer;
313
- constructor(config: ConfidentialTokenOptions);
314
- balanceOf(account?: `0x${string}`): Promise<bigint>;
315
- setObserver(account: `0x${string}`, observer: `0x${string}`): Promise<`0x${string}`>;
316
- transfer(to: `0x${string}`, amount: number): Promise<`0x${string}`>;
317
- wrap(to: `0x${string}`, amount: string | number | bigint): Promise<`0x${string}`>;
318
- unwrap(from: `0x${string}`, to: `0x${string}`, amount: number): Promise<`0x${string}`>;
319
- }
320
-
321
359
  type ConfidentialPaymentAuthorization = {
322
360
  holder: `0x${string}`;
323
361
  payee: `0x${string}`;
@@ -328,6 +366,14 @@ type ConfidentialPaymentAuthorization = {
328
366
  nonce: `0x${string}`;
329
367
  encryptedAmountHash: `0x${string}`;
330
368
  };
369
+ type UnwrapAuthorization = {
370
+ holder: `0x${string}`;
371
+ to: `0x${string}`;
372
+ validAfter: number;
373
+ validBefore: number;
374
+ nonce: `0x${string}`;
375
+ encryptedAmountHash: `0x${string}`;
376
+ };
331
377
  type ConfidentialPaymentPayload = {
332
378
  authorization: ConfidentialPaymentAuthorization;
333
379
  signature: `0x${string}`;
@@ -355,4 +401,33 @@ type ConfidentialPaymentInput = {
355
401
  nonce?: `0x${string}`;
356
402
  };
357
403
 
358
- export { type ConfidentialErrorCode, type ConfidentialPaymentAuthorization, type ConfidentialPaymentInput, type ConfidentialPaymentPayload, type ConfidentialRequirementsExtra, ConfidentialToken, type ConfidentialTokenOptions, type RelayerInstance, type RelayerSigner, type TransferAmount, type TransferQueryOptions, confidentialErrorCodes, confidentialPaymentTypes, confidentialTokenAbi, createEncryptedAmountInput, createNonce, createRelayer, decryptEuint64, getTransferAmounts, hashEncryptedAmountInput, normalizeAmount, publicDecrypt };
404
+ type TokenWriteSigner = RelayerSigner & {
405
+ writeContract?: (args: {
406
+ address: `0x${string}`;
407
+ abi: typeof confidentialTokenAbi;
408
+ functionName: "confidentialTransfer" | "wrap" | "unwrap" | "setObserver" | "unwrapWithAuthorization" | "finalizeUnwrap";
409
+ args: readonly unknown[];
410
+ }) => Promise<`0x${string}`>;
411
+ };
412
+ type ConfidentialTokenOptions = {
413
+ rpcUrl: string;
414
+ tokenAddress: `0x${string}`;
415
+ relayer: RelayerInstance;
416
+ signer: TokenWriteSigner;
417
+ };
418
+ declare class ConfidentialToken {
419
+ private readonly rpcUrl;
420
+ private readonly tokenAddress;
421
+ private readonly relayer;
422
+ private readonly signer;
423
+ constructor(config: ConfidentialTokenOptions);
424
+ balanceOf(account?: `0x${string}`): Promise<bigint>;
425
+ setObserver(account: `0x${string}`, observer: `0x${string}`): Promise<`0x${string}`>;
426
+ transfer(to: `0x${string}`, amount: number): Promise<`0x${string}`>;
427
+ wrap(to: `0x${string}`, amount: string | number | bigint): Promise<`0x${string}`>;
428
+ unwrap(from: `0x${string}`, to: `0x${string}`, amount: number): Promise<`0x${string}`>;
429
+ unwrapWithAuthorization(authorization: UnwrapAuthorization, encryptedAmountInput: `0x${string}`, inputProof: `0x${string}`, signature: `0x${string}`): Promise<`0x${string}`>;
430
+ finalizeUnwrap(burntAmount: `0x${string}`, burntAmountCleartext: string | number | bigint, decryptionProof: `0x${string}`): Promise<`0x${string}`>;
431
+ }
432
+
433
+ export { type ConfidentialErrorCode, type ConfidentialPaymentAuthorization, type ConfidentialPaymentInput, type ConfidentialPaymentPayload, type ConfidentialRequirementsExtra, ConfidentialToken, type ConfidentialTokenOptions, type RelayerInstance, type RelayerSigner, type TransferAmount, type TransferQueryOptions, type UnwrapAuthorization, confidentialErrorCodes, confidentialPaymentTypes, confidentialTokenAbi, createEncryptedAmountInput, createNonce, createRelayer, decryptEuint64, getTransferAmounts, hashEncryptedAmountInput, normalizeAmount, publicDecrypt };
package/dist/index.js CHANGED
@@ -97,6 +97,41 @@ var confidentialTokenAbi = [
97
97
  stateMutability: "nonpayable",
98
98
  type: "function"
99
99
  },
100
+ {
101
+ inputs: [
102
+ {
103
+ components: [
104
+ { internalType: "address", name: "holder", type: "address" },
105
+ { internalType: "address", name: "to", type: "address" },
106
+ { internalType: "uint48", name: "validAfter", type: "uint48" },
107
+ { internalType: "uint48", name: "validBefore", type: "uint48" },
108
+ { internalType: "bytes32", name: "nonce", type: "bytes32" },
109
+ { internalType: "bytes32", name: "encryptedAmountHash", type: "bytes32" }
110
+ ],
111
+ internalType: "struct FHEToken.UnwrapAuthorization",
112
+ name: "p",
113
+ type: "tuple"
114
+ },
115
+ { internalType: "bytes", name: "encryptedAmountInput", type: "bytes" },
116
+ { internalType: "bytes", name: "inputProof", type: "bytes" },
117
+ { internalType: "bytes", name: "sig", type: "bytes" }
118
+ ],
119
+ name: "unwrapWithAuthorization",
120
+ outputs: [],
121
+ stateMutability: "nonpayable",
122
+ type: "function"
123
+ },
124
+ {
125
+ inputs: [
126
+ { internalType: "bytes32", name: "burntAmount", type: "bytes32" },
127
+ { internalType: "uint64", name: "burntAmountCleartext", type: "uint64" },
128
+ { internalType: "bytes", name: "decryptionProof", type: "bytes" }
129
+ ],
130
+ name: "finalizeUnwrap",
131
+ outputs: [],
132
+ stateMutability: "nonpayable",
133
+ type: "function"
134
+ },
100
135
  {
101
136
  anonymous: false,
102
137
  inputs: [
@@ -520,6 +555,41 @@ var ConfidentialToken = class {
520
555
  args: [fromAddress, toAddress, handle, inputProof]
521
556
  });
522
557
  }
558
+ async unwrapWithAuthorization(authorization, encryptedAmountInput, inputProof, signature) {
559
+ const tokenAddress = assertAddress(this.tokenAddress, "token address");
560
+ const holder = assertAddress(authorization.holder, "holder address");
561
+ const to = assertAddress(authorization.to, "to address");
562
+ const writeContract = requireWriteContract(this.signer);
563
+ return writeContract({
564
+ address: tokenAddress,
565
+ abi: confidentialTokenAbi,
566
+ functionName: "unwrapWithAuthorization",
567
+ args: [
568
+ {
569
+ holder,
570
+ to,
571
+ validAfter: authorization.validAfter,
572
+ validBefore: authorization.validBefore,
573
+ nonce: authorization.nonce,
574
+ encryptedAmountHash: authorization.encryptedAmountHash
575
+ },
576
+ encryptedAmountInput,
577
+ inputProof,
578
+ signature
579
+ ]
580
+ });
581
+ }
582
+ async finalizeUnwrap(burntAmount, burntAmountCleartext, decryptionProof) {
583
+ const tokenAddress = assertAddress(this.tokenAddress, "token address");
584
+ const normalizedAmount = BigInt(normalizeAmount(burntAmountCleartext));
585
+ const writeContract = requireWriteContract(this.signer);
586
+ return writeContract({
587
+ address: tokenAddress,
588
+ abi: confidentialTokenAbi,
589
+ functionName: "finalizeUnwrap",
590
+ args: [burntAmount, normalizedAmount, decryptionProof]
591
+ });
592
+ }
523
593
  };
524
594
  // Annotate the CommonJS export names for ESM import in node:
525
595
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -59,6 +59,41 @@ var confidentialTokenAbi = [
59
59
  stateMutability: "nonpayable",
60
60
  type: "function"
61
61
  },
62
+ {
63
+ inputs: [
64
+ {
65
+ components: [
66
+ { internalType: "address", name: "holder", type: "address" },
67
+ { internalType: "address", name: "to", type: "address" },
68
+ { internalType: "uint48", name: "validAfter", type: "uint48" },
69
+ { internalType: "uint48", name: "validBefore", type: "uint48" },
70
+ { internalType: "bytes32", name: "nonce", type: "bytes32" },
71
+ { internalType: "bytes32", name: "encryptedAmountHash", type: "bytes32" }
72
+ ],
73
+ internalType: "struct FHEToken.UnwrapAuthorization",
74
+ name: "p",
75
+ type: "tuple"
76
+ },
77
+ { internalType: "bytes", name: "encryptedAmountInput", type: "bytes" },
78
+ { internalType: "bytes", name: "inputProof", type: "bytes" },
79
+ { internalType: "bytes", name: "sig", type: "bytes" }
80
+ ],
81
+ name: "unwrapWithAuthorization",
82
+ outputs: [],
83
+ stateMutability: "nonpayable",
84
+ type: "function"
85
+ },
86
+ {
87
+ inputs: [
88
+ { internalType: "bytes32", name: "burntAmount", type: "bytes32" },
89
+ { internalType: "uint64", name: "burntAmountCleartext", type: "uint64" },
90
+ { internalType: "bytes", name: "decryptionProof", type: "bytes" }
91
+ ],
92
+ name: "finalizeUnwrap",
93
+ outputs: [],
94
+ stateMutability: "nonpayable",
95
+ type: "function"
96
+ },
62
97
  {
63
98
  anonymous: false,
64
99
  inputs: [
@@ -482,6 +517,41 @@ var ConfidentialToken = class {
482
517
  args: [fromAddress, toAddress, handle, inputProof]
483
518
  });
484
519
  }
520
+ async unwrapWithAuthorization(authorization, encryptedAmountInput, inputProof, signature) {
521
+ const tokenAddress = assertAddress(this.tokenAddress, "token address");
522
+ const holder = assertAddress(authorization.holder, "holder address");
523
+ const to = assertAddress(authorization.to, "to address");
524
+ const writeContract = requireWriteContract(this.signer);
525
+ return writeContract({
526
+ address: tokenAddress,
527
+ abi: confidentialTokenAbi,
528
+ functionName: "unwrapWithAuthorization",
529
+ args: [
530
+ {
531
+ holder,
532
+ to,
533
+ validAfter: authorization.validAfter,
534
+ validBefore: authorization.validBefore,
535
+ nonce: authorization.nonce,
536
+ encryptedAmountHash: authorization.encryptedAmountHash
537
+ },
538
+ encryptedAmountInput,
539
+ inputProof,
540
+ signature
541
+ ]
542
+ });
543
+ }
544
+ async finalizeUnwrap(burntAmount, burntAmountCleartext, decryptionProof) {
545
+ const tokenAddress = assertAddress(this.tokenAddress, "token address");
546
+ const normalizedAmount = BigInt(normalizeAmount(burntAmountCleartext));
547
+ const writeContract = requireWriteContract(this.signer);
548
+ return writeContract({
549
+ address: tokenAddress,
550
+ abi: confidentialTokenAbi,
551
+ functionName: "finalizeUnwrap",
552
+ args: [burntAmount, normalizedAmount, decryptionProof]
553
+ });
554
+ }
485
555
  };
486
556
  export {
487
557
  ConfidentialToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x402z-shared",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",