x402z-shared-web 0.0.13 → 0.0.15
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 +7 -38
- package/dist/index.d.ts +7 -38
- package/dist/index.js +10 -6
- package/dist/index.mjs +10 -6
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -168,9 +168,9 @@ declare const confidentialTokenAbi: readonly [{
|
|
|
168
168
|
readonly name: "p";
|
|
169
169
|
readonly type: "tuple";
|
|
170
170
|
}, {
|
|
171
|
-
readonly internalType: "
|
|
171
|
+
readonly internalType: "externalEuint64";
|
|
172
172
|
readonly name: "encryptedAmountInput";
|
|
173
|
-
readonly type: "
|
|
173
|
+
readonly type: "bytes32";
|
|
174
174
|
}, {
|
|
175
175
|
readonly internalType: "bytes";
|
|
176
176
|
readonly name: "inputProof";
|
|
@@ -413,46 +413,15 @@ type BrowserSigner = {
|
|
|
413
413
|
declare function getBrowserEthereumProvider(): BrowserEthereumProvider;
|
|
414
414
|
declare function createBrowserSigner(provider?: BrowserEthereumProvider): Promise<BrowserSigner>;
|
|
415
415
|
|
|
416
|
-
interface RelayerInstance {
|
|
417
|
-
createEncryptedInput: (contractAddress: string, senderAddress: string) => {
|
|
418
|
-
add64: (amount: number) => {
|
|
419
|
-
encrypt: () => Promise<{
|
|
420
|
-
handles: Array<string | Uint8Array>;
|
|
421
|
-
inputProof: string | Uint8Array;
|
|
422
|
-
}>;
|
|
423
|
-
};
|
|
424
|
-
};
|
|
425
|
-
generateKeypair: () => {
|
|
426
|
-
publicKey: string;
|
|
427
|
-
privateKey: string;
|
|
428
|
-
};
|
|
429
|
-
createEIP712: (publicKey: string, contractAddresses: string[], startTimestamp: string, durationDays: string) => {
|
|
430
|
-
domain: Record<string, unknown>;
|
|
431
|
-
types: Record<string, Array<{
|
|
432
|
-
name: string;
|
|
433
|
-
type: string;
|
|
434
|
-
}>>;
|
|
435
|
-
message: Record<string, unknown>;
|
|
436
|
-
};
|
|
437
|
-
userDecrypt: (handles: Array<{
|
|
438
|
-
handle: string;
|
|
439
|
-
contractAddress: string;
|
|
440
|
-
}>, privateKey: string, publicKey: string, signature: string, contractAddresses: string[], address: string, startTimestamp: string, durationDays: string) => Promise<Record<string, bigint> | {
|
|
441
|
-
clearValues?: Record<string, bigint>;
|
|
442
|
-
}>;
|
|
443
|
-
publicDecrypt: (handles: string[]) => Promise<{
|
|
444
|
-
clearValues: Record<string, bigint>;
|
|
445
|
-
decryptionProof: string;
|
|
446
|
-
}>;
|
|
447
|
-
}
|
|
448
416
|
type RelayerWebModule = typeof relayerWeb;
|
|
417
|
+
type RelayerInstance = Awaited<ReturnType<RelayerWebModule["createInstance"]>>;
|
|
449
418
|
type RelayerSdkModule = {
|
|
450
419
|
createInstance: RelayerWebModule["createInstance"];
|
|
451
420
|
initSDK: RelayerWebModule["initSDK"];
|
|
452
421
|
SepoliaConfig: RelayerWebModule["SepoliaConfig"];
|
|
453
422
|
};
|
|
454
423
|
type FhevmInstanceConfig = Parameters<RelayerWebModule["createInstance"]>[0];
|
|
455
|
-
declare const SepoliaConfig:
|
|
424
|
+
declare const SepoliaConfig: RelayerWebModule["SepoliaConfig"];
|
|
456
425
|
declare function getSepoliaConfig(): RelayerWebModule["SepoliaConfig"];
|
|
457
426
|
type RelayerSigner = {
|
|
458
427
|
address: string;
|
|
@@ -471,13 +440,13 @@ type RelayerSigner = {
|
|
|
471
440
|
};
|
|
472
441
|
declare function createRelayer(config: FhevmInstanceConfig): Promise<RelayerInstance>;
|
|
473
442
|
declare function initSDK(params?: Parameters<RelayerSdkModule["initSDK"]>[0]): Promise<boolean>;
|
|
474
|
-
declare function createEncryptedAmountInput(relayer: RelayerInstance, contractAddress: string,
|
|
443
|
+
declare function createEncryptedAmountInput(relayer: RelayerInstance, contractAddress: string, callerAddress: string, amount: number): Promise<{
|
|
475
444
|
handle: `0x${string}`;
|
|
476
445
|
inputProof: `0x${string}`;
|
|
477
446
|
}>;
|
|
478
447
|
declare function decryptEuint64(relayer: RelayerInstance, handle: string, contractAddress: string, signer: RelayerSigner, options?: {
|
|
479
|
-
durationDays?:
|
|
480
|
-
startTimestamp?:
|
|
448
|
+
durationDays?: number;
|
|
449
|
+
startTimestamp?: number;
|
|
481
450
|
}): Promise<bigint>;
|
|
482
451
|
declare function publicDecrypt(relayer: RelayerInstance, handles: string[]): Promise<{
|
|
483
452
|
clearValues: Record<string, bigint>;
|
package/dist/index.d.ts
CHANGED
|
@@ -168,9 +168,9 @@ declare const confidentialTokenAbi: readonly [{
|
|
|
168
168
|
readonly name: "p";
|
|
169
169
|
readonly type: "tuple";
|
|
170
170
|
}, {
|
|
171
|
-
readonly internalType: "
|
|
171
|
+
readonly internalType: "externalEuint64";
|
|
172
172
|
readonly name: "encryptedAmountInput";
|
|
173
|
-
readonly type: "
|
|
173
|
+
readonly type: "bytes32";
|
|
174
174
|
}, {
|
|
175
175
|
readonly internalType: "bytes";
|
|
176
176
|
readonly name: "inputProof";
|
|
@@ -413,46 +413,15 @@ type BrowserSigner = {
|
|
|
413
413
|
declare function getBrowserEthereumProvider(): BrowserEthereumProvider;
|
|
414
414
|
declare function createBrowserSigner(provider?: BrowserEthereumProvider): Promise<BrowserSigner>;
|
|
415
415
|
|
|
416
|
-
interface RelayerInstance {
|
|
417
|
-
createEncryptedInput: (contractAddress: string, senderAddress: string) => {
|
|
418
|
-
add64: (amount: number) => {
|
|
419
|
-
encrypt: () => Promise<{
|
|
420
|
-
handles: Array<string | Uint8Array>;
|
|
421
|
-
inputProof: string | Uint8Array;
|
|
422
|
-
}>;
|
|
423
|
-
};
|
|
424
|
-
};
|
|
425
|
-
generateKeypair: () => {
|
|
426
|
-
publicKey: string;
|
|
427
|
-
privateKey: string;
|
|
428
|
-
};
|
|
429
|
-
createEIP712: (publicKey: string, contractAddresses: string[], startTimestamp: string, durationDays: string) => {
|
|
430
|
-
domain: Record<string, unknown>;
|
|
431
|
-
types: Record<string, Array<{
|
|
432
|
-
name: string;
|
|
433
|
-
type: string;
|
|
434
|
-
}>>;
|
|
435
|
-
message: Record<string, unknown>;
|
|
436
|
-
};
|
|
437
|
-
userDecrypt: (handles: Array<{
|
|
438
|
-
handle: string;
|
|
439
|
-
contractAddress: string;
|
|
440
|
-
}>, privateKey: string, publicKey: string, signature: string, contractAddresses: string[], address: string, startTimestamp: string, durationDays: string) => Promise<Record<string, bigint> | {
|
|
441
|
-
clearValues?: Record<string, bigint>;
|
|
442
|
-
}>;
|
|
443
|
-
publicDecrypt: (handles: string[]) => Promise<{
|
|
444
|
-
clearValues: Record<string, bigint>;
|
|
445
|
-
decryptionProof: string;
|
|
446
|
-
}>;
|
|
447
|
-
}
|
|
448
416
|
type RelayerWebModule = typeof relayerWeb;
|
|
417
|
+
type RelayerInstance = Awaited<ReturnType<RelayerWebModule["createInstance"]>>;
|
|
449
418
|
type RelayerSdkModule = {
|
|
450
419
|
createInstance: RelayerWebModule["createInstance"];
|
|
451
420
|
initSDK: RelayerWebModule["initSDK"];
|
|
452
421
|
SepoliaConfig: RelayerWebModule["SepoliaConfig"];
|
|
453
422
|
};
|
|
454
423
|
type FhevmInstanceConfig = Parameters<RelayerWebModule["createInstance"]>[0];
|
|
455
|
-
declare const SepoliaConfig:
|
|
424
|
+
declare const SepoliaConfig: RelayerWebModule["SepoliaConfig"];
|
|
456
425
|
declare function getSepoliaConfig(): RelayerWebModule["SepoliaConfig"];
|
|
457
426
|
type RelayerSigner = {
|
|
458
427
|
address: string;
|
|
@@ -471,13 +440,13 @@ type RelayerSigner = {
|
|
|
471
440
|
};
|
|
472
441
|
declare function createRelayer(config: FhevmInstanceConfig): Promise<RelayerInstance>;
|
|
473
442
|
declare function initSDK(params?: Parameters<RelayerSdkModule["initSDK"]>[0]): Promise<boolean>;
|
|
474
|
-
declare function createEncryptedAmountInput(relayer: RelayerInstance, contractAddress: string,
|
|
443
|
+
declare function createEncryptedAmountInput(relayer: RelayerInstance, contractAddress: string, callerAddress: string, amount: number): Promise<{
|
|
475
444
|
handle: `0x${string}`;
|
|
476
445
|
inputProof: `0x${string}`;
|
|
477
446
|
}>;
|
|
478
447
|
declare function decryptEuint64(relayer: RelayerInstance, handle: string, contractAddress: string, signer: RelayerSigner, options?: {
|
|
479
|
-
durationDays?:
|
|
480
|
-
startTimestamp?:
|
|
448
|
+
durationDays?: number;
|
|
449
|
+
startTimestamp?: number;
|
|
481
450
|
}): Promise<bigint>;
|
|
482
451
|
declare function publicDecrypt(relayer: RelayerInstance, handles: string[]): Promise<{
|
|
483
452
|
clearValues: Record<string, bigint>;
|
package/dist/index.js
CHANGED
|
@@ -137,7 +137,11 @@ var confidentialTokenAbi = [
|
|
|
137
137
|
name: "p",
|
|
138
138
|
type: "tuple"
|
|
139
139
|
},
|
|
140
|
-
{
|
|
140
|
+
{
|
|
141
|
+
internalType: "externalEuint64",
|
|
142
|
+
name: "encryptedAmountInput",
|
|
143
|
+
type: "bytes32"
|
|
144
|
+
},
|
|
141
145
|
{ internalType: "bytes", name: "inputProof", type: "bytes" },
|
|
142
146
|
{ internalType: "bytes", name: "sig", type: "bytes" }
|
|
143
147
|
],
|
|
@@ -349,10 +353,10 @@ async function initSDK2(params) {
|
|
|
349
353
|
sdkInitialized = true;
|
|
350
354
|
return result;
|
|
351
355
|
}
|
|
352
|
-
async function createEncryptedAmountInput(relayer, contractAddress,
|
|
356
|
+
async function createEncryptedAmountInput(relayer, contractAddress, callerAddress, amount) {
|
|
353
357
|
const normalizedContract = (0, import_viem2.getAddress)(contractAddress);
|
|
354
|
-
const
|
|
355
|
-
const encrypted = await relayer.createEncryptedInput(normalizedContract,
|
|
358
|
+
const normalizedCaller = (0, import_viem2.getAddress)(callerAddress);
|
|
359
|
+
const encrypted = await relayer.createEncryptedInput(normalizedContract, normalizedCaller).add64(amount).encrypt();
|
|
356
360
|
const handle = typeof encrypted.handles[0] === "string" ? encrypted.handles[0] : (0, import_viem2.toHex)(encrypted.handles[0]);
|
|
357
361
|
const inputProof = typeof encrypted.inputProof === "string" ? encrypted.inputProof : (0, import_viem2.toHex)(encrypted.inputProof);
|
|
358
362
|
return {
|
|
@@ -362,8 +366,8 @@ async function createEncryptedAmountInput(relayer, contractAddress, senderAddres
|
|
|
362
366
|
}
|
|
363
367
|
async function decryptEuint64(relayer, handle, contractAddress, signer, options) {
|
|
364
368
|
const keypair = relayer.generateKeypair();
|
|
365
|
-
const startTimestamp = options?.startTimestamp ?? Math.floor(Date.now() / 1e3)
|
|
366
|
-
const durationDays = options?.durationDays ??
|
|
369
|
+
const startTimestamp = options?.startTimestamp ?? Math.floor(Date.now() / 1e3);
|
|
370
|
+
const durationDays = options?.durationDays ?? 10;
|
|
367
371
|
const contractAddresses = [contractAddress];
|
|
368
372
|
const eip712 = relayer.createEIP712(keypair.publicKey, contractAddresses, startTimestamp, durationDays);
|
|
369
373
|
const types = { UserDecryptRequestVerification: eip712.types.UserDecryptRequestVerification };
|
package/dist/index.mjs
CHANGED
|
@@ -85,7 +85,11 @@ var confidentialTokenAbi = [
|
|
|
85
85
|
name: "p",
|
|
86
86
|
type: "tuple"
|
|
87
87
|
},
|
|
88
|
-
{
|
|
88
|
+
{
|
|
89
|
+
internalType: "externalEuint64",
|
|
90
|
+
name: "encryptedAmountInput",
|
|
91
|
+
type: "bytes32"
|
|
92
|
+
},
|
|
89
93
|
{ internalType: "bytes", name: "inputProof", type: "bytes" },
|
|
90
94
|
{ internalType: "bytes", name: "sig", type: "bytes" }
|
|
91
95
|
],
|
|
@@ -297,10 +301,10 @@ async function initSDK2(params) {
|
|
|
297
301
|
sdkInitialized = true;
|
|
298
302
|
return result;
|
|
299
303
|
}
|
|
300
|
-
async function createEncryptedAmountInput(relayer, contractAddress,
|
|
304
|
+
async function createEncryptedAmountInput(relayer, contractAddress, callerAddress, amount) {
|
|
301
305
|
const normalizedContract = getAddress(contractAddress);
|
|
302
|
-
const
|
|
303
|
-
const encrypted = await relayer.createEncryptedInput(normalizedContract,
|
|
306
|
+
const normalizedCaller = getAddress(callerAddress);
|
|
307
|
+
const encrypted = await relayer.createEncryptedInput(normalizedContract, normalizedCaller).add64(amount).encrypt();
|
|
304
308
|
const handle = typeof encrypted.handles[0] === "string" ? encrypted.handles[0] : toHex2(encrypted.handles[0]);
|
|
305
309
|
const inputProof = typeof encrypted.inputProof === "string" ? encrypted.inputProof : toHex2(encrypted.inputProof);
|
|
306
310
|
return {
|
|
@@ -310,8 +314,8 @@ async function createEncryptedAmountInput(relayer, contractAddress, senderAddres
|
|
|
310
314
|
}
|
|
311
315
|
async function decryptEuint64(relayer, handle, contractAddress, signer, options) {
|
|
312
316
|
const keypair = relayer.generateKeypair();
|
|
313
|
-
const startTimestamp = options?.startTimestamp ?? Math.floor(Date.now() / 1e3)
|
|
314
|
-
const durationDays = options?.durationDays ??
|
|
317
|
+
const startTimestamp = options?.startTimestamp ?? Math.floor(Date.now() / 1e3);
|
|
318
|
+
const durationDays = options?.durationDays ?? 10;
|
|
315
319
|
const contractAddresses = [contractAddress];
|
|
316
320
|
const eip712 = relayer.createEIP712(keypair.publicKey, contractAddresses, startTimestamp, durationDays);
|
|
317
321
|
const types = { UserDecryptRequestVerification: eip712.types.UserDecryptRequestVerification };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x402z-shared-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@x402/core": "^2.0.0",
|
|
19
|
-
"@zama-fhe/relayer-sdk": "0.
|
|
19
|
+
"@zama-fhe/relayer-sdk": "0.4.0-3",
|
|
20
20
|
"viem": "^2.39.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|