@permissionless-technologies/upp-sdk 0.3.1 → 0.3.4
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-56LZ2RV6.js → chunk-3A2XAQPZ.js} +4 -4
- package/dist/{chunk-56LZ2RV6.js.map → chunk-3A2XAQPZ.js.map} +1 -1
- package/dist/{chunk-4MOXKZSE.cjs → chunk-ISA2WEA5.cjs} +4 -4
- package/dist/{chunk-4MOXKZSE.cjs.map → chunk-ISA2WEA5.cjs.map} +1 -1
- package/dist/{chunk-IYOR5TCO.cjs → chunk-KXPZUBPI.cjs} +19 -6
- package/dist/chunk-KXPZUBPI.cjs.map +1 -0
- package/dist/{chunk-GS4UCMW4.js → chunk-OD2SDC4L.js} +3 -3
- package/dist/{chunk-GS4UCMW4.js.map → chunk-OD2SDC4L.js.map} +1 -1
- package/dist/{chunk-7F75NGNB.js → chunk-QKI4QWLT.js} +19 -6
- package/dist/chunk-QKI4QWLT.js.map +1 -0
- package/dist/{chunk-4EMXHMJ5.cjs → chunk-RZE7Z5BR.cjs} +2 -2
- package/dist/{chunk-4EMXHMJ5.cjs.map → chunk-RZE7Z5BR.cjs.map} +1 -1
- package/dist/{chunk-52PPS4AT.cjs → chunk-SJDPDHSD.cjs} +4 -4
- package/dist/{chunk-52PPS4AT.cjs.map → chunk-SJDPDHSD.cjs.map} +1 -1
- package/dist/{chunk-4EDTZQ44.js → chunk-YVFH6RBX.js} +2 -2
- package/dist/{chunk-4EDTZQ44.js.map → chunk-YVFH6RBX.js.map} +1 -1
- package/dist/core/index.cjs +60 -60
- package/dist/core/index.js +4 -4
- package/dist/index.cjs +204 -204
- package/dist/index.js +6 -6
- package/dist/indexer/index.cjs +6 -6
- package/dist/indexer/index.js +1 -1
- package/dist/react/index.cjs +59 -18
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +49 -8
- package/dist/react/index.js.map +1 -1
- package/dist/{transfer-4GJJTWMH.js → transfer-QK3QUIA3.js} +4 -4
- package/dist/{transfer-4GJJTWMH.js.map → transfer-QK3QUIA3.js.map} +1 -1
- package/dist/{transfer-CLBDOA63.cjs → transfer-RCVNV4VC.cjs} +10 -10
- package/dist/{transfer-CLBDOA63.cjs.map → transfer-RCVNV4VC.cjs.map} +1 -1
- package/package.json +1 -1
- package/src/deployments/31337.json +1 -1
- package/dist/chunk-7F75NGNB.js.map +0 -1
- package/dist/chunk-IYOR5TCO.cjs.map +0 -1
package/dist/react/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StorableAccountAdapter, init_stealth, stealth_exports, SWAP_ORDER_PLACED_EVENT, filterOrdersByTokenPair, filterOrdersByASP, generateCancelSecret, computeCancelKeyHash, computeGiveAmount, NoteStore } from '../chunk-
|
|
1
|
+
import { StorableAccountAdapter, init_stealth, stealth_exports, SWAP_ORDER_PLACED_EVENT, filterOrdersByTokenPair, filterOrdersByASP, generateCancelSecret, computeCancelKeyHash, computeGiveAmount, NoteStore } from '../chunk-QKI4QWLT.js';
|
|
2
2
|
import { computeSingleOriginASPRoot } from '../chunk-P37MRZ73.js';
|
|
3
3
|
export { ASP_TREE_DEPTH, buildASPTree, computeMultiOriginASPRoot, computeSingleOriginASPRoot, generateASPProof, generateMultiOriginASPProof, generateSingleOriginASPProof } from '../chunk-P37MRZ73.js';
|
|
4
4
|
import { createAutoAdapter } from '../chunk-XV72HNHN.js';
|
|
@@ -371,8 +371,9 @@ function UPPAccountProvider({
|
|
|
371
371
|
false,
|
|
372
372
|
["decrypt"]
|
|
373
373
|
);
|
|
374
|
+
const currentStore = noteStoreRef.current;
|
|
374
375
|
const existingCommitments = new Set(
|
|
375
|
-
notes.map((n) => n.commitment.toLowerCase())
|
|
376
|
+
(currentStore ? currentStore.getNotes() : notes).map((n) => n.commitment.toLowerCase())
|
|
376
377
|
);
|
|
377
378
|
const candidates = [];
|
|
378
379
|
console.log("[syncNotes] Scanning contract:", contractAddress, "\u2014 existing:", existingCommitments.size, "notes");
|
|
@@ -593,7 +594,41 @@ function UPPAccountProvider({
|
|
|
593
594
|
}
|
|
594
595
|
try {
|
|
595
596
|
const currentNotes = store ? store.getNotes() : notes;
|
|
596
|
-
const
|
|
597
|
+
const snarkNotes = currentNotes.filter((n) => n.proofSystem !== "stark");
|
|
598
|
+
const unspentSnarkNotes = snarkNotes.filter((n) => n.status !== "spent");
|
|
599
|
+
if (unspentSnarkNotes.length > 0) {
|
|
600
|
+
const sdk2 = await loadSDK();
|
|
601
|
+
for (const note of unspentSnarkNotes) {
|
|
602
|
+
const correctLeaf = commitmentLeafMap.get(note.commitment.toLowerCase());
|
|
603
|
+
if (correctLeaf === void 0) continue;
|
|
604
|
+
const ownerSecret = BigInt(note.ownerSecret);
|
|
605
|
+
const commitment = BigInt(note.commitment);
|
|
606
|
+
const nullifier = await sdk2.poseidon([
|
|
607
|
+
ownerSecret % 2736030358979909402780800718157159386076813972158567259200215660948447373041n,
|
|
608
|
+
BigInt(correctLeaf),
|
|
609
|
+
commitment
|
|
610
|
+
]);
|
|
611
|
+
const nullifierHex = toHex(nullifier, { size: 32 });
|
|
612
|
+
const isUsed = await client.readContract({
|
|
613
|
+
address: contractAddress,
|
|
614
|
+
abi: [{
|
|
615
|
+
type: "function",
|
|
616
|
+
name: "nullifierUsed",
|
|
617
|
+
inputs: [{ name: "", type: "bytes32" }],
|
|
618
|
+
outputs: [{ name: "", type: "bool" }],
|
|
619
|
+
stateMutability: "view"
|
|
620
|
+
}],
|
|
621
|
+
functionName: "nullifierUsed",
|
|
622
|
+
args: [nullifierHex]
|
|
623
|
+
});
|
|
624
|
+
if (isUsed) {
|
|
625
|
+
console.log(`[syncNotes] Marking note ${note.commitment.slice(0, 12)} as spent \u2014 nullifier found on-chain`);
|
|
626
|
+
if (store) store.markSpent(note.commitment);
|
|
627
|
+
repaired++;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
const spentSnarkNotes = snarkNotes.filter((n) => n.status === "spent");
|
|
597
632
|
if (spentSnarkNotes.length > 0) {
|
|
598
633
|
const sdk2 = await loadSDK();
|
|
599
634
|
for (const note of spentSnarkNotes) {
|
|
@@ -696,6 +731,12 @@ function UPPAccountProvider({
|
|
|
696
731
|
}
|
|
697
732
|
};
|
|
698
733
|
}, [liveSyncInterval]);
|
|
734
|
+
useEffect(() => {
|
|
735
|
+
const contractAddr = indexerConfig?.contractAddress;
|
|
736
|
+
if (!masterKeys || !publicClientProp || !contractAddr) return;
|
|
737
|
+
startLiveSync(contractAddr, publicClientProp);
|
|
738
|
+
return () => stopLiveSync();
|
|
739
|
+
}, [masterKeys, publicClientProp, indexerConfig?.contractAddress]);
|
|
699
740
|
const ownerHashHex = masterKeys ? toHex(masterKeys.ownerHash, { size: 32 }) : null;
|
|
700
741
|
const stealthAddress = useMemo(() => {
|
|
701
742
|
if (!masterKeys) return null;
|
|
@@ -1560,7 +1601,7 @@ function usePoolTransfer(config) {
|
|
|
1560
1601
|
const recipientNote = await createNoteForSelf(amount, origin, token);
|
|
1561
1602
|
const changeNote = await createNoteForSelf(changeAmount, origin, token);
|
|
1562
1603
|
const [transferModule, proofModule, aspModule] = await Promise.all([
|
|
1563
|
-
import('../transfer-
|
|
1604
|
+
import('../transfer-QK3QUIA3.js'),
|
|
1564
1605
|
import('../proof-C4YBP6RY.js'),
|
|
1565
1606
|
import('../asp-ZA3RGN7G.js')
|
|
1566
1607
|
]);
|
|
@@ -1719,7 +1760,7 @@ function useWithdraw(config) {
|
|
|
1719
1760
|
const token = BigInt(selectedNote.token);
|
|
1720
1761
|
setStage("creating_outputs");
|
|
1721
1762
|
const [transferModule, proofModule, sdk] = await Promise.all([
|
|
1722
|
-
import('../transfer-
|
|
1763
|
+
import('../transfer-QK3QUIA3.js'),
|
|
1723
1764
|
import('../proof-C4YBP6RY.js'),
|
|
1724
1765
|
import('../index.js')
|
|
1725
1766
|
]);
|
|
@@ -2098,7 +2139,7 @@ function useSwap(config) {
|
|
|
2098
2139
|
}
|
|
2099
2140
|
setStage("creating_outputs");
|
|
2100
2141
|
const [transferModule, proofModule, sdk, aspModule] = await Promise.all([
|
|
2101
|
-
import('../transfer-
|
|
2142
|
+
import('../transfer-QK3QUIA3.js'),
|
|
2102
2143
|
import('../proof-C4YBP6RY.js'),
|
|
2103
2144
|
import('../index.js'),
|
|
2104
2145
|
import('../asp-ZA3RGN7G.js')
|
|
@@ -2250,7 +2291,7 @@ function useSwap(config) {
|
|
|
2250
2291
|
}
|
|
2251
2292
|
setStage("creating_outputs");
|
|
2252
2293
|
const [transferModule, proofModule, sdk, aspModule] = await Promise.all([
|
|
2253
|
-
import('../transfer-
|
|
2294
|
+
import('../transfer-QK3QUIA3.js'),
|
|
2254
2295
|
import('../proof-C4YBP6RY.js'),
|
|
2255
2296
|
import('../index.js'),
|
|
2256
2297
|
import('../asp-ZA3RGN7G.js')
|
|
@@ -2480,7 +2521,7 @@ function useSwap(config) {
|
|
|
2480
2521
|
createNoteForSelf(changeAmount, origin, token)
|
|
2481
2522
|
]);
|
|
2482
2523
|
const [transferModule, proofModule, aspModule] = await Promise.all([
|
|
2483
|
-
import('../transfer-
|
|
2524
|
+
import('../transfer-QK3QUIA3.js'),
|
|
2484
2525
|
import('../proof-C4YBP6RY.js'),
|
|
2485
2526
|
import('../asp-ZA3RGN7G.js')
|
|
2486
2527
|
]);
|