x402z-shared 0.0.5 → 0.0.6
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/README.md +17 -23
- package/dist/chunk-7OLOM2AQ.mjs +155 -0
- package/dist/index.d.mts +60 -13
- package/dist/index.d.ts +60 -13
- package/dist/index.js +214 -80
- package/dist/index.mjs +212 -79
- package/dist/types-I3K7qzdc.d.mts +274 -0
- package/dist/types-I3K7qzdc.d.ts +274 -0
- package/dist/web.d.mts +19 -21
- package/dist/web.d.ts +19 -21
- package/dist/web.js +227 -108
- package/dist/web.mjs +194 -75
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,9 +4,8 @@ import {
|
|
|
4
4
|
confidentialTokenAbi,
|
|
5
5
|
createNonce,
|
|
6
6
|
hashEncryptedAmountInput,
|
|
7
|
-
normalizeAmount
|
|
8
|
-
|
|
9
|
-
} from "./chunk-LTE4V3LT.mjs";
|
|
7
|
+
normalizeAmount
|
|
8
|
+
} from "./chunk-7OLOM2AQ.mjs";
|
|
10
9
|
|
|
11
10
|
// src/relayer.ts
|
|
12
11
|
import { createInstance, SepoliaConfig } from "@zama-fhe/relayer-sdk/node";
|
|
@@ -63,87 +62,29 @@ async function publicDecrypt(relayer, handles) {
|
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
// src/balance.ts
|
|
67
|
-
import { createPublicClient, getAddress as getAddress2, http, isAddress, isAddressEqual } from "viem";
|
|
68
|
-
var ZERO_HANDLE = "0x" + "00".repeat(32);
|
|
69
|
-
async function viewConfidentialBalance(options) {
|
|
70
|
-
if (!isAddress(options.tokenAddress)) {
|
|
71
|
-
throw new Error(`Invalid token address: ${options.tokenAddress}`);
|
|
72
|
-
}
|
|
73
|
-
const account = options.account ?? options.signer?.address;
|
|
74
|
-
if (!account || !isAddress(account)) {
|
|
75
|
-
throw new Error(`Invalid account address: ${account ?? "undefined"}`);
|
|
76
|
-
}
|
|
77
|
-
const publicClient = createPublicClient({ transport: http(options.rpcUrl) });
|
|
78
|
-
const confidentialBalanceAbi = [
|
|
79
|
-
{
|
|
80
|
-
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
81
|
-
name: "confidentialBalanceOf",
|
|
82
|
-
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
83
|
-
stateMutability: "view",
|
|
84
|
-
type: "function"
|
|
85
|
-
}
|
|
86
|
-
];
|
|
87
|
-
const handle = await publicClient.readContract({
|
|
88
|
-
address: options.tokenAddress,
|
|
89
|
-
abi: confidentialBalanceAbi,
|
|
90
|
-
functionName: "confidentialBalanceOf",
|
|
91
|
-
args: [account]
|
|
92
|
-
});
|
|
93
|
-
const shouldDecrypt = options.decrypt ?? true;
|
|
94
|
-
if (!shouldDecrypt) {
|
|
95
|
-
return { handle };
|
|
96
|
-
}
|
|
97
|
-
if (!options.signer) {
|
|
98
|
-
throw new Error("Missing signer for decryption");
|
|
99
|
-
}
|
|
100
|
-
const signerAddress = getAddress2(options.signer.address);
|
|
101
|
-
if (!isAddressEqual(signerAddress, getAddress2(account))) {
|
|
102
|
-
const observer = await publicClient.readContract({
|
|
103
|
-
address: options.tokenAddress,
|
|
104
|
-
abi: confidentialTokenAbi,
|
|
105
|
-
functionName: "observer",
|
|
106
|
-
args: [account]
|
|
107
|
-
});
|
|
108
|
-
if (!observer || !isAddressEqual(observer, signerAddress)) {
|
|
109
|
-
throw new Error(confidentialErrorCodes.observerNotAuthorized);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (handle === ZERO_HANDLE) {
|
|
113
|
-
return { handle, balance: 0n };
|
|
114
|
-
}
|
|
115
|
-
const balance = await userDecryptEuint64(
|
|
116
|
-
options.relayer,
|
|
117
|
-
handle,
|
|
118
|
-
options.tokenAddress,
|
|
119
|
-
options.signer
|
|
120
|
-
);
|
|
121
|
-
return { handle, balance };
|
|
122
|
-
}
|
|
123
|
-
|
|
124
65
|
// src/transfer.ts
|
|
125
|
-
import { createPublicClient
|
|
66
|
+
import { createPublicClient, decodeEventLog, getAddress as getAddress2, http, isAddress, isHex, isAddressEqual } from "viem";
|
|
126
67
|
async function viewConfidentialTransferAmounts(options) {
|
|
127
|
-
if (!
|
|
68
|
+
if (!isAddress(options.tokenAddress)) {
|
|
128
69
|
throw new Error(`Invalid token address: ${options.tokenAddress}`);
|
|
129
70
|
}
|
|
130
71
|
if (!isHex(options.txHash, { strict: true })) {
|
|
131
72
|
throw new Error(`Invalid transaction hash: ${options.txHash}`);
|
|
132
73
|
}
|
|
133
|
-
if (options.from && !
|
|
74
|
+
if (options.from && !isAddress(options.from)) {
|
|
134
75
|
throw new Error(`Invalid from address: ${options.from}`);
|
|
135
76
|
}
|
|
136
|
-
if (options.to && !
|
|
77
|
+
if (options.to && !isAddress(options.to)) {
|
|
137
78
|
throw new Error(`Invalid to address: ${options.to}`);
|
|
138
79
|
}
|
|
139
|
-
const publicClient =
|
|
80
|
+
const publicClient = createPublicClient({ transport: http(options.rpcUrl) });
|
|
140
81
|
const receipt = await publicClient.getTransactionReceipt({
|
|
141
82
|
hash: options.txHash
|
|
142
83
|
});
|
|
143
|
-
const tokenAddress =
|
|
144
|
-
const fromFilter = options.from ?
|
|
145
|
-
const toFilter = options.to ?
|
|
146
|
-
const logs = receipt.logs.filter((log) =>
|
|
84
|
+
const tokenAddress = getAddress2(options.tokenAddress);
|
|
85
|
+
const fromFilter = options.from ? getAddress2(options.from) : void 0;
|
|
86
|
+
const toFilter = options.to ? getAddress2(options.to) : void 0;
|
|
87
|
+
const logs = receipt.logs.filter((log) => getAddress2(log.address) === tokenAddress);
|
|
147
88
|
const transfers = [];
|
|
148
89
|
for (const log of logs) {
|
|
149
90
|
try {
|
|
@@ -155,8 +96,8 @@ async function viewConfidentialTransferAmounts(options) {
|
|
|
155
96
|
});
|
|
156
97
|
const args = decoded.args;
|
|
157
98
|
const entry = {
|
|
158
|
-
holder:
|
|
159
|
-
payee:
|
|
99
|
+
holder: getAddress2(args.holder),
|
|
100
|
+
payee: getAddress2(args.payee),
|
|
160
101
|
maxClearAmount: BigInt(args.maxClearAmount),
|
|
161
102
|
resourceHash: args.resourceHash,
|
|
162
103
|
nonce: args.nonce,
|
|
@@ -173,10 +114,10 @@ async function viewConfidentialTransferAmounts(options) {
|
|
|
173
114
|
if (!options.signer) {
|
|
174
115
|
throw new Error("Missing signer for decryption");
|
|
175
116
|
}
|
|
176
|
-
const signerAddress =
|
|
177
|
-
const holderAddress =
|
|
178
|
-
const payeeAddress =
|
|
179
|
-
if (!
|
|
117
|
+
const signerAddress = getAddress2(options.signer.address);
|
|
118
|
+
const holderAddress = getAddress2(entry.holder);
|
|
119
|
+
const payeeAddress = getAddress2(entry.payee);
|
|
120
|
+
if (!isAddressEqual(signerAddress, holderAddress) && !isAddressEqual(signerAddress, payeeAddress)) {
|
|
180
121
|
const [holderObserver, payeeObserver] = await Promise.all([
|
|
181
122
|
publicClient.readContract({
|
|
182
123
|
address: tokenAddress,
|
|
@@ -191,7 +132,7 @@ async function viewConfidentialTransferAmounts(options) {
|
|
|
191
132
|
args: [payeeAddress]
|
|
192
133
|
})
|
|
193
134
|
]);
|
|
194
|
-
const allowed = holderObserver &&
|
|
135
|
+
const allowed = holderObserver && isAddressEqual(holderObserver, signerAddress) || payeeObserver && isAddressEqual(payeeObserver, signerAddress);
|
|
195
136
|
if (!allowed) {
|
|
196
137
|
throw new Error(confidentialErrorCodes.observerNotAuthorized);
|
|
197
138
|
}
|
|
@@ -212,10 +153,204 @@ async function viewConfidentialTransferAmounts(options) {
|
|
|
212
153
|
}
|
|
213
154
|
return transfers;
|
|
214
155
|
}
|
|
156
|
+
|
|
157
|
+
// src/token.ts
|
|
158
|
+
import { getAddress as getAddress5, isAddress as isAddress4 } from "viem";
|
|
159
|
+
|
|
160
|
+
// src/balance.ts
|
|
161
|
+
import { createPublicClient as createPublicClient2, getAddress as getAddress3, http as http2, isAddress as isAddress2, isAddressEqual as isAddressEqual2 } from "viem";
|
|
162
|
+
var ZERO_HANDLE = "0x" + "00".repeat(32);
|
|
163
|
+
async function viewConfidentialBalance(options) {
|
|
164
|
+
if (!isAddress2(options.tokenAddress)) {
|
|
165
|
+
throw new Error(`Invalid token address: ${options.tokenAddress}`);
|
|
166
|
+
}
|
|
167
|
+
const account = options.account ?? options.signer?.address;
|
|
168
|
+
if (!account || !isAddress2(account)) {
|
|
169
|
+
throw new Error(`Invalid account address: ${account ?? "undefined"}`);
|
|
170
|
+
}
|
|
171
|
+
const publicClient = createPublicClient2({ transport: http2(options.rpcUrl) });
|
|
172
|
+
const confidentialBalanceAbi = [
|
|
173
|
+
{
|
|
174
|
+
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
175
|
+
name: "confidentialBalanceOf",
|
|
176
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
177
|
+
stateMutability: "view",
|
|
178
|
+
type: "function"
|
|
179
|
+
}
|
|
180
|
+
];
|
|
181
|
+
const handle = await publicClient.readContract({
|
|
182
|
+
address: options.tokenAddress,
|
|
183
|
+
abi: confidentialBalanceAbi,
|
|
184
|
+
functionName: "confidentialBalanceOf",
|
|
185
|
+
args: [account]
|
|
186
|
+
});
|
|
187
|
+
const shouldDecrypt = options.decrypt ?? true;
|
|
188
|
+
if (!shouldDecrypt) {
|
|
189
|
+
return { handle };
|
|
190
|
+
}
|
|
191
|
+
if (!options.signer) {
|
|
192
|
+
throw new Error("Missing signer for decryption");
|
|
193
|
+
}
|
|
194
|
+
const signerAddress = getAddress3(options.signer.address);
|
|
195
|
+
if (!isAddressEqual2(signerAddress, getAddress3(account))) {
|
|
196
|
+
const observer = await publicClient.readContract({
|
|
197
|
+
address: options.tokenAddress,
|
|
198
|
+
abi: confidentialTokenAbi,
|
|
199
|
+
functionName: "observer",
|
|
200
|
+
args: [account]
|
|
201
|
+
});
|
|
202
|
+
if (!observer || !isAddressEqual2(observer, signerAddress)) {
|
|
203
|
+
throw new Error(confidentialErrorCodes.observerNotAuthorized);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (handle === ZERO_HANDLE) {
|
|
207
|
+
return { handle, balance: 0n };
|
|
208
|
+
}
|
|
209
|
+
const balance = await userDecryptEuint64(
|
|
210
|
+
options.relayer,
|
|
211
|
+
handle,
|
|
212
|
+
options.tokenAddress,
|
|
213
|
+
options.signer
|
|
214
|
+
);
|
|
215
|
+
return { handle, balance };
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// src/observer.ts
|
|
219
|
+
import { createPublicClient as createPublicClient3, getAddress as getAddress4, http as http3, isAddress as isAddress3 } from "viem";
|
|
220
|
+
async function setObserver(options) {
|
|
221
|
+
if (!isAddress3(options.tokenAddress)) {
|
|
222
|
+
throw new Error(`Invalid token address: ${options.tokenAddress}`);
|
|
223
|
+
}
|
|
224
|
+
if (!isAddress3(options.account)) {
|
|
225
|
+
throw new Error(`Invalid account address: ${options.account}`);
|
|
226
|
+
}
|
|
227
|
+
if (!isAddress3(options.observer)) {
|
|
228
|
+
throw new Error(`Invalid observer address: ${options.observer}`);
|
|
229
|
+
}
|
|
230
|
+
const tokenAddress = getAddress4(options.tokenAddress);
|
|
231
|
+
const account = getAddress4(options.account);
|
|
232
|
+
const observer = getAddress4(options.observer);
|
|
233
|
+
const publicClient = createPublicClient3({ transport: http3(options.rpcUrl) });
|
|
234
|
+
const existing = await publicClient.readContract({
|
|
235
|
+
address: tokenAddress,
|
|
236
|
+
abi: confidentialTokenAbi,
|
|
237
|
+
functionName: "observer",
|
|
238
|
+
args: [account]
|
|
239
|
+
});
|
|
240
|
+
if (existing && isAddress3(existing) && getAddress4(existing) === observer) {
|
|
241
|
+
return "0x" + "00".repeat(32);
|
|
242
|
+
}
|
|
243
|
+
return options.signer.writeContract({
|
|
244
|
+
address: tokenAddress,
|
|
245
|
+
abi: confidentialTokenAbi,
|
|
246
|
+
functionName: "setObserver",
|
|
247
|
+
args: [account, observer]
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// src/token.ts
|
|
252
|
+
function assertAddress(value, label) {
|
|
253
|
+
if (!isAddress4(value)) {
|
|
254
|
+
throw new Error(`Invalid ${label}: ${value}`);
|
|
255
|
+
}
|
|
256
|
+
return getAddress5(value);
|
|
257
|
+
}
|
|
258
|
+
function requireWriteContract(signer) {
|
|
259
|
+
if (!signer.writeContract) {
|
|
260
|
+
throw new Error("Missing signer.writeContract for on-chain calls");
|
|
261
|
+
}
|
|
262
|
+
return signer.writeContract;
|
|
263
|
+
}
|
|
264
|
+
var ConfidentialToken = class {
|
|
265
|
+
constructor(config) {
|
|
266
|
+
this.rpcUrl = config.rpcUrl;
|
|
267
|
+
this.tokenAddress = config.tokenAddress;
|
|
268
|
+
this.relayer = config.relayer;
|
|
269
|
+
this.signer = config.signer;
|
|
270
|
+
}
|
|
271
|
+
async balanceOf(account) {
|
|
272
|
+
const result = await viewConfidentialBalance({
|
|
273
|
+
rpcUrl: this.rpcUrl,
|
|
274
|
+
tokenAddress: this.tokenAddress,
|
|
275
|
+
account,
|
|
276
|
+
relayer: this.relayer,
|
|
277
|
+
signer: this.signer,
|
|
278
|
+
decrypt: true
|
|
279
|
+
});
|
|
280
|
+
return result.balance ?? 0n;
|
|
281
|
+
}
|
|
282
|
+
async setObserver(account, observer) {
|
|
283
|
+
const writeContract = requireWriteContract(this.signer);
|
|
284
|
+
return setObserver({
|
|
285
|
+
rpcUrl: this.rpcUrl,
|
|
286
|
+
tokenAddress: this.tokenAddress,
|
|
287
|
+
account,
|
|
288
|
+
observer,
|
|
289
|
+
signer: { ...this.signer, writeContract }
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
async transfer(to, amount) {
|
|
293
|
+
const tokenAddress = assertAddress(this.tokenAddress, "token address");
|
|
294
|
+
const toAddress = assertAddress(to, "recipient address");
|
|
295
|
+
const fromAddress = assertAddress(this.signer.address, "signer address");
|
|
296
|
+
if (!Number.isSafeInteger(amount)) {
|
|
297
|
+
throw new Error("Transfer amount must be a safe integer");
|
|
298
|
+
}
|
|
299
|
+
const { handle, inputProof } = await createEncryptedAmountInput(
|
|
300
|
+
this.relayer,
|
|
301
|
+
tokenAddress,
|
|
302
|
+
fromAddress,
|
|
303
|
+
amount
|
|
304
|
+
);
|
|
305
|
+
const writeContract = requireWriteContract(this.signer);
|
|
306
|
+
return writeContract({
|
|
307
|
+
address: tokenAddress,
|
|
308
|
+
abi: confidentialTokenAbi,
|
|
309
|
+
functionName: "confidentialTransfer",
|
|
310
|
+
args: [toAddress, handle, inputProof]
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
async wrap(to, amount) {
|
|
314
|
+
const tokenAddress = assertAddress(this.tokenAddress, "token address");
|
|
315
|
+
const toAddress = assertAddress(to, "recipient address");
|
|
316
|
+
const normalizedAmount = BigInt(normalizeAmount(amount));
|
|
317
|
+
const writeContract = requireWriteContract(this.signer);
|
|
318
|
+
return writeContract({
|
|
319
|
+
address: tokenAddress,
|
|
320
|
+
abi: confidentialTokenAbi,
|
|
321
|
+
functionName: "wrap",
|
|
322
|
+
args: [toAddress, normalizedAmount]
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
async unwrap(from, to, amount) {
|
|
326
|
+
const tokenAddress = assertAddress(this.tokenAddress, "token address");
|
|
327
|
+
const fromAddress = assertAddress(from, "from address");
|
|
328
|
+
const toAddress = assertAddress(to, "to address");
|
|
329
|
+
const signerAddress = assertAddress(this.signer.address, "signer address");
|
|
330
|
+
if (!Number.isSafeInteger(amount)) {
|
|
331
|
+
throw new Error("Unwrap amount must be a safe integer");
|
|
332
|
+
}
|
|
333
|
+
const { handle, inputProof } = await createEncryptedAmountInput(
|
|
334
|
+
this.relayer,
|
|
335
|
+
tokenAddress,
|
|
336
|
+
signerAddress,
|
|
337
|
+
amount
|
|
338
|
+
);
|
|
339
|
+
const writeContract = requireWriteContract(this.signer);
|
|
340
|
+
return writeContract({
|
|
341
|
+
address: tokenAddress,
|
|
342
|
+
abi: confidentialTokenAbi,
|
|
343
|
+
functionName: "unwrap",
|
|
344
|
+
args: [fromAddress, toAddress, handle, inputProof]
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
};
|
|
215
348
|
export {
|
|
349
|
+
ConfidentialToken,
|
|
216
350
|
SepoliaConfig,
|
|
217
351
|
confidentialErrorCodes,
|
|
218
352
|
confidentialPaymentTypes,
|
|
353
|
+
ConfidentialToken as confidentialToken,
|
|
219
354
|
confidentialTokenAbi,
|
|
220
355
|
createEncryptedAmountInput,
|
|
221
356
|
createNonce,
|
|
@@ -223,8 +358,6 @@ export {
|
|
|
223
358
|
hashEncryptedAmountInput,
|
|
224
359
|
normalizeAmount,
|
|
225
360
|
publicDecrypt,
|
|
226
|
-
setObserver,
|
|
227
361
|
userDecryptEuint64,
|
|
228
|
-
viewConfidentialBalance,
|
|
229
362
|
viewConfidentialTransferAmounts
|
|
230
363
|
};
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
declare const confidentialTokenAbi: readonly [{
|
|
2
|
+
readonly inputs: readonly [{
|
|
3
|
+
readonly internalType: "address";
|
|
4
|
+
readonly name: "to";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
}, {
|
|
7
|
+
readonly internalType: "bytes32";
|
|
8
|
+
readonly name: "encryptedAmountInput";
|
|
9
|
+
readonly type: "bytes32";
|
|
10
|
+
}, {
|
|
11
|
+
readonly internalType: "bytes";
|
|
12
|
+
readonly name: "inputProof";
|
|
13
|
+
readonly type: "bytes";
|
|
14
|
+
}];
|
|
15
|
+
readonly name: "confidentialTransfer";
|
|
16
|
+
readonly outputs: readonly [{
|
|
17
|
+
readonly internalType: "euint64";
|
|
18
|
+
readonly name: "transferred";
|
|
19
|
+
readonly type: "bytes32";
|
|
20
|
+
}];
|
|
21
|
+
readonly stateMutability: "nonpayable";
|
|
22
|
+
readonly type: "function";
|
|
23
|
+
}, {
|
|
24
|
+
readonly inputs: readonly [{
|
|
25
|
+
readonly components: readonly [{
|
|
26
|
+
readonly internalType: "address";
|
|
27
|
+
readonly name: "holder";
|
|
28
|
+
readonly type: "address";
|
|
29
|
+
}, {
|
|
30
|
+
readonly internalType: "address";
|
|
31
|
+
readonly name: "payee";
|
|
32
|
+
readonly type: "address";
|
|
33
|
+
}, {
|
|
34
|
+
readonly internalType: "uint256";
|
|
35
|
+
readonly name: "maxClearAmount";
|
|
36
|
+
readonly type: "uint256";
|
|
37
|
+
}, {
|
|
38
|
+
readonly internalType: "bytes32";
|
|
39
|
+
readonly name: "resourceHash";
|
|
40
|
+
readonly type: "bytes32";
|
|
41
|
+
}, {
|
|
42
|
+
readonly internalType: "uint48";
|
|
43
|
+
readonly name: "validAfter";
|
|
44
|
+
readonly type: "uint48";
|
|
45
|
+
}, {
|
|
46
|
+
readonly internalType: "uint48";
|
|
47
|
+
readonly name: "validBefore";
|
|
48
|
+
readonly type: "uint48";
|
|
49
|
+
}, {
|
|
50
|
+
readonly internalType: "bytes32";
|
|
51
|
+
readonly name: "nonce";
|
|
52
|
+
readonly type: "bytes32";
|
|
53
|
+
}, {
|
|
54
|
+
readonly internalType: "bytes32";
|
|
55
|
+
readonly name: "encryptedAmountHash";
|
|
56
|
+
readonly type: "bytes32";
|
|
57
|
+
}];
|
|
58
|
+
readonly internalType: "struct FHEToken.ConfidentialPayment";
|
|
59
|
+
readonly name: "p";
|
|
60
|
+
readonly type: "tuple";
|
|
61
|
+
}, {
|
|
62
|
+
readonly internalType: "externalEuint64";
|
|
63
|
+
readonly name: "encryptedAmountInput";
|
|
64
|
+
readonly type: "bytes32";
|
|
65
|
+
}, {
|
|
66
|
+
readonly internalType: "bytes";
|
|
67
|
+
readonly name: "inputProof";
|
|
68
|
+
readonly type: "bytes";
|
|
69
|
+
}, {
|
|
70
|
+
readonly internalType: "bytes";
|
|
71
|
+
readonly name: "sig";
|
|
72
|
+
readonly type: "bytes";
|
|
73
|
+
}];
|
|
74
|
+
readonly name: "confidentialTransferWithAuthorization";
|
|
75
|
+
readonly outputs: readonly [{
|
|
76
|
+
readonly internalType: "euint64";
|
|
77
|
+
readonly name: "transferred";
|
|
78
|
+
readonly type: "bytes32";
|
|
79
|
+
}];
|
|
80
|
+
readonly stateMutability: "nonpayable";
|
|
81
|
+
readonly type: "function";
|
|
82
|
+
}, {
|
|
83
|
+
readonly inputs: readonly [{
|
|
84
|
+
readonly internalType: "address";
|
|
85
|
+
readonly name: "to";
|
|
86
|
+
readonly type: "address";
|
|
87
|
+
}, {
|
|
88
|
+
readonly internalType: "uint256";
|
|
89
|
+
readonly name: "amount";
|
|
90
|
+
readonly type: "uint256";
|
|
91
|
+
}];
|
|
92
|
+
readonly name: "wrap";
|
|
93
|
+
readonly outputs: readonly [];
|
|
94
|
+
readonly stateMutability: "nonpayable";
|
|
95
|
+
readonly type: "function";
|
|
96
|
+
}, {
|
|
97
|
+
readonly inputs: readonly [{
|
|
98
|
+
readonly internalType: "address";
|
|
99
|
+
readonly name: "from";
|
|
100
|
+
readonly type: "address";
|
|
101
|
+
}, {
|
|
102
|
+
readonly internalType: "address";
|
|
103
|
+
readonly name: "to";
|
|
104
|
+
readonly type: "address";
|
|
105
|
+
}, {
|
|
106
|
+
readonly internalType: "bytes32";
|
|
107
|
+
readonly name: "encryptedAmountInput";
|
|
108
|
+
readonly type: "bytes32";
|
|
109
|
+
}, {
|
|
110
|
+
readonly internalType: "bytes";
|
|
111
|
+
readonly name: "inputProof";
|
|
112
|
+
readonly type: "bytes";
|
|
113
|
+
}];
|
|
114
|
+
readonly name: "unwrap";
|
|
115
|
+
readonly outputs: readonly [];
|
|
116
|
+
readonly stateMutability: "nonpayable";
|
|
117
|
+
readonly type: "function";
|
|
118
|
+
}, {
|
|
119
|
+
readonly anonymous: false;
|
|
120
|
+
readonly inputs: readonly [{
|
|
121
|
+
readonly indexed: true;
|
|
122
|
+
readonly internalType: "address";
|
|
123
|
+
readonly name: "holder";
|
|
124
|
+
readonly type: "address";
|
|
125
|
+
}, {
|
|
126
|
+
readonly indexed: true;
|
|
127
|
+
readonly internalType: "address";
|
|
128
|
+
readonly name: "payee";
|
|
129
|
+
readonly type: "address";
|
|
130
|
+
}, {
|
|
131
|
+
readonly indexed: false;
|
|
132
|
+
readonly internalType: "uint256";
|
|
133
|
+
readonly name: "maxClearAmount";
|
|
134
|
+
readonly type: "uint256";
|
|
135
|
+
}, {
|
|
136
|
+
readonly indexed: true;
|
|
137
|
+
readonly internalType: "bytes32";
|
|
138
|
+
readonly name: "resourceHash";
|
|
139
|
+
readonly type: "bytes32";
|
|
140
|
+
}, {
|
|
141
|
+
readonly indexed: false;
|
|
142
|
+
readonly internalType: "bytes32";
|
|
143
|
+
readonly name: "nonce";
|
|
144
|
+
readonly type: "bytes32";
|
|
145
|
+
}, {
|
|
146
|
+
readonly indexed: false;
|
|
147
|
+
readonly internalType: "bytes32";
|
|
148
|
+
readonly name: "transferredAmount";
|
|
149
|
+
readonly type: "bytes32";
|
|
150
|
+
}];
|
|
151
|
+
readonly name: "ConfidentialPaymentExecuted";
|
|
152
|
+
readonly type: "event";
|
|
153
|
+
}, {
|
|
154
|
+
readonly inputs: readonly [{
|
|
155
|
+
readonly internalType: "address";
|
|
156
|
+
readonly name: "";
|
|
157
|
+
readonly type: "address";
|
|
158
|
+
}, {
|
|
159
|
+
readonly internalType: "bytes32";
|
|
160
|
+
readonly name: "";
|
|
161
|
+
readonly type: "bytes32";
|
|
162
|
+
}];
|
|
163
|
+
readonly name: "usedNonces";
|
|
164
|
+
readonly outputs: readonly [{
|
|
165
|
+
readonly internalType: "bool";
|
|
166
|
+
readonly name: "";
|
|
167
|
+
readonly type: "bool";
|
|
168
|
+
}];
|
|
169
|
+
readonly stateMutability: "view";
|
|
170
|
+
readonly type: "function";
|
|
171
|
+
}, {
|
|
172
|
+
readonly inputs: readonly [{
|
|
173
|
+
readonly internalType: "address";
|
|
174
|
+
readonly name: "account";
|
|
175
|
+
readonly type: "address";
|
|
176
|
+
}];
|
|
177
|
+
readonly name: "observer";
|
|
178
|
+
readonly outputs: readonly [{
|
|
179
|
+
readonly internalType: "address";
|
|
180
|
+
readonly name: "";
|
|
181
|
+
readonly type: "address";
|
|
182
|
+
}];
|
|
183
|
+
readonly stateMutability: "view";
|
|
184
|
+
readonly type: "function";
|
|
185
|
+
}, {
|
|
186
|
+
readonly inputs: readonly [{
|
|
187
|
+
readonly internalType: "address";
|
|
188
|
+
readonly name: "account";
|
|
189
|
+
readonly type: "address";
|
|
190
|
+
}, {
|
|
191
|
+
readonly internalType: "address";
|
|
192
|
+
readonly name: "newObserver";
|
|
193
|
+
readonly type: "address";
|
|
194
|
+
}];
|
|
195
|
+
readonly name: "setObserver";
|
|
196
|
+
readonly outputs: readonly [];
|
|
197
|
+
readonly stateMutability: "nonpayable";
|
|
198
|
+
readonly type: "function";
|
|
199
|
+
}];
|
|
200
|
+
|
|
201
|
+
declare const confidentialPaymentTypes: {
|
|
202
|
+
readonly ConfidentialPayment: readonly [{
|
|
203
|
+
readonly name: "holder";
|
|
204
|
+
readonly type: "address";
|
|
205
|
+
}, {
|
|
206
|
+
readonly name: "payee";
|
|
207
|
+
readonly type: "address";
|
|
208
|
+
}, {
|
|
209
|
+
readonly name: "maxClearAmount";
|
|
210
|
+
readonly type: "uint256";
|
|
211
|
+
}, {
|
|
212
|
+
readonly name: "resourceHash";
|
|
213
|
+
readonly type: "bytes32";
|
|
214
|
+
}, {
|
|
215
|
+
readonly name: "validAfter";
|
|
216
|
+
readonly type: "uint48";
|
|
217
|
+
}, {
|
|
218
|
+
readonly name: "validBefore";
|
|
219
|
+
readonly type: "uint48";
|
|
220
|
+
}, {
|
|
221
|
+
readonly name: "nonce";
|
|
222
|
+
readonly type: "bytes32";
|
|
223
|
+
}, {
|
|
224
|
+
readonly name: "encryptedAmountHash";
|
|
225
|
+
readonly type: "bytes32";
|
|
226
|
+
}];
|
|
227
|
+
};
|
|
228
|
+
declare const confidentialErrorCodes: {
|
|
229
|
+
readonly observerNotAuthorized: "observer_not_authorized";
|
|
230
|
+
};
|
|
231
|
+
type ConfidentialErrorCode = (typeof confidentialErrorCodes)[keyof typeof confidentialErrorCodes];
|
|
232
|
+
|
|
233
|
+
declare function createNonce(): `0x${string}`;
|
|
234
|
+
declare function hashEncryptedAmountInput(encryptedAmountInput: `0x${string}`): `0x${string}`;
|
|
235
|
+
declare function normalizeAmount(amount: string | number | bigint): string;
|
|
236
|
+
|
|
237
|
+
type ConfidentialPaymentAuthorization = {
|
|
238
|
+
holder: `0x${string}`;
|
|
239
|
+
payee: `0x${string}`;
|
|
240
|
+
maxClearAmount: string;
|
|
241
|
+
resourceHash: `0x${string}`;
|
|
242
|
+
validAfter: string;
|
|
243
|
+
validBefore: string;
|
|
244
|
+
nonce: `0x${string}`;
|
|
245
|
+
encryptedAmountHash: `0x${string}`;
|
|
246
|
+
};
|
|
247
|
+
type ConfidentialPaymentPayload = {
|
|
248
|
+
authorization: ConfidentialPaymentAuthorization;
|
|
249
|
+
signature: `0x${string}`;
|
|
250
|
+
encryptedAmountInput: `0x${string}`;
|
|
251
|
+
inputProof: `0x${string}`;
|
|
252
|
+
};
|
|
253
|
+
type ConfidentialRequirementsExtra = {
|
|
254
|
+
eip712: {
|
|
255
|
+
name: string;
|
|
256
|
+
version: string;
|
|
257
|
+
};
|
|
258
|
+
confidential?: {
|
|
259
|
+
maxClearAmount?: string;
|
|
260
|
+
resourceHash?: `0x${string}`;
|
|
261
|
+
batcherAddress?: `0x${string}`;
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
type ConfidentialPaymentInput = {
|
|
265
|
+
encryptedAmountInput: `0x${string}`;
|
|
266
|
+
inputProof: `0x${string}`;
|
|
267
|
+
maxClearAmount?: string;
|
|
268
|
+
resourceHash?: `0x${string}`;
|
|
269
|
+
validAfter?: number;
|
|
270
|
+
validBefore?: number;
|
|
271
|
+
nonce?: `0x${string}`;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export { type ConfidentialErrorCode as C, confidentialPaymentTypes as a, confidentialErrorCodes as b, confidentialTokenAbi as c, createNonce as d, type ConfidentialPaymentAuthorization as e, type ConfidentialPaymentPayload as f, type ConfidentialRequirementsExtra as g, hashEncryptedAmountInput as h, type ConfidentialPaymentInput as i, normalizeAmount as n };
|