x402z-shared 0.0.10 → 0.0.13
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 +192 -28
- package/dist/index.d.ts +192 -28
- package/dist/index.js +115 -0
- package/dist/index.mjs +115 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -119,6 +119,103 @@ 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 internalType: "address";
|
|
125
|
+
readonly name: "from";
|
|
126
|
+
readonly type: "address";
|
|
127
|
+
}, {
|
|
128
|
+
readonly internalType: "address";
|
|
129
|
+
readonly name: "to";
|
|
130
|
+
readonly type: "address";
|
|
131
|
+
}, {
|
|
132
|
+
readonly internalType: "euint64";
|
|
133
|
+
readonly name: "amount";
|
|
134
|
+
readonly type: "bytes32";
|
|
135
|
+
}];
|
|
136
|
+
readonly name: "unwrap";
|
|
137
|
+
readonly outputs: readonly [];
|
|
138
|
+
readonly stateMutability: "nonpayable";
|
|
139
|
+
readonly type: "function";
|
|
140
|
+
}, {
|
|
141
|
+
readonly inputs: readonly [{
|
|
142
|
+
readonly components: readonly [{
|
|
143
|
+
readonly internalType: "address";
|
|
144
|
+
readonly name: "holder";
|
|
145
|
+
readonly type: "address";
|
|
146
|
+
}, {
|
|
147
|
+
readonly internalType: "address";
|
|
148
|
+
readonly name: "to";
|
|
149
|
+
readonly type: "address";
|
|
150
|
+
}, {
|
|
151
|
+
readonly internalType: "uint48";
|
|
152
|
+
readonly name: "validAfter";
|
|
153
|
+
readonly type: "uint48";
|
|
154
|
+
}, {
|
|
155
|
+
readonly internalType: "uint48";
|
|
156
|
+
readonly name: "validBefore";
|
|
157
|
+
readonly type: "uint48";
|
|
158
|
+
}, {
|
|
159
|
+
readonly internalType: "bytes32";
|
|
160
|
+
readonly name: "nonce";
|
|
161
|
+
readonly type: "bytes32";
|
|
162
|
+
}, {
|
|
163
|
+
readonly internalType: "bytes32";
|
|
164
|
+
readonly name: "encryptedAmountHash";
|
|
165
|
+
readonly type: "bytes32";
|
|
166
|
+
}];
|
|
167
|
+
readonly internalType: "struct FHEToken.UnwrapAuthorization";
|
|
168
|
+
readonly name: "p";
|
|
169
|
+
readonly type: "tuple";
|
|
170
|
+
}, {
|
|
171
|
+
readonly internalType: "bytes";
|
|
172
|
+
readonly name: "encryptedAmountInput";
|
|
173
|
+
readonly type: "bytes";
|
|
174
|
+
}, {
|
|
175
|
+
readonly internalType: "bytes";
|
|
176
|
+
readonly name: "inputProof";
|
|
177
|
+
readonly type: "bytes";
|
|
178
|
+
}, {
|
|
179
|
+
readonly internalType: "bytes";
|
|
180
|
+
readonly name: "sig";
|
|
181
|
+
readonly type: "bytes";
|
|
182
|
+
}];
|
|
183
|
+
readonly name: "unwrapWithAuthorization";
|
|
184
|
+
readonly outputs: readonly [];
|
|
185
|
+
readonly stateMutability: "nonpayable";
|
|
186
|
+
readonly type: "function";
|
|
187
|
+
}, {
|
|
188
|
+
readonly inputs: readonly [{
|
|
189
|
+
readonly internalType: "bytes32";
|
|
190
|
+
readonly name: "burntAmount";
|
|
191
|
+
readonly type: "bytes32";
|
|
192
|
+
}, {
|
|
193
|
+
readonly internalType: "uint64";
|
|
194
|
+
readonly name: "burntAmountCleartext";
|
|
195
|
+
readonly type: "uint64";
|
|
196
|
+
}, {
|
|
197
|
+
readonly internalType: "bytes";
|
|
198
|
+
readonly name: "decryptionProof";
|
|
199
|
+
readonly type: "bytes";
|
|
200
|
+
}];
|
|
201
|
+
readonly name: "finalizeUnwrap";
|
|
202
|
+
readonly outputs: readonly [];
|
|
203
|
+
readonly stateMutability: "nonpayable";
|
|
204
|
+
readonly type: "function";
|
|
205
|
+
}, {
|
|
206
|
+
readonly inputs: readonly [{
|
|
207
|
+
readonly internalType: "address";
|
|
208
|
+
readonly name: "account";
|
|
209
|
+
readonly type: "address";
|
|
210
|
+
}];
|
|
211
|
+
readonly name: "confidentialBalanceOf";
|
|
212
|
+
readonly outputs: readonly [{
|
|
213
|
+
readonly internalType: "bytes32";
|
|
214
|
+
readonly name: "";
|
|
215
|
+
readonly type: "bytes32";
|
|
216
|
+
}];
|
|
217
|
+
readonly stateMutability: "view";
|
|
218
|
+
readonly type: "function";
|
|
122
219
|
}, {
|
|
123
220
|
readonly anonymous: false;
|
|
124
221
|
readonly inputs: readonly [{
|
|
@@ -154,6 +251,63 @@ declare const confidentialTokenAbi: readonly [{
|
|
|
154
251
|
}];
|
|
155
252
|
readonly name: "ConfidentialPaymentExecuted";
|
|
156
253
|
readonly type: "event";
|
|
254
|
+
}, {
|
|
255
|
+
readonly inputs: readonly [{
|
|
256
|
+
readonly indexed: true;
|
|
257
|
+
readonly internalType: "address";
|
|
258
|
+
readonly name: "receiver";
|
|
259
|
+
readonly type: "address";
|
|
260
|
+
}, {
|
|
261
|
+
readonly indexed: false;
|
|
262
|
+
readonly internalType: "bytes32";
|
|
263
|
+
readonly name: "encryptedAmount";
|
|
264
|
+
readonly type: "bytes32";
|
|
265
|
+
}, {
|
|
266
|
+
readonly indexed: false;
|
|
267
|
+
readonly internalType: "uint64";
|
|
268
|
+
readonly name: "cleartextAmount";
|
|
269
|
+
readonly type: "uint64";
|
|
270
|
+
}];
|
|
271
|
+
readonly name: "UnwrapFinalized";
|
|
272
|
+
readonly type: "event";
|
|
273
|
+
}, {
|
|
274
|
+
readonly inputs: readonly [{
|
|
275
|
+
readonly indexed: true;
|
|
276
|
+
readonly internalType: "address";
|
|
277
|
+
readonly name: "receiver";
|
|
278
|
+
readonly type: "address";
|
|
279
|
+
}, {
|
|
280
|
+
readonly indexed: false;
|
|
281
|
+
readonly internalType: "bytes32";
|
|
282
|
+
readonly name: "amount";
|
|
283
|
+
readonly type: "bytes32";
|
|
284
|
+
}];
|
|
285
|
+
readonly name: "UnwrapRequested";
|
|
286
|
+
readonly type: "event";
|
|
287
|
+
}, {
|
|
288
|
+
readonly inputs: readonly [{
|
|
289
|
+
readonly indexed: true;
|
|
290
|
+
readonly internalType: "address";
|
|
291
|
+
readonly name: "holder";
|
|
292
|
+
readonly type: "address";
|
|
293
|
+
}, {
|
|
294
|
+
readonly indexed: true;
|
|
295
|
+
readonly internalType: "address";
|
|
296
|
+
readonly name: "to";
|
|
297
|
+
readonly type: "address";
|
|
298
|
+
}, {
|
|
299
|
+
readonly indexed: false;
|
|
300
|
+
readonly internalType: "bytes32";
|
|
301
|
+
readonly name: "nonce";
|
|
302
|
+
readonly type: "bytes32";
|
|
303
|
+
}, {
|
|
304
|
+
readonly indexed: false;
|
|
305
|
+
readonly internalType: "bytes32";
|
|
306
|
+
readonly name: "encryptedAmountHandle";
|
|
307
|
+
readonly type: "bytes32";
|
|
308
|
+
}];
|
|
309
|
+
readonly name: "UnwrapWithAuthorizationExecuted";
|
|
310
|
+
readonly type: "event";
|
|
157
311
|
}, {
|
|
158
312
|
readonly inputs: readonly [{
|
|
159
313
|
readonly internalType: "address";
|
|
@@ -291,33 +445,6 @@ type TransferQueryOptions = {
|
|
|
291
445
|
};
|
|
292
446
|
declare function getTransferAmounts(options: TransferQueryOptions): Promise<TransferAmount[]>;
|
|
293
447
|
|
|
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
448
|
type ConfidentialPaymentAuthorization = {
|
|
322
449
|
holder: `0x${string}`;
|
|
323
450
|
payee: `0x${string}`;
|
|
@@ -328,6 +455,14 @@ type ConfidentialPaymentAuthorization = {
|
|
|
328
455
|
nonce: `0x${string}`;
|
|
329
456
|
encryptedAmountHash: `0x${string}`;
|
|
330
457
|
};
|
|
458
|
+
type UnwrapAuthorization = {
|
|
459
|
+
holder: `0x${string}`;
|
|
460
|
+
to: `0x${string}`;
|
|
461
|
+
validAfter: number;
|
|
462
|
+
validBefore: number;
|
|
463
|
+
nonce: `0x${string}`;
|
|
464
|
+
encryptedAmountHash: `0x${string}`;
|
|
465
|
+
};
|
|
331
466
|
type ConfidentialPaymentPayload = {
|
|
332
467
|
authorization: ConfidentialPaymentAuthorization;
|
|
333
468
|
signature: `0x${string}`;
|
|
@@ -355,4 +490,33 @@ type ConfidentialPaymentInput = {
|
|
|
355
490
|
nonce?: `0x${string}`;
|
|
356
491
|
};
|
|
357
492
|
|
|
358
|
-
|
|
493
|
+
type TokenWriteSigner = RelayerSigner & {
|
|
494
|
+
writeContract?: (args: {
|
|
495
|
+
address: `0x${string}`;
|
|
496
|
+
abi: typeof confidentialTokenAbi;
|
|
497
|
+
functionName: "confidentialTransfer" | "wrap" | "unwrap" | "setObserver" | "unwrapWithAuthorization" | "finalizeUnwrap";
|
|
498
|
+
args: readonly unknown[];
|
|
499
|
+
}) => Promise<`0x${string}`>;
|
|
500
|
+
};
|
|
501
|
+
type ConfidentialTokenOptions = {
|
|
502
|
+
rpcUrl: string;
|
|
503
|
+
tokenAddress: `0x${string}`;
|
|
504
|
+
relayer: RelayerInstance;
|
|
505
|
+
signer: TokenWriteSigner;
|
|
506
|
+
};
|
|
507
|
+
declare class ConfidentialToken {
|
|
508
|
+
private readonly rpcUrl;
|
|
509
|
+
private readonly tokenAddress;
|
|
510
|
+
private readonly relayer;
|
|
511
|
+
private readonly signer;
|
|
512
|
+
constructor(config: ConfidentialTokenOptions);
|
|
513
|
+
balanceOf(account?: `0x${string}`): Promise<bigint>;
|
|
514
|
+
setObserver(account: `0x${string}`, observer: `0x${string}`): Promise<`0x${string}`>;
|
|
515
|
+
transfer(to: `0x${string}`, amount: number): Promise<`0x${string}`>;
|
|
516
|
+
wrap(to: `0x${string}`, amount: string | number | bigint): Promise<`0x${string}`>;
|
|
517
|
+
unwrap(from: `0x${string}`, to: `0x${string}`, amount: number): Promise<`0x${string}`>;
|
|
518
|
+
unwrapWithAuthorization(authorization: UnwrapAuthorization, encryptedAmountInput: `0x${string}`, inputProof: `0x${string}`, signature: `0x${string}`): Promise<`0x${string}`>;
|
|
519
|
+
finalizeUnwrap(burntAmount: `0x${string}`, burntAmountCleartext: string | number | bigint, decryptionProof: `0x${string}`): Promise<`0x${string}`>;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
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,103 @@ 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 internalType: "address";
|
|
125
|
+
readonly name: "from";
|
|
126
|
+
readonly type: "address";
|
|
127
|
+
}, {
|
|
128
|
+
readonly internalType: "address";
|
|
129
|
+
readonly name: "to";
|
|
130
|
+
readonly type: "address";
|
|
131
|
+
}, {
|
|
132
|
+
readonly internalType: "euint64";
|
|
133
|
+
readonly name: "amount";
|
|
134
|
+
readonly type: "bytes32";
|
|
135
|
+
}];
|
|
136
|
+
readonly name: "unwrap";
|
|
137
|
+
readonly outputs: readonly [];
|
|
138
|
+
readonly stateMutability: "nonpayable";
|
|
139
|
+
readonly type: "function";
|
|
140
|
+
}, {
|
|
141
|
+
readonly inputs: readonly [{
|
|
142
|
+
readonly components: readonly [{
|
|
143
|
+
readonly internalType: "address";
|
|
144
|
+
readonly name: "holder";
|
|
145
|
+
readonly type: "address";
|
|
146
|
+
}, {
|
|
147
|
+
readonly internalType: "address";
|
|
148
|
+
readonly name: "to";
|
|
149
|
+
readonly type: "address";
|
|
150
|
+
}, {
|
|
151
|
+
readonly internalType: "uint48";
|
|
152
|
+
readonly name: "validAfter";
|
|
153
|
+
readonly type: "uint48";
|
|
154
|
+
}, {
|
|
155
|
+
readonly internalType: "uint48";
|
|
156
|
+
readonly name: "validBefore";
|
|
157
|
+
readonly type: "uint48";
|
|
158
|
+
}, {
|
|
159
|
+
readonly internalType: "bytes32";
|
|
160
|
+
readonly name: "nonce";
|
|
161
|
+
readonly type: "bytes32";
|
|
162
|
+
}, {
|
|
163
|
+
readonly internalType: "bytes32";
|
|
164
|
+
readonly name: "encryptedAmountHash";
|
|
165
|
+
readonly type: "bytes32";
|
|
166
|
+
}];
|
|
167
|
+
readonly internalType: "struct FHEToken.UnwrapAuthorization";
|
|
168
|
+
readonly name: "p";
|
|
169
|
+
readonly type: "tuple";
|
|
170
|
+
}, {
|
|
171
|
+
readonly internalType: "bytes";
|
|
172
|
+
readonly name: "encryptedAmountInput";
|
|
173
|
+
readonly type: "bytes";
|
|
174
|
+
}, {
|
|
175
|
+
readonly internalType: "bytes";
|
|
176
|
+
readonly name: "inputProof";
|
|
177
|
+
readonly type: "bytes";
|
|
178
|
+
}, {
|
|
179
|
+
readonly internalType: "bytes";
|
|
180
|
+
readonly name: "sig";
|
|
181
|
+
readonly type: "bytes";
|
|
182
|
+
}];
|
|
183
|
+
readonly name: "unwrapWithAuthorization";
|
|
184
|
+
readonly outputs: readonly [];
|
|
185
|
+
readonly stateMutability: "nonpayable";
|
|
186
|
+
readonly type: "function";
|
|
187
|
+
}, {
|
|
188
|
+
readonly inputs: readonly [{
|
|
189
|
+
readonly internalType: "bytes32";
|
|
190
|
+
readonly name: "burntAmount";
|
|
191
|
+
readonly type: "bytes32";
|
|
192
|
+
}, {
|
|
193
|
+
readonly internalType: "uint64";
|
|
194
|
+
readonly name: "burntAmountCleartext";
|
|
195
|
+
readonly type: "uint64";
|
|
196
|
+
}, {
|
|
197
|
+
readonly internalType: "bytes";
|
|
198
|
+
readonly name: "decryptionProof";
|
|
199
|
+
readonly type: "bytes";
|
|
200
|
+
}];
|
|
201
|
+
readonly name: "finalizeUnwrap";
|
|
202
|
+
readonly outputs: readonly [];
|
|
203
|
+
readonly stateMutability: "nonpayable";
|
|
204
|
+
readonly type: "function";
|
|
205
|
+
}, {
|
|
206
|
+
readonly inputs: readonly [{
|
|
207
|
+
readonly internalType: "address";
|
|
208
|
+
readonly name: "account";
|
|
209
|
+
readonly type: "address";
|
|
210
|
+
}];
|
|
211
|
+
readonly name: "confidentialBalanceOf";
|
|
212
|
+
readonly outputs: readonly [{
|
|
213
|
+
readonly internalType: "bytes32";
|
|
214
|
+
readonly name: "";
|
|
215
|
+
readonly type: "bytes32";
|
|
216
|
+
}];
|
|
217
|
+
readonly stateMutability: "view";
|
|
218
|
+
readonly type: "function";
|
|
122
219
|
}, {
|
|
123
220
|
readonly anonymous: false;
|
|
124
221
|
readonly inputs: readonly [{
|
|
@@ -154,6 +251,63 @@ declare const confidentialTokenAbi: readonly [{
|
|
|
154
251
|
}];
|
|
155
252
|
readonly name: "ConfidentialPaymentExecuted";
|
|
156
253
|
readonly type: "event";
|
|
254
|
+
}, {
|
|
255
|
+
readonly inputs: readonly [{
|
|
256
|
+
readonly indexed: true;
|
|
257
|
+
readonly internalType: "address";
|
|
258
|
+
readonly name: "receiver";
|
|
259
|
+
readonly type: "address";
|
|
260
|
+
}, {
|
|
261
|
+
readonly indexed: false;
|
|
262
|
+
readonly internalType: "bytes32";
|
|
263
|
+
readonly name: "encryptedAmount";
|
|
264
|
+
readonly type: "bytes32";
|
|
265
|
+
}, {
|
|
266
|
+
readonly indexed: false;
|
|
267
|
+
readonly internalType: "uint64";
|
|
268
|
+
readonly name: "cleartextAmount";
|
|
269
|
+
readonly type: "uint64";
|
|
270
|
+
}];
|
|
271
|
+
readonly name: "UnwrapFinalized";
|
|
272
|
+
readonly type: "event";
|
|
273
|
+
}, {
|
|
274
|
+
readonly inputs: readonly [{
|
|
275
|
+
readonly indexed: true;
|
|
276
|
+
readonly internalType: "address";
|
|
277
|
+
readonly name: "receiver";
|
|
278
|
+
readonly type: "address";
|
|
279
|
+
}, {
|
|
280
|
+
readonly indexed: false;
|
|
281
|
+
readonly internalType: "bytes32";
|
|
282
|
+
readonly name: "amount";
|
|
283
|
+
readonly type: "bytes32";
|
|
284
|
+
}];
|
|
285
|
+
readonly name: "UnwrapRequested";
|
|
286
|
+
readonly type: "event";
|
|
287
|
+
}, {
|
|
288
|
+
readonly inputs: readonly [{
|
|
289
|
+
readonly indexed: true;
|
|
290
|
+
readonly internalType: "address";
|
|
291
|
+
readonly name: "holder";
|
|
292
|
+
readonly type: "address";
|
|
293
|
+
}, {
|
|
294
|
+
readonly indexed: true;
|
|
295
|
+
readonly internalType: "address";
|
|
296
|
+
readonly name: "to";
|
|
297
|
+
readonly type: "address";
|
|
298
|
+
}, {
|
|
299
|
+
readonly indexed: false;
|
|
300
|
+
readonly internalType: "bytes32";
|
|
301
|
+
readonly name: "nonce";
|
|
302
|
+
readonly type: "bytes32";
|
|
303
|
+
}, {
|
|
304
|
+
readonly indexed: false;
|
|
305
|
+
readonly internalType: "bytes32";
|
|
306
|
+
readonly name: "encryptedAmountHandle";
|
|
307
|
+
readonly type: "bytes32";
|
|
308
|
+
}];
|
|
309
|
+
readonly name: "UnwrapWithAuthorizationExecuted";
|
|
310
|
+
readonly type: "event";
|
|
157
311
|
}, {
|
|
158
312
|
readonly inputs: readonly [{
|
|
159
313
|
readonly internalType: "address";
|
|
@@ -291,33 +445,6 @@ type TransferQueryOptions = {
|
|
|
291
445
|
};
|
|
292
446
|
declare function getTransferAmounts(options: TransferQueryOptions): Promise<TransferAmount[]>;
|
|
293
447
|
|
|
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
448
|
type ConfidentialPaymentAuthorization = {
|
|
322
449
|
holder: `0x${string}`;
|
|
323
450
|
payee: `0x${string}`;
|
|
@@ -328,6 +455,14 @@ type ConfidentialPaymentAuthorization = {
|
|
|
328
455
|
nonce: `0x${string}`;
|
|
329
456
|
encryptedAmountHash: `0x${string}`;
|
|
330
457
|
};
|
|
458
|
+
type UnwrapAuthorization = {
|
|
459
|
+
holder: `0x${string}`;
|
|
460
|
+
to: `0x${string}`;
|
|
461
|
+
validAfter: number;
|
|
462
|
+
validBefore: number;
|
|
463
|
+
nonce: `0x${string}`;
|
|
464
|
+
encryptedAmountHash: `0x${string}`;
|
|
465
|
+
};
|
|
331
466
|
type ConfidentialPaymentPayload = {
|
|
332
467
|
authorization: ConfidentialPaymentAuthorization;
|
|
333
468
|
signature: `0x${string}`;
|
|
@@ -355,4 +490,33 @@ type ConfidentialPaymentInput = {
|
|
|
355
490
|
nonce?: `0x${string}`;
|
|
356
491
|
};
|
|
357
492
|
|
|
358
|
-
|
|
493
|
+
type TokenWriteSigner = RelayerSigner & {
|
|
494
|
+
writeContract?: (args: {
|
|
495
|
+
address: `0x${string}`;
|
|
496
|
+
abi: typeof confidentialTokenAbi;
|
|
497
|
+
functionName: "confidentialTransfer" | "wrap" | "unwrap" | "setObserver" | "unwrapWithAuthorization" | "finalizeUnwrap";
|
|
498
|
+
args: readonly unknown[];
|
|
499
|
+
}) => Promise<`0x${string}`>;
|
|
500
|
+
};
|
|
501
|
+
type ConfidentialTokenOptions = {
|
|
502
|
+
rpcUrl: string;
|
|
503
|
+
tokenAddress: `0x${string}`;
|
|
504
|
+
relayer: RelayerInstance;
|
|
505
|
+
signer: TokenWriteSigner;
|
|
506
|
+
};
|
|
507
|
+
declare class ConfidentialToken {
|
|
508
|
+
private readonly rpcUrl;
|
|
509
|
+
private readonly tokenAddress;
|
|
510
|
+
private readonly relayer;
|
|
511
|
+
private readonly signer;
|
|
512
|
+
constructor(config: ConfidentialTokenOptions);
|
|
513
|
+
balanceOf(account?: `0x${string}`): Promise<bigint>;
|
|
514
|
+
setObserver(account: `0x${string}`, observer: `0x${string}`): Promise<`0x${string}`>;
|
|
515
|
+
transfer(to: `0x${string}`, amount: number): Promise<`0x${string}`>;
|
|
516
|
+
wrap(to: `0x${string}`, amount: string | number | bigint): Promise<`0x${string}`>;
|
|
517
|
+
unwrap(from: `0x${string}`, to: `0x${string}`, amount: number): Promise<`0x${string}`>;
|
|
518
|
+
unwrapWithAuthorization(authorization: UnwrapAuthorization, encryptedAmountInput: `0x${string}`, inputProof: `0x${string}`, signature: `0x${string}`): Promise<`0x${string}`>;
|
|
519
|
+
finalizeUnwrap(burntAmount: `0x${string}`, burntAmountCleartext: string | number | bigint, decryptionProof: `0x${string}`): Promise<`0x${string}`>;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
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,59 @@ var confidentialTokenAbi = [
|
|
|
97
97
|
stateMutability: "nonpayable",
|
|
98
98
|
type: "function"
|
|
99
99
|
},
|
|
100
|
+
{
|
|
101
|
+
inputs: [
|
|
102
|
+
{ internalType: "address", name: "from", type: "address" },
|
|
103
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
104
|
+
{ internalType: "euint64", name: "amount", type: "bytes32" }
|
|
105
|
+
],
|
|
106
|
+
name: "unwrap",
|
|
107
|
+
outputs: [],
|
|
108
|
+
stateMutability: "nonpayable",
|
|
109
|
+
type: "function"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
inputs: [
|
|
113
|
+
{
|
|
114
|
+
components: [
|
|
115
|
+
{ internalType: "address", name: "holder", type: "address" },
|
|
116
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
117
|
+
{ internalType: "uint48", name: "validAfter", type: "uint48" },
|
|
118
|
+
{ internalType: "uint48", name: "validBefore", type: "uint48" },
|
|
119
|
+
{ internalType: "bytes32", name: "nonce", type: "bytes32" },
|
|
120
|
+
{ internalType: "bytes32", name: "encryptedAmountHash", type: "bytes32" }
|
|
121
|
+
],
|
|
122
|
+
internalType: "struct FHEToken.UnwrapAuthorization",
|
|
123
|
+
name: "p",
|
|
124
|
+
type: "tuple"
|
|
125
|
+
},
|
|
126
|
+
{ internalType: "bytes", name: "encryptedAmountInput", type: "bytes" },
|
|
127
|
+
{ internalType: "bytes", name: "inputProof", type: "bytes" },
|
|
128
|
+
{ internalType: "bytes", name: "sig", type: "bytes" }
|
|
129
|
+
],
|
|
130
|
+
name: "unwrapWithAuthorization",
|
|
131
|
+
outputs: [],
|
|
132
|
+
stateMutability: "nonpayable",
|
|
133
|
+
type: "function"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
inputs: [
|
|
137
|
+
{ internalType: "bytes32", name: "burntAmount", type: "bytes32" },
|
|
138
|
+
{ internalType: "uint64", name: "burntAmountCleartext", type: "uint64" },
|
|
139
|
+
{ internalType: "bytes", name: "decryptionProof", type: "bytes" }
|
|
140
|
+
],
|
|
141
|
+
name: "finalizeUnwrap",
|
|
142
|
+
outputs: [],
|
|
143
|
+
stateMutability: "nonpayable",
|
|
144
|
+
type: "function"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
148
|
+
name: "confidentialBalanceOf",
|
|
149
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
150
|
+
stateMutability: "view",
|
|
151
|
+
type: "function"
|
|
152
|
+
},
|
|
100
153
|
{
|
|
101
154
|
anonymous: false,
|
|
102
155
|
inputs: [
|
|
@@ -110,6 +163,33 @@ var confidentialTokenAbi = [
|
|
|
110
163
|
name: "ConfidentialPaymentExecuted",
|
|
111
164
|
type: "event"
|
|
112
165
|
},
|
|
166
|
+
{
|
|
167
|
+
inputs: [
|
|
168
|
+
{ indexed: true, internalType: "address", name: "receiver", type: "address" },
|
|
169
|
+
{ indexed: false, internalType: "bytes32", name: "encryptedAmount", type: "bytes32" },
|
|
170
|
+
{ indexed: false, internalType: "uint64", name: "cleartextAmount", type: "uint64" }
|
|
171
|
+
],
|
|
172
|
+
name: "UnwrapFinalized",
|
|
173
|
+
type: "event"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
inputs: [
|
|
177
|
+
{ indexed: true, internalType: "address", name: "receiver", type: "address" },
|
|
178
|
+
{ indexed: false, internalType: "bytes32", name: "amount", type: "bytes32" }
|
|
179
|
+
],
|
|
180
|
+
name: "UnwrapRequested",
|
|
181
|
+
type: "event"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
inputs: [
|
|
185
|
+
{ indexed: true, internalType: "address", name: "holder", type: "address" },
|
|
186
|
+
{ indexed: true, internalType: "address", name: "to", type: "address" },
|
|
187
|
+
{ indexed: false, internalType: "bytes32", name: "nonce", type: "bytes32" },
|
|
188
|
+
{ indexed: false, internalType: "bytes32", name: "encryptedAmountHandle", type: "bytes32" }
|
|
189
|
+
],
|
|
190
|
+
name: "UnwrapWithAuthorizationExecuted",
|
|
191
|
+
type: "event"
|
|
192
|
+
},
|
|
113
193
|
{
|
|
114
194
|
inputs: [
|
|
115
195
|
{ internalType: "address", name: "", type: "address" },
|
|
@@ -520,6 +600,41 @@ var ConfidentialToken = class {
|
|
|
520
600
|
args: [fromAddress, toAddress, handle, inputProof]
|
|
521
601
|
});
|
|
522
602
|
}
|
|
603
|
+
async unwrapWithAuthorization(authorization, encryptedAmountInput, inputProof, signature) {
|
|
604
|
+
const tokenAddress = assertAddress(this.tokenAddress, "token address");
|
|
605
|
+
const holder = assertAddress(authorization.holder, "holder address");
|
|
606
|
+
const to = assertAddress(authorization.to, "to address");
|
|
607
|
+
const writeContract = requireWriteContract(this.signer);
|
|
608
|
+
return writeContract({
|
|
609
|
+
address: tokenAddress,
|
|
610
|
+
abi: confidentialTokenAbi,
|
|
611
|
+
functionName: "unwrapWithAuthorization",
|
|
612
|
+
args: [
|
|
613
|
+
{
|
|
614
|
+
holder,
|
|
615
|
+
to,
|
|
616
|
+
validAfter: authorization.validAfter,
|
|
617
|
+
validBefore: authorization.validBefore,
|
|
618
|
+
nonce: authorization.nonce,
|
|
619
|
+
encryptedAmountHash: authorization.encryptedAmountHash
|
|
620
|
+
},
|
|
621
|
+
encryptedAmountInput,
|
|
622
|
+
inputProof,
|
|
623
|
+
signature
|
|
624
|
+
]
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
async finalizeUnwrap(burntAmount, burntAmountCleartext, decryptionProof) {
|
|
628
|
+
const tokenAddress = assertAddress(this.tokenAddress, "token address");
|
|
629
|
+
const normalizedAmount = BigInt(normalizeAmount(burntAmountCleartext));
|
|
630
|
+
const writeContract = requireWriteContract(this.signer);
|
|
631
|
+
return writeContract({
|
|
632
|
+
address: tokenAddress,
|
|
633
|
+
abi: confidentialTokenAbi,
|
|
634
|
+
functionName: "finalizeUnwrap",
|
|
635
|
+
args: [burntAmount, normalizedAmount, decryptionProof]
|
|
636
|
+
});
|
|
637
|
+
}
|
|
523
638
|
};
|
|
524
639
|
// Annotate the CommonJS export names for ESM import in node:
|
|
525
640
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -59,6 +59,59 @@ var confidentialTokenAbi = [
|
|
|
59
59
|
stateMutability: "nonpayable",
|
|
60
60
|
type: "function"
|
|
61
61
|
},
|
|
62
|
+
{
|
|
63
|
+
inputs: [
|
|
64
|
+
{ internalType: "address", name: "from", type: "address" },
|
|
65
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
66
|
+
{ internalType: "euint64", name: "amount", type: "bytes32" }
|
|
67
|
+
],
|
|
68
|
+
name: "unwrap",
|
|
69
|
+
outputs: [],
|
|
70
|
+
stateMutability: "nonpayable",
|
|
71
|
+
type: "function"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
inputs: [
|
|
75
|
+
{
|
|
76
|
+
components: [
|
|
77
|
+
{ internalType: "address", name: "holder", type: "address" },
|
|
78
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
79
|
+
{ internalType: "uint48", name: "validAfter", type: "uint48" },
|
|
80
|
+
{ internalType: "uint48", name: "validBefore", type: "uint48" },
|
|
81
|
+
{ internalType: "bytes32", name: "nonce", type: "bytes32" },
|
|
82
|
+
{ internalType: "bytes32", name: "encryptedAmountHash", type: "bytes32" }
|
|
83
|
+
],
|
|
84
|
+
internalType: "struct FHEToken.UnwrapAuthorization",
|
|
85
|
+
name: "p",
|
|
86
|
+
type: "tuple"
|
|
87
|
+
},
|
|
88
|
+
{ internalType: "bytes", name: "encryptedAmountInput", type: "bytes" },
|
|
89
|
+
{ internalType: "bytes", name: "inputProof", type: "bytes" },
|
|
90
|
+
{ internalType: "bytes", name: "sig", type: "bytes" }
|
|
91
|
+
],
|
|
92
|
+
name: "unwrapWithAuthorization",
|
|
93
|
+
outputs: [],
|
|
94
|
+
stateMutability: "nonpayable",
|
|
95
|
+
type: "function"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
inputs: [
|
|
99
|
+
{ internalType: "bytes32", name: "burntAmount", type: "bytes32" },
|
|
100
|
+
{ internalType: "uint64", name: "burntAmountCleartext", type: "uint64" },
|
|
101
|
+
{ internalType: "bytes", name: "decryptionProof", type: "bytes" }
|
|
102
|
+
],
|
|
103
|
+
name: "finalizeUnwrap",
|
|
104
|
+
outputs: [],
|
|
105
|
+
stateMutability: "nonpayable",
|
|
106
|
+
type: "function"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
110
|
+
name: "confidentialBalanceOf",
|
|
111
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
112
|
+
stateMutability: "view",
|
|
113
|
+
type: "function"
|
|
114
|
+
},
|
|
62
115
|
{
|
|
63
116
|
anonymous: false,
|
|
64
117
|
inputs: [
|
|
@@ -72,6 +125,33 @@ var confidentialTokenAbi = [
|
|
|
72
125
|
name: "ConfidentialPaymentExecuted",
|
|
73
126
|
type: "event"
|
|
74
127
|
},
|
|
128
|
+
{
|
|
129
|
+
inputs: [
|
|
130
|
+
{ indexed: true, internalType: "address", name: "receiver", type: "address" },
|
|
131
|
+
{ indexed: false, internalType: "bytes32", name: "encryptedAmount", type: "bytes32" },
|
|
132
|
+
{ indexed: false, internalType: "uint64", name: "cleartextAmount", type: "uint64" }
|
|
133
|
+
],
|
|
134
|
+
name: "UnwrapFinalized",
|
|
135
|
+
type: "event"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
inputs: [
|
|
139
|
+
{ indexed: true, internalType: "address", name: "receiver", type: "address" },
|
|
140
|
+
{ indexed: false, internalType: "bytes32", name: "amount", type: "bytes32" }
|
|
141
|
+
],
|
|
142
|
+
name: "UnwrapRequested",
|
|
143
|
+
type: "event"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
inputs: [
|
|
147
|
+
{ indexed: true, internalType: "address", name: "holder", type: "address" },
|
|
148
|
+
{ indexed: true, internalType: "address", name: "to", type: "address" },
|
|
149
|
+
{ indexed: false, internalType: "bytes32", name: "nonce", type: "bytes32" },
|
|
150
|
+
{ indexed: false, internalType: "bytes32", name: "encryptedAmountHandle", type: "bytes32" }
|
|
151
|
+
],
|
|
152
|
+
name: "UnwrapWithAuthorizationExecuted",
|
|
153
|
+
type: "event"
|
|
154
|
+
},
|
|
75
155
|
{
|
|
76
156
|
inputs: [
|
|
77
157
|
{ internalType: "address", name: "", type: "address" },
|
|
@@ -482,6 +562,41 @@ var ConfidentialToken = class {
|
|
|
482
562
|
args: [fromAddress, toAddress, handle, inputProof]
|
|
483
563
|
});
|
|
484
564
|
}
|
|
565
|
+
async unwrapWithAuthorization(authorization, encryptedAmountInput, inputProof, signature) {
|
|
566
|
+
const tokenAddress = assertAddress(this.tokenAddress, "token address");
|
|
567
|
+
const holder = assertAddress(authorization.holder, "holder address");
|
|
568
|
+
const to = assertAddress(authorization.to, "to address");
|
|
569
|
+
const writeContract = requireWriteContract(this.signer);
|
|
570
|
+
return writeContract({
|
|
571
|
+
address: tokenAddress,
|
|
572
|
+
abi: confidentialTokenAbi,
|
|
573
|
+
functionName: "unwrapWithAuthorization",
|
|
574
|
+
args: [
|
|
575
|
+
{
|
|
576
|
+
holder,
|
|
577
|
+
to,
|
|
578
|
+
validAfter: authorization.validAfter,
|
|
579
|
+
validBefore: authorization.validBefore,
|
|
580
|
+
nonce: authorization.nonce,
|
|
581
|
+
encryptedAmountHash: authorization.encryptedAmountHash
|
|
582
|
+
},
|
|
583
|
+
encryptedAmountInput,
|
|
584
|
+
inputProof,
|
|
585
|
+
signature
|
|
586
|
+
]
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
async finalizeUnwrap(burntAmount, burntAmountCleartext, decryptionProof) {
|
|
590
|
+
const tokenAddress = assertAddress(this.tokenAddress, "token address");
|
|
591
|
+
const normalizedAmount = BigInt(normalizeAmount(burntAmountCleartext));
|
|
592
|
+
const writeContract = requireWriteContract(this.signer);
|
|
593
|
+
return writeContract({
|
|
594
|
+
address: tokenAddress,
|
|
595
|
+
abi: confidentialTokenAbi,
|
|
596
|
+
functionName: "finalizeUnwrap",
|
|
597
|
+
args: [burntAmount, normalizedAmount, decryptionProof]
|
|
598
|
+
});
|
|
599
|
+
}
|
|
485
600
|
};
|
|
486
601
|
export {
|
|
487
602
|
ConfidentialToken,
|