x402z-shared 0.0.1

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.mjs ADDED
@@ -0,0 +1,191 @@
1
+ import {
2
+ confidentialPaymentTypes,
3
+ confidentialTokenAbi,
4
+ createNonce,
5
+ hashEncryptedAmountInput,
6
+ normalizeAmount
7
+ } from "./chunk-V7Z3OAXS.mjs";
8
+
9
+ // src/relayer.ts
10
+ import { createInstance, SepoliaConfig } from "@zama-fhe/relayer-sdk/node";
11
+ import { getAddress, toHex } from "viem";
12
+ async function createRelayerInstance(config) {
13
+ return createInstance(config);
14
+ }
15
+ async function createEncryptedAmountInput(relayer, contractAddress, senderAddress, amount) {
16
+ const normalizedContract = getAddress(contractAddress);
17
+ const normalizedSender = getAddress(senderAddress);
18
+ const encrypted = await relayer.createEncryptedInput(normalizedContract, normalizedSender).add64(amount).encrypt();
19
+ const handle = typeof encrypted.handles[0] === "string" ? encrypted.handles[0] : toHex(encrypted.handles[0]);
20
+ const inputProof = typeof encrypted.inputProof === "string" ? encrypted.inputProof : toHex(encrypted.inputProof);
21
+ return {
22
+ handle,
23
+ inputProof
24
+ };
25
+ }
26
+ async function userDecryptEuint64(relayer, handle, contractAddress, signer, options) {
27
+ const keypair = relayer.generateKeypair();
28
+ const startTimestamp = options?.startTimestamp ?? Math.floor(Date.now() / 1e3).toString();
29
+ const durationDays = options?.durationDays ?? "10";
30
+ const contractAddresses = [contractAddress];
31
+ const eip712 = relayer.createEIP712(keypair.publicKey, contractAddresses, startTimestamp, durationDays);
32
+ const types = { UserDecryptRequestVerification: eip712.types.UserDecryptRequestVerification };
33
+ const sign = signer.signTypedData;
34
+ const signature = sign.length >= 3 ? await sign(eip712.domain, types, eip712.message) : await sign({
35
+ domain: eip712.domain,
36
+ types,
37
+ primaryType: "UserDecryptRequestVerification",
38
+ message: eip712.message
39
+ });
40
+ const result = await relayer.userDecrypt(
41
+ [{ handle, contractAddress }],
42
+ keypair.privateKey,
43
+ keypair.publicKey,
44
+ signature.replace("0x", ""),
45
+ contractAddresses,
46
+ signer.address,
47
+ startTimestamp,
48
+ durationDays
49
+ );
50
+ return result[handle];
51
+ }
52
+ async function publicDecrypt(relayer, handles) {
53
+ const result = await relayer.publicDecrypt(handles);
54
+ return {
55
+ clearValues: result.clearValues,
56
+ decryptionProof: result.decryptionProof
57
+ };
58
+ }
59
+
60
+ // src/balance.ts
61
+ import { createPublicClient, http, isAddress } from "viem";
62
+ var ZERO_HANDLE = "0x" + "00".repeat(32);
63
+ async function viewConfidentialBalance(options) {
64
+ if (!isAddress(options.tokenAddress)) {
65
+ throw new Error(`Invalid token address: ${options.tokenAddress}`);
66
+ }
67
+ const account = options.account ?? options.signer?.address;
68
+ if (!account || !isAddress(account)) {
69
+ throw new Error(`Invalid account address: ${account ?? "undefined"}`);
70
+ }
71
+ const publicClient = createPublicClient({ transport: http(options.rpcUrl) });
72
+ const confidentialBalanceAbi = [
73
+ {
74
+ inputs: [{ internalType: "address", name: "account", type: "address" }],
75
+ name: "confidentialBalanceOf",
76
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
77
+ stateMutability: "view",
78
+ type: "function"
79
+ }
80
+ ];
81
+ const handle = await publicClient.readContract({
82
+ address: options.tokenAddress,
83
+ abi: confidentialBalanceAbi,
84
+ functionName: "confidentialBalanceOf",
85
+ args: [account]
86
+ });
87
+ const shouldDecrypt = options.decrypt ?? true;
88
+ if (!shouldDecrypt) {
89
+ return { handle };
90
+ }
91
+ if (!options.signer) {
92
+ throw new Error("Missing signer for decryption");
93
+ }
94
+ if (handle === ZERO_HANDLE) {
95
+ return { handle, balance: 0n };
96
+ }
97
+ const balance = await userDecryptEuint64(
98
+ options.relayer,
99
+ handle,
100
+ options.tokenAddress,
101
+ options.signer
102
+ );
103
+ return { handle, balance };
104
+ }
105
+
106
+ // src/transfer.ts
107
+ import { createPublicClient as createPublicClient2, decodeEventLog, getAddress as getAddress2, http as http2, isAddress as isAddress2, isHex } from "viem";
108
+ async function viewConfidentialTransferAmounts(options) {
109
+ if (!isAddress2(options.tokenAddress)) {
110
+ throw new Error(`Invalid token address: ${options.tokenAddress}`);
111
+ }
112
+ if (!isHex(options.txHash, { strict: true })) {
113
+ throw new Error(`Invalid transaction hash: ${options.txHash}`);
114
+ }
115
+ if (options.from && !isAddress2(options.from)) {
116
+ throw new Error(`Invalid from address: ${options.from}`);
117
+ }
118
+ if (options.to && !isAddress2(options.to)) {
119
+ throw new Error(`Invalid to address: ${options.to}`);
120
+ }
121
+ const publicClient = createPublicClient2({ transport: http2(options.rpcUrl) });
122
+ const receipt = await publicClient.getTransactionReceipt({
123
+ hash: options.txHash
124
+ });
125
+ const tokenAddress = getAddress2(options.tokenAddress);
126
+ const fromFilter = options.from ? getAddress2(options.from) : void 0;
127
+ const toFilter = options.to ? getAddress2(options.to) : void 0;
128
+ const logs = receipt.logs.filter((log) => getAddress2(log.address) === tokenAddress);
129
+ const transfers = [];
130
+ for (const log of logs) {
131
+ try {
132
+ const decoded = decodeEventLog({
133
+ abi: confidentialTokenAbi,
134
+ eventName: "ConfidentialPaymentExecuted",
135
+ data: log.data,
136
+ topics: log.topics
137
+ });
138
+ const args = decoded.args;
139
+ const entry = {
140
+ holder: getAddress2(args.holder),
141
+ payee: getAddress2(args.payee),
142
+ maxClearAmount: BigInt(args.maxClearAmount),
143
+ resourceHash: args.resourceHash,
144
+ nonce: args.nonce,
145
+ handle: args.transferredAmount
146
+ };
147
+ if (fromFilter && entry.holder !== fromFilter) {
148
+ continue;
149
+ }
150
+ if (toFilter && entry.payee !== toFilter) {
151
+ continue;
152
+ }
153
+ const shouldDecrypt = options.decrypt ?? true;
154
+ if (shouldDecrypt) {
155
+ if (!options.signer) {
156
+ throw new Error("Missing signer for decryption");
157
+ }
158
+ const signerAddress = getAddress2(options.signer.address);
159
+ if (signerAddress !== getAddress2(entry.holder) && signerAddress !== getAddress2(entry.payee)) {
160
+ throw new Error("Signer must be the holder or payee to decrypt transfer amount");
161
+ }
162
+ entry.amount = await userDecryptEuint64(
163
+ options.relayer,
164
+ entry.handle,
165
+ tokenAddress,
166
+ options.signer
167
+ );
168
+ }
169
+ transfers.push(entry);
170
+ } catch (error) {
171
+ if (error instanceof Error && error.message.includes("ConfidentialPaymentExecuted")) {
172
+ throw error;
173
+ }
174
+ }
175
+ }
176
+ return transfers;
177
+ }
178
+ export {
179
+ SepoliaConfig,
180
+ confidentialPaymentTypes,
181
+ confidentialTokenAbi,
182
+ createEncryptedAmountInput,
183
+ createNonce,
184
+ createRelayerInstance,
185
+ hashEncryptedAmountInput,
186
+ normalizeAmount,
187
+ publicDecrypt,
188
+ userDecryptEuint64,
189
+ viewConfidentialBalance,
190
+ viewConfidentialTransferAmounts
191
+ };
@@ -0,0 +1,184 @@
1
+ declare const confidentialTokenAbi: readonly [{
2
+ readonly inputs: readonly [{
3
+ readonly components: readonly [{
4
+ readonly internalType: "address";
5
+ readonly name: "holder";
6
+ readonly type: "address";
7
+ }, {
8
+ readonly internalType: "address";
9
+ readonly name: "payee";
10
+ readonly type: "address";
11
+ }, {
12
+ readonly internalType: "uint256";
13
+ readonly name: "maxClearAmount";
14
+ readonly type: "uint256";
15
+ }, {
16
+ readonly internalType: "bytes32";
17
+ readonly name: "resourceHash";
18
+ readonly type: "bytes32";
19
+ }, {
20
+ readonly internalType: "uint48";
21
+ readonly name: "validAfter";
22
+ readonly type: "uint48";
23
+ }, {
24
+ readonly internalType: "uint48";
25
+ readonly name: "validBefore";
26
+ readonly type: "uint48";
27
+ }, {
28
+ readonly internalType: "bytes32";
29
+ readonly name: "nonce";
30
+ readonly type: "bytes32";
31
+ }, {
32
+ readonly internalType: "bytes32";
33
+ readonly name: "encryptedAmountHash";
34
+ readonly type: "bytes32";
35
+ }];
36
+ readonly internalType: "struct FHEToken.ConfidentialPayment";
37
+ readonly name: "p";
38
+ readonly type: "tuple";
39
+ }, {
40
+ readonly internalType: "externalEuint64";
41
+ readonly name: "encryptedAmountInput";
42
+ readonly type: "bytes32";
43
+ }, {
44
+ readonly internalType: "bytes";
45
+ readonly name: "inputProof";
46
+ readonly type: "bytes";
47
+ }, {
48
+ readonly internalType: "bytes";
49
+ readonly name: "sig";
50
+ readonly type: "bytes";
51
+ }];
52
+ readonly name: "confidentialTransferWithAuthorization";
53
+ readonly outputs: readonly [{
54
+ readonly internalType: "euint64";
55
+ readonly name: "transferred";
56
+ readonly type: "bytes32";
57
+ }];
58
+ readonly stateMutability: "nonpayable";
59
+ readonly type: "function";
60
+ }, {
61
+ readonly anonymous: false;
62
+ readonly inputs: readonly [{
63
+ readonly indexed: true;
64
+ readonly internalType: "address";
65
+ readonly name: "holder";
66
+ readonly type: "address";
67
+ }, {
68
+ readonly indexed: true;
69
+ readonly internalType: "address";
70
+ readonly name: "payee";
71
+ readonly type: "address";
72
+ }, {
73
+ readonly indexed: false;
74
+ readonly internalType: "uint256";
75
+ readonly name: "maxClearAmount";
76
+ readonly type: "uint256";
77
+ }, {
78
+ readonly indexed: true;
79
+ readonly internalType: "bytes32";
80
+ readonly name: "resourceHash";
81
+ readonly type: "bytes32";
82
+ }, {
83
+ readonly indexed: false;
84
+ readonly internalType: "bytes32";
85
+ readonly name: "nonce";
86
+ readonly type: "bytes32";
87
+ }, {
88
+ readonly indexed: false;
89
+ readonly internalType: "bytes32";
90
+ readonly name: "transferredAmount";
91
+ readonly type: "bytes32";
92
+ }];
93
+ readonly name: "ConfidentialPaymentExecuted";
94
+ readonly type: "event";
95
+ }, {
96
+ readonly inputs: readonly [{
97
+ readonly internalType: "address";
98
+ readonly name: "";
99
+ readonly type: "address";
100
+ }, {
101
+ readonly internalType: "bytes32";
102
+ readonly name: "";
103
+ readonly type: "bytes32";
104
+ }];
105
+ readonly name: "usedNonces";
106
+ readonly outputs: readonly [{
107
+ readonly internalType: "bool";
108
+ readonly name: "";
109
+ readonly type: "bool";
110
+ }];
111
+ readonly stateMutability: "view";
112
+ readonly type: "function";
113
+ }];
114
+
115
+ declare const confidentialPaymentTypes: {
116
+ readonly ConfidentialPayment: readonly [{
117
+ readonly name: "holder";
118
+ readonly type: "address";
119
+ }, {
120
+ readonly name: "payee";
121
+ readonly type: "address";
122
+ }, {
123
+ readonly name: "maxClearAmount";
124
+ readonly type: "uint256";
125
+ }, {
126
+ readonly name: "resourceHash";
127
+ readonly type: "bytes32";
128
+ }, {
129
+ readonly name: "validAfter";
130
+ readonly type: "uint48";
131
+ }, {
132
+ readonly name: "validBefore";
133
+ readonly type: "uint48";
134
+ }, {
135
+ readonly name: "nonce";
136
+ readonly type: "bytes32";
137
+ }, {
138
+ readonly name: "encryptedAmountHash";
139
+ readonly type: "bytes32";
140
+ }];
141
+ };
142
+
143
+ declare function createNonce(): `0x${string}`;
144
+ declare function hashEncryptedAmountInput(encryptedAmountInput: `0x${string}`): `0x${string}`;
145
+ declare function normalizeAmount(amount: string | number | bigint): string;
146
+
147
+ type ConfidentialPaymentAuthorization = {
148
+ holder: `0x${string}`;
149
+ payee: `0x${string}`;
150
+ maxClearAmount: string;
151
+ resourceHash: `0x${string}`;
152
+ validAfter: string;
153
+ validBefore: string;
154
+ nonce: `0x${string}`;
155
+ encryptedAmountHash: `0x${string}`;
156
+ };
157
+ type ConfidentialPaymentPayload = {
158
+ authorization: ConfidentialPaymentAuthorization;
159
+ signature: `0x${string}`;
160
+ encryptedAmountInput: `0x${string}`;
161
+ inputProof: `0x${string}`;
162
+ };
163
+ type ConfidentialRequirementsExtra = {
164
+ eip712: {
165
+ name: string;
166
+ version: string;
167
+ };
168
+ confidential?: {
169
+ maxClearAmount?: string;
170
+ resourceHash?: `0x${string}`;
171
+ facilitatorAddress?: `0x${string}`;
172
+ };
173
+ };
174
+ type ConfidentialPaymentInput = {
175
+ encryptedAmountInput: `0x${string}`;
176
+ inputProof: `0x${string}`;
177
+ maxClearAmount?: string;
178
+ resourceHash?: `0x${string}`;
179
+ validAfter?: number;
180
+ validBefore?: number;
181
+ nonce?: `0x${string}`;
182
+ };
183
+
184
+ export { type ConfidentialPaymentAuthorization as C, confidentialPaymentTypes as a, createNonce as b, confidentialTokenAbi as c, type ConfidentialPaymentPayload as d, type ConfidentialRequirementsExtra as e, type ConfidentialPaymentInput as f, hashEncryptedAmountInput as h, normalizeAmount as n };
@@ -0,0 +1,184 @@
1
+ declare const confidentialTokenAbi: readonly [{
2
+ readonly inputs: readonly [{
3
+ readonly components: readonly [{
4
+ readonly internalType: "address";
5
+ readonly name: "holder";
6
+ readonly type: "address";
7
+ }, {
8
+ readonly internalType: "address";
9
+ readonly name: "payee";
10
+ readonly type: "address";
11
+ }, {
12
+ readonly internalType: "uint256";
13
+ readonly name: "maxClearAmount";
14
+ readonly type: "uint256";
15
+ }, {
16
+ readonly internalType: "bytes32";
17
+ readonly name: "resourceHash";
18
+ readonly type: "bytes32";
19
+ }, {
20
+ readonly internalType: "uint48";
21
+ readonly name: "validAfter";
22
+ readonly type: "uint48";
23
+ }, {
24
+ readonly internalType: "uint48";
25
+ readonly name: "validBefore";
26
+ readonly type: "uint48";
27
+ }, {
28
+ readonly internalType: "bytes32";
29
+ readonly name: "nonce";
30
+ readonly type: "bytes32";
31
+ }, {
32
+ readonly internalType: "bytes32";
33
+ readonly name: "encryptedAmountHash";
34
+ readonly type: "bytes32";
35
+ }];
36
+ readonly internalType: "struct FHEToken.ConfidentialPayment";
37
+ readonly name: "p";
38
+ readonly type: "tuple";
39
+ }, {
40
+ readonly internalType: "externalEuint64";
41
+ readonly name: "encryptedAmountInput";
42
+ readonly type: "bytes32";
43
+ }, {
44
+ readonly internalType: "bytes";
45
+ readonly name: "inputProof";
46
+ readonly type: "bytes";
47
+ }, {
48
+ readonly internalType: "bytes";
49
+ readonly name: "sig";
50
+ readonly type: "bytes";
51
+ }];
52
+ readonly name: "confidentialTransferWithAuthorization";
53
+ readonly outputs: readonly [{
54
+ readonly internalType: "euint64";
55
+ readonly name: "transferred";
56
+ readonly type: "bytes32";
57
+ }];
58
+ readonly stateMutability: "nonpayable";
59
+ readonly type: "function";
60
+ }, {
61
+ readonly anonymous: false;
62
+ readonly inputs: readonly [{
63
+ readonly indexed: true;
64
+ readonly internalType: "address";
65
+ readonly name: "holder";
66
+ readonly type: "address";
67
+ }, {
68
+ readonly indexed: true;
69
+ readonly internalType: "address";
70
+ readonly name: "payee";
71
+ readonly type: "address";
72
+ }, {
73
+ readonly indexed: false;
74
+ readonly internalType: "uint256";
75
+ readonly name: "maxClearAmount";
76
+ readonly type: "uint256";
77
+ }, {
78
+ readonly indexed: true;
79
+ readonly internalType: "bytes32";
80
+ readonly name: "resourceHash";
81
+ readonly type: "bytes32";
82
+ }, {
83
+ readonly indexed: false;
84
+ readonly internalType: "bytes32";
85
+ readonly name: "nonce";
86
+ readonly type: "bytes32";
87
+ }, {
88
+ readonly indexed: false;
89
+ readonly internalType: "bytes32";
90
+ readonly name: "transferredAmount";
91
+ readonly type: "bytes32";
92
+ }];
93
+ readonly name: "ConfidentialPaymentExecuted";
94
+ readonly type: "event";
95
+ }, {
96
+ readonly inputs: readonly [{
97
+ readonly internalType: "address";
98
+ readonly name: "";
99
+ readonly type: "address";
100
+ }, {
101
+ readonly internalType: "bytes32";
102
+ readonly name: "";
103
+ readonly type: "bytes32";
104
+ }];
105
+ readonly name: "usedNonces";
106
+ readonly outputs: readonly [{
107
+ readonly internalType: "bool";
108
+ readonly name: "";
109
+ readonly type: "bool";
110
+ }];
111
+ readonly stateMutability: "view";
112
+ readonly type: "function";
113
+ }];
114
+
115
+ declare const confidentialPaymentTypes: {
116
+ readonly ConfidentialPayment: readonly [{
117
+ readonly name: "holder";
118
+ readonly type: "address";
119
+ }, {
120
+ readonly name: "payee";
121
+ readonly type: "address";
122
+ }, {
123
+ readonly name: "maxClearAmount";
124
+ readonly type: "uint256";
125
+ }, {
126
+ readonly name: "resourceHash";
127
+ readonly type: "bytes32";
128
+ }, {
129
+ readonly name: "validAfter";
130
+ readonly type: "uint48";
131
+ }, {
132
+ readonly name: "validBefore";
133
+ readonly type: "uint48";
134
+ }, {
135
+ readonly name: "nonce";
136
+ readonly type: "bytes32";
137
+ }, {
138
+ readonly name: "encryptedAmountHash";
139
+ readonly type: "bytes32";
140
+ }];
141
+ };
142
+
143
+ declare function createNonce(): `0x${string}`;
144
+ declare function hashEncryptedAmountInput(encryptedAmountInput: `0x${string}`): `0x${string}`;
145
+ declare function normalizeAmount(amount: string | number | bigint): string;
146
+
147
+ type ConfidentialPaymentAuthorization = {
148
+ holder: `0x${string}`;
149
+ payee: `0x${string}`;
150
+ maxClearAmount: string;
151
+ resourceHash: `0x${string}`;
152
+ validAfter: string;
153
+ validBefore: string;
154
+ nonce: `0x${string}`;
155
+ encryptedAmountHash: `0x${string}`;
156
+ };
157
+ type ConfidentialPaymentPayload = {
158
+ authorization: ConfidentialPaymentAuthorization;
159
+ signature: `0x${string}`;
160
+ encryptedAmountInput: `0x${string}`;
161
+ inputProof: `0x${string}`;
162
+ };
163
+ type ConfidentialRequirementsExtra = {
164
+ eip712: {
165
+ name: string;
166
+ version: string;
167
+ };
168
+ confidential?: {
169
+ maxClearAmount?: string;
170
+ resourceHash?: `0x${string}`;
171
+ facilitatorAddress?: `0x${string}`;
172
+ };
173
+ };
174
+ type ConfidentialPaymentInput = {
175
+ encryptedAmountInput: `0x${string}`;
176
+ inputProof: `0x${string}`;
177
+ maxClearAmount?: string;
178
+ resourceHash?: `0x${string}`;
179
+ validAfter?: number;
180
+ validBefore?: number;
181
+ nonce?: `0x${string}`;
182
+ };
183
+
184
+ export { type ConfidentialPaymentAuthorization as C, confidentialPaymentTypes as a, createNonce as b, confidentialTokenAbi as c, type ConfidentialPaymentPayload as d, type ConfidentialRequirementsExtra as e, type ConfidentialPaymentInput as f, hashEncryptedAmountInput as h, normalizeAmount as n };
package/dist/web.d.mts ADDED
@@ -0,0 +1,71 @@
1
+ export { C as ConfidentialPaymentAuthorization, f as ConfidentialPaymentInput, d as ConfidentialPaymentPayload, e as ConfidentialRequirementsExtra, a as confidentialPaymentTypes, c as confidentialTokenAbi, b as createNonce, h as hashEncryptedAmountInput, n as normalizeAmount } from './types-RdcpJuhT.mjs';
2
+ import { createInstance } from '@zama-fhe/relayer-sdk/bundle';
3
+ export { SepoliaConfig, initSDK } from '@zama-fhe/relayer-sdk/bundle';
4
+ export * from '@x402/core/types';
5
+
6
+ type RelayerInstance = Awaited<ReturnType<typeof createInstance>>;
7
+ type RelayerSigner = {
8
+ address: string;
9
+ signTypedData: ((domain: Record<string, unknown>, types: Record<string, Array<{
10
+ name: string;
11
+ type: string;
12
+ }>>, message: Record<string, unknown>) => Promise<string>) | ((args: {
13
+ domain: Record<string, unknown>;
14
+ types: Record<string, Array<{
15
+ name: string;
16
+ type: string;
17
+ }>>;
18
+ primaryType: string;
19
+ message: Record<string, unknown>;
20
+ }) => Promise<string>);
21
+ };
22
+ declare function createRelayerInstance(config: unknown): Promise<RelayerInstance>;
23
+
24
+ declare function createEncryptedAmountInput(relayer: RelayerInstance, contractAddress: string, senderAddress: string, amount: number): Promise<{
25
+ handle: `0x${string}`;
26
+ inputProof: `0x${string}`;
27
+ }>;
28
+ declare function userDecryptEuint64(relayer: RelayerInstance, handle: string, contractAddress: string, signer: RelayerSigner, options?: {
29
+ durationDays?: string;
30
+ startTimestamp?: string;
31
+ }): Promise<bigint>;
32
+ declare function publicDecrypt(relayer: RelayerInstance, handles: string[]): Promise<{
33
+ clearValues: Record<string, bigint>;
34
+ decryptionProof: string;
35
+ }>;
36
+
37
+ type ViewConfidentialBalanceOptions = {
38
+ rpcUrl: string;
39
+ tokenAddress: `0x${string}`;
40
+ account?: `0x${string}`;
41
+ relayer: RelayerInstance;
42
+ signer?: RelayerSigner;
43
+ decrypt?: boolean;
44
+ };
45
+ declare function viewConfidentialBalance(options: ViewConfidentialBalanceOptions): Promise<{
46
+ handle: `0x${string}`;
47
+ balance?: bigint;
48
+ }>;
49
+
50
+ type ConfidentialTransferAmount = {
51
+ holder: `0x${string}`;
52
+ payee: `0x${string}`;
53
+ maxClearAmount: bigint;
54
+ resourceHash: `0x${string}`;
55
+ nonce: `0x${string}`;
56
+ handle: `0x${string}`;
57
+ amount?: bigint;
58
+ };
59
+ type ViewConfidentialTransferOptions = {
60
+ rpcUrl: string;
61
+ tokenAddress: `0x${string}`;
62
+ txHash: `0x${string}`;
63
+ from?: `0x${string}`;
64
+ to?: `0x${string}`;
65
+ relayer: RelayerInstance;
66
+ signer?: RelayerSigner;
67
+ decrypt?: boolean;
68
+ };
69
+ declare function viewConfidentialTransferAmounts(options: ViewConfidentialTransferOptions): Promise<ConfidentialTransferAmount[]>;
70
+
71
+ export { type ConfidentialTransferAmount, type RelayerInstance, type RelayerSigner, type ViewConfidentialBalanceOptions, type ViewConfidentialTransferOptions, createEncryptedAmountInput, createRelayerInstance, publicDecrypt, userDecryptEuint64, viewConfidentialBalance, viewConfidentialTransferAmounts };
package/dist/web.d.ts ADDED
@@ -0,0 +1,71 @@
1
+ export { C as ConfidentialPaymentAuthorization, f as ConfidentialPaymentInput, d as ConfidentialPaymentPayload, e as ConfidentialRequirementsExtra, a as confidentialPaymentTypes, c as confidentialTokenAbi, b as createNonce, h as hashEncryptedAmountInput, n as normalizeAmount } from './types-RdcpJuhT.js';
2
+ import { createInstance } from '@zama-fhe/relayer-sdk/bundle';
3
+ export { SepoliaConfig, initSDK } from '@zama-fhe/relayer-sdk/bundle';
4
+ export * from '@x402/core/types';
5
+
6
+ type RelayerInstance = Awaited<ReturnType<typeof createInstance>>;
7
+ type RelayerSigner = {
8
+ address: string;
9
+ signTypedData: ((domain: Record<string, unknown>, types: Record<string, Array<{
10
+ name: string;
11
+ type: string;
12
+ }>>, message: Record<string, unknown>) => Promise<string>) | ((args: {
13
+ domain: Record<string, unknown>;
14
+ types: Record<string, Array<{
15
+ name: string;
16
+ type: string;
17
+ }>>;
18
+ primaryType: string;
19
+ message: Record<string, unknown>;
20
+ }) => Promise<string>);
21
+ };
22
+ declare function createRelayerInstance(config: unknown): Promise<RelayerInstance>;
23
+
24
+ declare function createEncryptedAmountInput(relayer: RelayerInstance, contractAddress: string, senderAddress: string, amount: number): Promise<{
25
+ handle: `0x${string}`;
26
+ inputProof: `0x${string}`;
27
+ }>;
28
+ declare function userDecryptEuint64(relayer: RelayerInstance, handle: string, contractAddress: string, signer: RelayerSigner, options?: {
29
+ durationDays?: string;
30
+ startTimestamp?: string;
31
+ }): Promise<bigint>;
32
+ declare function publicDecrypt(relayer: RelayerInstance, handles: string[]): Promise<{
33
+ clearValues: Record<string, bigint>;
34
+ decryptionProof: string;
35
+ }>;
36
+
37
+ type ViewConfidentialBalanceOptions = {
38
+ rpcUrl: string;
39
+ tokenAddress: `0x${string}`;
40
+ account?: `0x${string}`;
41
+ relayer: RelayerInstance;
42
+ signer?: RelayerSigner;
43
+ decrypt?: boolean;
44
+ };
45
+ declare function viewConfidentialBalance(options: ViewConfidentialBalanceOptions): Promise<{
46
+ handle: `0x${string}`;
47
+ balance?: bigint;
48
+ }>;
49
+
50
+ type ConfidentialTransferAmount = {
51
+ holder: `0x${string}`;
52
+ payee: `0x${string}`;
53
+ maxClearAmount: bigint;
54
+ resourceHash: `0x${string}`;
55
+ nonce: `0x${string}`;
56
+ handle: `0x${string}`;
57
+ amount?: bigint;
58
+ };
59
+ type ViewConfidentialTransferOptions = {
60
+ rpcUrl: string;
61
+ tokenAddress: `0x${string}`;
62
+ txHash: `0x${string}`;
63
+ from?: `0x${string}`;
64
+ to?: `0x${string}`;
65
+ relayer: RelayerInstance;
66
+ signer?: RelayerSigner;
67
+ decrypt?: boolean;
68
+ };
69
+ declare function viewConfidentialTransferAmounts(options: ViewConfidentialTransferOptions): Promise<ConfidentialTransferAmount[]>;
70
+
71
+ export { type ConfidentialTransferAmount, type RelayerInstance, type RelayerSigner, type ViewConfidentialBalanceOptions, type ViewConfidentialTransferOptions, createEncryptedAmountInput, createRelayerInstance, publicDecrypt, userDecryptEuint64, viewConfidentialBalance, viewConfidentialTransferAmounts };