@permissionless-technologies/upp-sdk 0.4.15 → 0.4.17
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/{chunk-NIGEAKQP.js → chunk-7BOX7YFZ.js} +4 -3
- package/dist/chunk-7BOX7YFZ.js.map +1 -0
- package/dist/{chunk-TBGDQM33.cjs → chunk-D3XBKPQ2.cjs} +4 -4
- package/dist/{chunk-TBGDQM33.cjs.map → chunk-D3XBKPQ2.cjs.map} +1 -1
- package/dist/{chunk-CZLMCMYE.cjs → chunk-GJXJBDE5.cjs} +4 -3
- package/dist/chunk-GJXJBDE5.cjs.map +1 -0
- package/dist/{chunk-5WLAZA3M.js → chunk-HRHGZKTJ.js} +3 -3
- package/dist/{chunk-5WLAZA3M.js.map → chunk-HRHGZKTJ.js.map} +1 -1
- package/dist/{chunk-YMZM2ABJ.js → chunk-KOT5MTDL.js} +2 -2
- package/dist/{chunk-YMZM2ABJ.js.map → chunk-KOT5MTDL.js.map} +1 -1
- package/dist/{chunk-CTBLNYYB.cjs → chunk-QOMHO6FP.cjs} +2 -2
- package/dist/{chunk-CTBLNYYB.cjs.map → chunk-QOMHO6FP.cjs.map} +1 -1
- package/dist/core/index.cjs +50 -50
- package/dist/core/index.js +2 -2
- package/dist/index.cjs +52 -52
- package/dist/index.js +3 -3
- package/dist/indexer/index.cjs +6 -6
- package/dist/indexer/index.js +1 -1
- package/dist/react/index.cjs +32 -22
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +15 -5
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-CZLMCMYE.cjs.map +0 -1
- package/dist/chunk-NIGEAKQP.js.map +0 -1
package/dist/react/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkGJXJBDE5_cjs = require('../chunk-GJXJBDE5.cjs');
|
|
4
4
|
var chunkXVIICZKW_cjs = require('../chunk-XVIICZKW.cjs');
|
|
5
5
|
var chunkERQE57IA_cjs = require('../chunk-ERQE57IA.cjs');
|
|
6
6
|
require('../chunk-UFEDJJSH.cjs');
|
|
@@ -107,7 +107,7 @@ function UPPAccountProvider({
|
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
const accountStorage = chunkERQE57IA_cjs.createAutoAdapter(`upp_account`);
|
|
110
|
-
const adapter = new
|
|
110
|
+
const adapter = new chunkGJXJBDE5_cjs.StorableAccountAdapter(accountStorage, ethAddress);
|
|
111
111
|
accountAdapterRef.current = adapter;
|
|
112
112
|
const legacyKey = getStorageKey(ethAddress);
|
|
113
113
|
const legacySaved = typeof window !== "undefined" ? localStorage.getItem(legacyKey) : null;
|
|
@@ -148,7 +148,7 @@ function UPPAccountProvider({
|
|
|
148
148
|
const ownerHashHex2 = viem.toHex(account.keys.ownerHash, { size: 32 });
|
|
149
149
|
const storagePrefix = `upp_${chainId}_${ownerHashHex2.slice(0, 12)}`;
|
|
150
150
|
const noteStorage = chunkERQE57IA_cjs.createAutoAdapter(storagePrefix);
|
|
151
|
-
const store = new
|
|
151
|
+
const store = new chunkGJXJBDE5_cjs.NoteStore(noteStorage, "notes");
|
|
152
152
|
noteStoreRef.current = store;
|
|
153
153
|
noteStoreUnsub = store.onChange(() => {
|
|
154
154
|
if (!cancelled) setNotes([...store.getNotes()]);
|
|
@@ -849,7 +849,7 @@ function UPPAccountProvider({
|
|
|
849
849
|
const stealthAddress = react.useMemo(() => {
|
|
850
850
|
if (!masterKeys) return null;
|
|
851
851
|
try {
|
|
852
|
-
const { encodeStealthAddress } = (
|
|
852
|
+
const { encodeStealthAddress } = (chunkGJXJBDE5_cjs.init_stealth(), chunkG7VZBCD6_cjs.__toCommonJS(chunkGJXJBDE5_cjs.stealth_exports));
|
|
853
853
|
return encodeStealthAddress(masterKeys.ownerHash, masterKeys.viewingHash);
|
|
854
854
|
} catch {
|
|
855
855
|
return null;
|
|
@@ -858,7 +858,7 @@ function UPPAccountProvider({
|
|
|
858
858
|
const starkStealthAddress = react.useMemo(() => {
|
|
859
859
|
if (!starkMasterKeys) return null;
|
|
860
860
|
try {
|
|
861
|
-
const { encodeStarkStealthAddress } = (
|
|
861
|
+
const { encodeStarkStealthAddress } = (chunkGJXJBDE5_cjs.init_stealth(), chunkG7VZBCD6_cjs.__toCommonJS(chunkGJXJBDE5_cjs.stealth_exports));
|
|
862
862
|
return encodeStarkStealthAddress(starkMasterKeys.starkOwnerHash, starkMasterKeys.starkViewingHash);
|
|
863
863
|
} catch {
|
|
864
864
|
return null;
|
|
@@ -1745,7 +1745,7 @@ function usePoolTransfer(config) {
|
|
|
1745
1745
|
changeNoteWithAmount
|
|
1746
1746
|
);
|
|
1747
1747
|
setProvingProgress(null);
|
|
1748
|
-
const { proof } = await
|
|
1748
|
+
const { proof } = await chunkGJXJBDE5_cjs.generateUPPProofAsync(
|
|
1749
1749
|
"transfer",
|
|
1750
1750
|
circuitInputs,
|
|
1751
1751
|
cfg.circuitBaseUrl ?? "/circuits/",
|
|
@@ -1928,7 +1928,7 @@ function useWithdraw(config) {
|
|
|
1928
1928
|
aspPathIndices: Array(ASP_TREE_DEPTH2).fill("0")
|
|
1929
1929
|
};
|
|
1930
1930
|
setProvingProgress(null);
|
|
1931
|
-
const { proof } = await
|
|
1931
|
+
const { proof } = await chunkGJXJBDE5_cjs.generateUPPProofAsync(
|
|
1932
1932
|
"withdraw",
|
|
1933
1933
|
circuitInputs,
|
|
1934
1934
|
cfg.circuitBaseUrl ?? "/circuits/",
|
|
@@ -2123,7 +2123,7 @@ function useSwapOrderBook(config) {
|
|
|
2123
2123
|
try {
|
|
2124
2124
|
const logs = await config.publicClient.getLogs({
|
|
2125
2125
|
address: config.poolAddress,
|
|
2126
|
-
event:
|
|
2126
|
+
event: chunkGJXJBDE5_cjs.SWAP_ORDER_PLACED_EVENT,
|
|
2127
2127
|
fromBlock: config.fromBlock ?? 0n,
|
|
2128
2128
|
toBlock: "latest"
|
|
2129
2129
|
});
|
|
@@ -2139,10 +2139,10 @@ function useSwapOrderBook(config) {
|
|
|
2139
2139
|
blockNumber: log.blockNumber ?? 0n
|
|
2140
2140
|
}));
|
|
2141
2141
|
if (config.sellToken && config.buyToken) {
|
|
2142
|
-
parsedOrders =
|
|
2142
|
+
parsedOrders = chunkGJXJBDE5_cjs.filterOrdersByTokenPair(parsedOrders, config.sellToken, config.buyToken);
|
|
2143
2143
|
}
|
|
2144
2144
|
if (config.acceptableAspIds && config.acceptableAspIds.length > 0) {
|
|
2145
|
-
parsedOrders =
|
|
2145
|
+
parsedOrders = chunkGJXJBDE5_cjs.filterOrdersByASP(parsedOrders, config.acceptableAspIds);
|
|
2146
2146
|
}
|
|
2147
2147
|
const enriched = [];
|
|
2148
2148
|
for (const order of parsedOrders) {
|
|
@@ -2306,7 +2306,7 @@ function useSwap(config) {
|
|
|
2306
2306
|
aspPathIndices: padToDepth2(aspProofData.aspPathIndices.map(String), "0", ASP_TREE_DEPTH3)
|
|
2307
2307
|
};
|
|
2308
2308
|
setProvingProgress(null);
|
|
2309
|
-
const { proof } = await
|
|
2309
|
+
const { proof } = await chunkGJXJBDE5_cjs.generateUPPProofAsync(
|
|
2310
2310
|
"withdraw",
|
|
2311
2311
|
circuitInputs,
|
|
2312
2312
|
cfg.circuitBaseUrl ?? "/circuits/",
|
|
@@ -2316,8 +2316,8 @@ function useSwap(config) {
|
|
|
2316
2316
|
}
|
|
2317
2317
|
);
|
|
2318
2318
|
const formattedProof = await formatPlonkProofForContract(proof);
|
|
2319
|
-
const cancelSecret =
|
|
2320
|
-
const cancelKeyHash =
|
|
2319
|
+
const cancelSecret = chunkGJXJBDE5_cjs.generateCancelSecret();
|
|
2320
|
+
const cancelKeyHash = chunkGJXJBDE5_cjs.computeCancelKeyHash(cancelSecret);
|
|
2321
2321
|
const currentBlock = await cfg.publicClient.getBlockNumber();
|
|
2322
2322
|
const expiry = currentBlock + expiryBlocks;
|
|
2323
2323
|
return {
|
|
@@ -2366,7 +2366,7 @@ function useSwap(config) {
|
|
|
2366
2366
|
noteOverride
|
|
2367
2367
|
} = params;
|
|
2368
2368
|
const cfg = configRef.current;
|
|
2369
|
-
const giveAmount =
|
|
2369
|
+
const giveAmount = chunkGJXJBDE5_cjs.computeGiveAmount(takeAmount, rate);
|
|
2370
2370
|
setStage("selecting_notes");
|
|
2371
2371
|
let selectedNote;
|
|
2372
2372
|
if (noteOverride) {
|
|
@@ -2459,7 +2459,7 @@ function useSwap(config) {
|
|
|
2459
2459
|
aspPathIndices: padToDepth2(aspProofData.aspPathIndices.map(String), "0", ASP_TREE_DEPTH3)
|
|
2460
2460
|
};
|
|
2461
2461
|
setProvingProgress(null);
|
|
2462
|
-
const { proof } = await
|
|
2462
|
+
const { proof } = await chunkGJXJBDE5_cjs.generateUPPProofAsync(
|
|
2463
2463
|
"withdraw",
|
|
2464
2464
|
circuitInputs,
|
|
2465
2465
|
cfg.circuitBaseUrl ?? "/circuits/",
|
|
@@ -2533,13 +2533,18 @@ function useSwap(config) {
|
|
|
2533
2533
|
);
|
|
2534
2534
|
}
|
|
2535
2535
|
const zeroHex = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
2536
|
+
const { encodePacked: encodePacked3 } = await import('viem');
|
|
2537
|
+
const packNote = (note) => encodePacked3(
|
|
2538
|
+
["uint64", "uint256", "bytes"],
|
|
2539
|
+
[note.searchTag, note.ownerHash, note.encryptedNote]
|
|
2540
|
+
);
|
|
2536
2541
|
return {
|
|
2537
2542
|
orderId,
|
|
2538
2543
|
cancelSecret,
|
|
2539
2544
|
buyOutputCommitment: buyNoteData ? viem.toHex(buyNoteData.commitment, { size: 32 }) : zeroHex,
|
|
2540
2545
|
refundCommitment: refundNoteData ? viem.toHex(refundNoteData.commitment, { size: 32 }) : zeroHex,
|
|
2541
|
-
buyEncryptedNote: buyNoteData ? buyNoteData
|
|
2542
|
-
refundEncryptedNote: refundNoteData ? refundNoteData
|
|
2546
|
+
buyEncryptedNote: buyNoteData ? packNote(buyNoteData) : "0x",
|
|
2547
|
+
refundEncryptedNote: refundNoteData ? packNote(refundNoteData) : "0x",
|
|
2543
2548
|
buyNoteData,
|
|
2544
2549
|
refundNoteData
|
|
2545
2550
|
};
|
|
@@ -2570,11 +2575,16 @@ function useSwap(config) {
|
|
|
2570
2575
|
cancelOrigin,
|
|
2571
2576
|
BigInt(sellToken)
|
|
2572
2577
|
);
|
|
2578
|
+
const { encodePacked: encodePacked3 } = await import('viem');
|
|
2579
|
+
const packedRefund = encodePacked3(
|
|
2580
|
+
["uint64", "uint256", "bytes"],
|
|
2581
|
+
[refundNoteData.searchTag, refundNoteData.ownerHash, refundNoteData.encryptedNote]
|
|
2582
|
+
);
|
|
2573
2583
|
return {
|
|
2574
2584
|
orderId,
|
|
2575
2585
|
cancelSecret,
|
|
2576
2586
|
refundCommitment: viem.toHex(refundNoteData.commitment, { size: 32 }),
|
|
2577
|
-
refundEncryptedNote:
|
|
2587
|
+
refundEncryptedNote: packedRefund,
|
|
2578
2588
|
refundNoteData
|
|
2579
2589
|
};
|
|
2580
2590
|
} catch (err) {
|
|
@@ -2645,7 +2655,7 @@ function useSwap(config) {
|
|
|
2645
2655
|
changeNoteWithAmount
|
|
2646
2656
|
);
|
|
2647
2657
|
setProvingProgress(null);
|
|
2648
|
-
const { proof } = await
|
|
2658
|
+
const { proof } = await chunkGJXJBDE5_cjs.generateUPPProofAsync(
|
|
2649
2659
|
"transfer",
|
|
2650
2660
|
circuitInputs,
|
|
2651
2661
|
cfg.circuitBaseUrl ?? "/circuits/",
|
|
@@ -2735,7 +2745,7 @@ function useProofWorker(worker) {
|
|
|
2735
2745
|
managerRef.current = null;
|
|
2736
2746
|
return;
|
|
2737
2747
|
}
|
|
2738
|
-
const manager = new
|
|
2748
|
+
const manager = new chunkGJXJBDE5_cjs.ProofWorkerManager(worker);
|
|
2739
2749
|
managerRef.current = manager;
|
|
2740
2750
|
return () => {
|
|
2741
2751
|
manager.terminate();
|
|
@@ -2747,11 +2757,11 @@ function useProofWorker(worker) {
|
|
|
2747
2757
|
|
|
2748
2758
|
Object.defineProperty(exports, "ProofWorkerManager", {
|
|
2749
2759
|
enumerable: true,
|
|
2750
|
-
get: function () { return
|
|
2760
|
+
get: function () { return chunkGJXJBDE5_cjs.ProofWorkerManager; }
|
|
2751
2761
|
});
|
|
2752
2762
|
Object.defineProperty(exports, "generateUPPProofAsync", {
|
|
2753
2763
|
enumerable: true,
|
|
2754
|
-
get: function () { return
|
|
2764
|
+
get: function () { return chunkGJXJBDE5_cjs.generateUPPProofAsync; }
|
|
2755
2765
|
});
|
|
2756
2766
|
Object.defineProperty(exports, "ASP_TREE_DEPTH", {
|
|
2757
2767
|
enumerable: true,
|