@permissionless-technologies/upp-sdk 0.3.6 → 0.4.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/{asp-ZA3RGN7G.js → asp-72WUGTQE.js} +3 -3
- package/dist/asp-72WUGTQE.js.map +1 -0
- package/dist/{asp-TXSAFFD3.cjs → asp-CUE3NMBN.cjs} +14 -14
- package/dist/asp-CUE3NMBN.cjs.map +1 -0
- package/dist/{chunk-KXPZUBPI.cjs → chunk-23B5XSS4.cjs} +12 -12
- package/dist/{chunk-KXPZUBPI.cjs.map → chunk-23B5XSS4.cjs.map} +1 -1
- package/dist/{chunk-SQKBT2SH.cjs → chunk-2G22R7AJ.cjs} +18 -7
- package/dist/chunk-2G22R7AJ.cjs.map +1 -0
- package/dist/chunk-5QSSX3KR.js +64 -0
- package/dist/chunk-5QSSX3KR.js.map +1 -0
- package/dist/{chunk-P37MRZ73.js → chunk-6IEYWJVS.js} +8 -8
- package/dist/chunk-6IEYWJVS.js.map +1 -0
- package/dist/{chunk-5V5HSN6Y.js → chunk-6TFDBBAQ.js} +3 -3
- package/dist/{chunk-5V5HSN6Y.js.map → chunk-6TFDBBAQ.js.map} +1 -1
- package/dist/{chunk-ZKZV6OI3.cjs → chunk-7BNJV2ZS.cjs} +21 -21
- package/dist/{chunk-ZKZV6OI3.cjs.map → chunk-7BNJV2ZS.cjs.map} +1 -1
- package/dist/{chunk-XBNYAAMU.js → chunk-7T4CUE6E.js} +3 -3
- package/dist/{chunk-XBNYAAMU.js.map → chunk-7T4CUE6E.js.map} +1 -1
- package/dist/{chunk-NI62M3W3.cjs → chunk-BZD5KJL3.cjs} +2 -2
- package/dist/{chunk-NI62M3W3.cjs.map → chunk-BZD5KJL3.cjs.map} +1 -1
- package/dist/{chunk-OD2SDC4L.js → chunk-CEJN5ZE5.js} +3 -3
- package/dist/{chunk-OD2SDC4L.js.map → chunk-CEJN5ZE5.js.map} +1 -1
- package/dist/{chunk-2JQISXBD.js → chunk-DTEAFJG7.js} +8 -8
- package/dist/{chunk-2JQISXBD.js.map → chunk-DTEAFJG7.js.map} +1 -1
- package/dist/chunk-EHGH6TAW.js +100 -0
- package/dist/chunk-EHGH6TAW.js.map +1 -0
- package/dist/{chunk-ZU6J7KMY.js → chunk-GPF72JFR.js} +3 -3
- package/dist/{chunk-ZU6J7KMY.js.map → chunk-GPF72JFR.js.map} +1 -1
- package/dist/chunk-HEHXSV47.cjs +77 -0
- package/dist/chunk-HEHXSV47.cjs.map +1 -0
- package/dist/chunk-I5EKGD4P.cjs +113 -0
- package/dist/chunk-I5EKGD4P.cjs.map +1 -0
- package/dist/{chunk-EUP7MBAH.cjs → chunk-IIUKM5VE.cjs} +7 -7
- package/dist/{chunk-EUP7MBAH.cjs.map → chunk-IIUKM5VE.cjs.map} +1 -1
- package/dist/{chunk-7Q4RSSHM.js → chunk-MDF37354.js} +2 -2
- package/dist/{chunk-7Q4RSSHM.js.map → chunk-MDF37354.js.map} +1 -1
- package/dist/{chunk-CWSUBAV3.js → chunk-OBBSIPEK.js} +30 -35
- package/dist/chunk-OBBSIPEK.js.map +1 -0
- package/dist/{chunk-FVT2XRRL.cjs → chunk-Q2E432UK.cjs} +41 -46
- package/dist/chunk-Q2E432UK.cjs.map +1 -0
- package/dist/{chunk-QKI4QWLT.js → chunk-RNUG3EFC.js} +6 -6
- package/dist/{chunk-QKI4QWLT.js.map → chunk-RNUG3EFC.js.map} +1 -1
- package/dist/{chunk-3YZSIYJC.cjs → chunk-SWTNJPK5.cjs} +11 -11
- package/dist/{chunk-3YZSIYJC.cjs.map → chunk-SWTNJPK5.cjs.map} +1 -1
- package/dist/{chunk-BH24DZ5S.cjs → chunk-U3YFYMWF.cjs} +5 -5
- package/dist/{chunk-BH24DZ5S.cjs.map → chunk-U3YFYMWF.cjs.map} +1 -1
- package/dist/{chunk-3HQ7A6ZM.cjs → chunk-UFEDJJSH.cjs} +5 -5
- package/dist/{chunk-3HQ7A6ZM.cjs.map → chunk-UFEDJJSH.cjs.map} +1 -1
- package/dist/{chunk-W77GRBO4.js → chunk-UQIM2KT3.js} +3 -3
- package/dist/{chunk-W77GRBO4.js.map → chunk-UQIM2KT3.js.map} +1 -1
- package/dist/{chunk-SJDPDHSD.cjs → chunk-UTAJSERA.cjs} +4 -4
- package/dist/{chunk-SJDPDHSD.cjs.map → chunk-UTAJSERA.cjs.map} +1 -1
- package/dist/{chunk-S4B7GYLN.js → chunk-W3HLIKC2.js} +18 -8
- package/dist/chunk-W3HLIKC2.js.map +1 -0
- package/dist/{chunk-NDM5EJEV.cjs → chunk-XVIICZKW.cjs} +7 -7
- package/dist/chunk-XVIICZKW.cjs.map +1 -0
- package/dist/core/index.cjs +85 -85
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +10 -10
- package/dist/{index-B45-okum.d.cts → index-BgPdYxFS.d.cts} +18 -18
- package/dist/{index-o-Ds3YAq.d.cts → index-CL4vb3ej.d.cts} +1 -1
- package/dist/{index-BIcvNMPt.d.ts → index-CtcXgof_.d.ts} +18 -18
- package/dist/{index-DwAJBoU7.d.ts → index-D6nvfm59.d.ts} +1 -1
- package/dist/index.cjs +279 -280
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +29 -30
- package/dist/index.js.map +1 -1
- package/dist/indexer/index.cjs +6 -6
- package/dist/indexer/index.d.cts +5 -5
- package/dist/indexer/index.d.ts +5 -5
- package/dist/indexer/index.js +1 -1
- package/dist/keys/index.cjs +18 -18
- package/dist/keys/index.js +4 -4
- package/dist/merkle-DZHEOPH3.cjs +30 -0
- package/dist/{merkle-HGDC6OB4.cjs.map → merkle-DZHEOPH3.cjs.map} +1 -1
- package/dist/merkle-IF2RMWCF.js +5 -0
- package/dist/{merkle-7KS2EHRF.js.map → merkle-IF2RMWCF.js.map} +1 -1
- package/dist/poseidon-ACM7E2OH.js +7 -0
- package/dist/{poseidon-UHTJLWQM.js.map → poseidon-ACM7E2OH.js.map} +1 -1
- package/dist/poseidon-PUSGUIVZ.cjs +61 -0
- package/dist/{poseidon-WHJSZSNP.cjs.map → poseidon-PUSGUIVZ.cjs.map} +1 -1
- package/dist/proof-JME3IZTX.js +4 -0
- package/dist/{proof-C4YBP6RY.js.map → proof-JME3IZTX.js.map} +1 -1
- package/dist/proof-XR6XE5PJ.cjs +49 -0
- package/dist/{proof-5OECB3RQ.cjs.map → proof-XR6XE5PJ.cjs.map} +1 -1
- package/dist/react/index.cjs +62 -116
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +27 -12
- package/dist/react/index.d.ts +27 -12
- package/dist/react/index.js +35 -89
- package/dist/react/index.js.map +1 -1
- package/dist/{transfer-BzyernBd.d.cts → transfer-D111ihqN.d.cts} +108 -56
- package/dist/{transfer-sqS6mJko.d.ts → transfer-DvIXqHCr.d.ts} +108 -56
- package/dist/transfer-MQMGSXTH.js +8 -0
- package/dist/{transfer-F6YOQTUL.js.map → transfer-MQMGSXTH.js.map} +1 -1
- package/dist/transfer-PB6D5VCW.cjs +37 -0
- package/dist/{transfer-42C4DXYA.cjs.map → transfer-PB6D5VCW.cjs.map} +1 -1
- package/dist/utils/index.cjs +60 -61
- package/dist/utils/index.d.cts +37 -14
- package/dist/utils/index.d.ts +37 -14
- package/dist/utils/index.js +6 -7
- package/package.json +4 -2
- package/src/contracts/interfaces/IUniversalPrivatePool.sol +10 -8
- package/src/contracts/interfaces/IVerifiers.sol +16 -52
- package/src/deployments/11155111.json +15 -12
- package/dist/asp-TXSAFFD3.cjs.map +0 -1
- package/dist/asp-ZA3RGN7G.js.map +0 -1
- package/dist/babyjubjub-2MGQVCKB.js +0 -5
- package/dist/babyjubjub-2MGQVCKB.js.map +0 -1
- package/dist/babyjubjub-MWZLJOVZ.cjs +0 -66
- package/dist/babyjubjub-MWZLJOVZ.cjs.map +0 -1
- package/dist/chunk-CWSUBAV3.js.map +0 -1
- package/dist/chunk-FVT2XRRL.cjs.map +0 -1
- package/dist/chunk-JWNXBALH.cjs +0 -57
- package/dist/chunk-JWNXBALH.cjs.map +0 -1
- package/dist/chunk-NDM5EJEV.cjs.map +0 -1
- package/dist/chunk-P37MRZ73.js.map +0 -1
- package/dist/chunk-PTDVGWHU.cjs +0 -10
- package/dist/chunk-PTDVGWHU.cjs.map +0 -1
- package/dist/chunk-S4B7GYLN.js.map +0 -1
- package/dist/chunk-SQKBT2SH.cjs.map +0 -1
- package/dist/chunk-TSF6HEVS.cjs +0 -201
- package/dist/chunk-TSF6HEVS.cjs.map +0 -1
- package/dist/chunk-UAVWYXDN.js +0 -8
- package/dist/chunk-UAVWYXDN.js.map +0 -1
- package/dist/chunk-V23OSL25.js +0 -48
- package/dist/chunk-V23OSL25.js.map +0 -1
- package/dist/chunk-YOWDERVC.js +0 -186
- package/dist/chunk-YOWDERVC.js.map +0 -1
- package/dist/merkle-7KS2EHRF.js +0 -5
- package/dist/merkle-HGDC6OB4.cjs +0 -30
- package/dist/poseidon-UHTJLWQM.js +0 -7
- package/dist/poseidon-WHJSZSNP.cjs +0 -45
- package/dist/proof-5OECB3RQ.cjs +0 -45
- package/dist/proof-C4YBP6RY.js +0 -4
- package/dist/transfer-42C4DXYA.cjs +0 -37
- package/dist/transfer-F6YOQTUL.js +0 -8
package/dist/react/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk23B5XSS4_cjs = require('../chunk-23B5XSS4.cjs');
|
|
4
|
+
var chunkXVIICZKW_cjs = require('../chunk-XVIICZKW.cjs');
|
|
5
5
|
var chunkERQE57IA_cjs = require('../chunk-ERQE57IA.cjs');
|
|
6
|
-
require('../chunk-
|
|
7
|
-
var
|
|
6
|
+
require('../chunk-UFEDJJSH.cjs');
|
|
7
|
+
var chunkHEHXSV47_cjs = require('../chunk-HEHXSV47.cjs');
|
|
8
8
|
var chunkG7VZBCD6_cjs = require('../chunk-G7VZBCD6.cjs');
|
|
9
9
|
var react = require('react');
|
|
10
10
|
var viem = require('viem');
|
|
@@ -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 chunk23B5XSS4_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 chunk23B5XSS4_cjs.NoteStore(noteStorage, "notes");
|
|
152
152
|
noteStoreRef.current = store;
|
|
153
153
|
noteStoreUnsub = store.onChange(() => {
|
|
154
154
|
if (!cancelled) setNotes([...store.getNotes()]);
|
|
@@ -742,7 +742,7 @@ function UPPAccountProvider({
|
|
|
742
742
|
const stealthAddress = react.useMemo(() => {
|
|
743
743
|
if (!masterKeys) return null;
|
|
744
744
|
try {
|
|
745
|
-
const { encodeStealthAddress } = (
|
|
745
|
+
const { encodeStealthAddress } = (chunk23B5XSS4_cjs.init_stealth(), chunkG7VZBCD6_cjs.__toCommonJS(chunk23B5XSS4_cjs.stealth_exports));
|
|
746
746
|
return encodeStealthAddress(masterKeys.ownerHash, masterKeys.viewingHash);
|
|
747
747
|
} catch {
|
|
748
748
|
return null;
|
|
@@ -751,7 +751,7 @@ function UPPAccountProvider({
|
|
|
751
751
|
const starkStealthAddress = react.useMemo(() => {
|
|
752
752
|
if (!starkMasterKeys) return null;
|
|
753
753
|
try {
|
|
754
|
-
const { encodeStarkStealthAddress } = (
|
|
754
|
+
const { encodeStarkStealthAddress } = (chunk23B5XSS4_cjs.init_stealth(), chunkG7VZBCD6_cjs.__toCommonJS(chunk23B5XSS4_cjs.stealth_exports));
|
|
755
755
|
return encodeStarkStealthAddress(starkMasterKeys.starkOwnerHash, starkMasterKeys.starkViewingHash);
|
|
756
756
|
} catch {
|
|
757
757
|
return null;
|
|
@@ -803,11 +803,9 @@ function useUPPAccount() {
|
|
|
803
803
|
}
|
|
804
804
|
async function createHashBasedNote(sdk, amount, spendingSecret, ownerHash, viewingSecret, origin, token) {
|
|
805
805
|
const blinding = await sdk.randomFieldElement();
|
|
806
|
-
const pubkey = await sdk.privateToPublic(spendingSecret);
|
|
807
806
|
const commitment = await sdk.poseidon([
|
|
808
807
|
amount,
|
|
809
|
-
|
|
810
|
-
pubkey.y,
|
|
808
|
+
ownerHash,
|
|
811
809
|
blinding,
|
|
812
810
|
origin,
|
|
813
811
|
token
|
|
@@ -819,8 +817,6 @@ async function createHashBasedNote(sdk, amount, spendingSecret, ownerHash, viewi
|
|
|
819
817
|
commitment,
|
|
820
818
|
ownerSecret: spendingSecret,
|
|
821
819
|
ownerHash,
|
|
822
|
-
pubkeyX: pubkey.x,
|
|
823
|
-
pubkeyY: pubkey.y,
|
|
824
820
|
blinding,
|
|
825
821
|
encryptedNote,
|
|
826
822
|
searchTag,
|
|
@@ -1602,16 +1598,16 @@ function usePoolTransfer(config) {
|
|
|
1602
1598
|
const recipientNote = await createNoteForSelf(amount, origin, token);
|
|
1603
1599
|
const changeNote = await createNoteForSelf(changeAmount, origin, token);
|
|
1604
1600
|
const [transferModule, proofModule, aspModule] = await Promise.all([
|
|
1605
|
-
import('../transfer-
|
|
1606
|
-
import('../proof-
|
|
1607
|
-
import('../asp-
|
|
1601
|
+
import('../transfer-PB6D5VCW.cjs'),
|
|
1602
|
+
import('../proof-XR6XE5PJ.cjs'),
|
|
1603
|
+
import('../asp-CUE3NMBN.cjs')
|
|
1608
1604
|
]);
|
|
1609
1605
|
const {
|
|
1610
1606
|
syncMerkleTree,
|
|
1611
1607
|
getMerkleProofsForNotes,
|
|
1612
1608
|
buildUPPTransferCircuitInputs
|
|
1613
1609
|
} = transferModule;
|
|
1614
|
-
const { generateUPPProof,
|
|
1610
|
+
const { generateUPPProof, formatPlonkProofForContract } = proofModule;
|
|
1615
1611
|
const { generateASPProof: generateASPProof2, DEMO_ASP_ID } = aspModule;
|
|
1616
1612
|
setStage("syncing_merkle");
|
|
1617
1613
|
const { tree, leaves } = await syncMerkleTree(cfg.publicClient, cfg.poolAddress);
|
|
@@ -1645,20 +1641,10 @@ function usePoolTransfer(config) {
|
|
|
1645
1641
|
circuitInputs,
|
|
1646
1642
|
cfg.circuitBaseUrl ?? "/circuits/"
|
|
1647
1643
|
);
|
|
1648
|
-
const formattedProof =
|
|
1649
|
-
const proofArray = [
|
|
1650
|
-
formattedProof.a[0],
|
|
1651
|
-
formattedProof.a[1],
|
|
1652
|
-
formattedProof.b[0][0],
|
|
1653
|
-
formattedProof.b[0][1],
|
|
1654
|
-
formattedProof.b[1][0],
|
|
1655
|
-
formattedProof.b[1][1],
|
|
1656
|
-
formattedProof.c[0],
|
|
1657
|
-
formattedProof.c[1]
|
|
1658
|
-
];
|
|
1644
|
+
const formattedProof = await formatPlonkProofForContract(proof);
|
|
1659
1645
|
return {
|
|
1660
1646
|
circuit: "transfer",
|
|
1661
|
-
proof:
|
|
1647
|
+
proof: formattedProof,
|
|
1662
1648
|
nullifier: viem.toHex(BigInt(circuitInputs.nullifier), { size: 32 }),
|
|
1663
1649
|
stateRoot: BigInt(circuitInputs.stateRoot),
|
|
1664
1650
|
aspRoot: BigInt(circuitInputs.aspRoot),
|
|
@@ -1690,7 +1676,7 @@ function usePoolTransfer(config) {
|
|
|
1690
1676
|
reset
|
|
1691
1677
|
};
|
|
1692
1678
|
}
|
|
1693
|
-
|
|
1679
|
+
chunkHEHXSV47_cjs.init_poseidon();
|
|
1694
1680
|
var STATE_TREE_DEPTH = 32;
|
|
1695
1681
|
var ASP_TREE_DEPTH2 = 20;
|
|
1696
1682
|
function padToDepth(arr, padValue, depth) {
|
|
@@ -1761,12 +1747,12 @@ function useWithdraw(config) {
|
|
|
1761
1747
|
const token = BigInt(selectedNote.token);
|
|
1762
1748
|
setStage("creating_outputs");
|
|
1763
1749
|
const [transferModule, proofModule, sdk] = await Promise.all([
|
|
1764
|
-
import('../transfer-
|
|
1765
|
-
import('../proof-
|
|
1750
|
+
import('../transfer-PB6D5VCW.cjs'),
|
|
1751
|
+
import('../proof-XR6XE5PJ.cjs'),
|
|
1766
1752
|
import('../index.cjs')
|
|
1767
1753
|
]);
|
|
1768
1754
|
const { syncMerkleTree, getMerkleProofsForNotes } = transferModule;
|
|
1769
|
-
const { generateUPPProof,
|
|
1755
|
+
const { generateUPPProof, formatPlonkProofForContract } = proofModule;
|
|
1770
1756
|
setStage("syncing_merkle");
|
|
1771
1757
|
const { tree, leaves } = await syncMerkleTree(cfg.publicClient, cfg.poolAddress);
|
|
1772
1758
|
const spendableNote = {
|
|
@@ -1800,7 +1786,7 @@ function useWithdraw(config) {
|
|
|
1800
1786
|
);
|
|
1801
1787
|
}
|
|
1802
1788
|
const nullifier = await sdk.poseidon([
|
|
1803
|
-
BigInt(selectedNote.ownerSecret) %
|
|
1789
|
+
BigInt(selectedNote.ownerSecret) % chunkHEHXSV47_cjs.BABYJUBJUB_SUBORDER,
|
|
1804
1790
|
BigInt(actualLeafIndex),
|
|
1805
1791
|
storedCommitment
|
|
1806
1792
|
]);
|
|
@@ -1816,7 +1802,7 @@ function useWithdraw(config) {
|
|
|
1816
1802
|
// Private inputs - Input Note
|
|
1817
1803
|
// IMPORTANT: Use actualLeafIndex from Merkle proof, not stored leafIndex
|
|
1818
1804
|
inputAmount: selectedNote.amount.toString(),
|
|
1819
|
-
inputOneTimeSecret: (BigInt(selectedNote.ownerSecret) %
|
|
1805
|
+
inputOneTimeSecret: (BigInt(selectedNote.ownerSecret) % chunkHEHXSV47_cjs.BABYJUBJUB_SUBORDER).toString(),
|
|
1820
1806
|
inputBlinding: selectedNote.blinding.toString(),
|
|
1821
1807
|
inputOrigin: origin.toString(),
|
|
1822
1808
|
inputLeafIndex: actualLeafIndex.toString(),
|
|
@@ -1831,20 +1817,10 @@ function useWithdraw(config) {
|
|
|
1831
1817
|
circuitInputs,
|
|
1832
1818
|
cfg.circuitBaseUrl ?? "/circuits/"
|
|
1833
1819
|
);
|
|
1834
|
-
const formattedProof =
|
|
1820
|
+
const formattedProof = await formatPlonkProofForContract(proof);
|
|
1835
1821
|
const stateRoot = stateRootBI;
|
|
1836
|
-
const proofArray = [
|
|
1837
|
-
formattedProof.a[0],
|
|
1838
|
-
formattedProof.a[1],
|
|
1839
|
-
formattedProof.b[0][0],
|
|
1840
|
-
formattedProof.b[0][1],
|
|
1841
|
-
formattedProof.b[1][0],
|
|
1842
|
-
formattedProof.b[1][1],
|
|
1843
|
-
formattedProof.c[0],
|
|
1844
|
-
formattedProof.c[1]
|
|
1845
|
-
];
|
|
1846
1822
|
return {
|
|
1847
|
-
proof:
|
|
1823
|
+
proof: formattedProof,
|
|
1848
1824
|
nullifier: viem.toHex(nullifier, { size: 32 }),
|
|
1849
1825
|
stateRoot,
|
|
1850
1826
|
aspRoot,
|
|
@@ -1924,7 +1900,7 @@ function usePersonalASP(config) {
|
|
|
1924
1900
|
});
|
|
1925
1901
|
if (aspData.operator.toLowerCase() === userAddress.toLowerCase()) {
|
|
1926
1902
|
const userOrigin = BigInt(userAddress);
|
|
1927
|
-
const expectedRoot = await
|
|
1903
|
+
const expectedRoot = await chunkXVIICZKW_cjs.computeSingleOriginASPRoot(userOrigin);
|
|
1928
1904
|
const isApproved = aspData.currentRoot === expectedRoot;
|
|
1929
1905
|
setAspInfo({
|
|
1930
1906
|
aspId: storedAspId,
|
|
@@ -1956,7 +1932,7 @@ function usePersonalASP(config) {
|
|
|
1956
1932
|
const isOriginApproved = react.useCallback(async (origin) => {
|
|
1957
1933
|
if (!aspInfo?.isRegistered || !publicClient) return false;
|
|
1958
1934
|
try {
|
|
1959
|
-
const expectedRoot = await
|
|
1935
|
+
const expectedRoot = await chunkXVIICZKW_cjs.computeSingleOriginASPRoot(origin);
|
|
1960
1936
|
const isValid = await publicClient.readContract({
|
|
1961
1937
|
address: aspHubAddress,
|
|
1962
1938
|
abi: upcSdk.ASP_REGISTRY_HUB_ABI,
|
|
@@ -1972,7 +1948,7 @@ function usePersonalASP(config) {
|
|
|
1972
1948
|
return aspInfo?.isRegistered ? aspInfo.aspId : null;
|
|
1973
1949
|
}, [aspInfo]);
|
|
1974
1950
|
const getASPRootForOrigin = react.useCallback(async (origin) => {
|
|
1975
|
-
return
|
|
1951
|
+
return chunkXVIICZKW_cjs.computeSingleOriginASPRoot(origin);
|
|
1976
1952
|
}, []);
|
|
1977
1953
|
return {
|
|
1978
1954
|
aspInfo,
|
|
@@ -1987,7 +1963,7 @@ function usePersonalASP(config) {
|
|
|
1987
1963
|
function storePersonalASPId(chainId, address, aspId) {
|
|
1988
1964
|
storeASPId(chainId, address, aspId);
|
|
1989
1965
|
}
|
|
1990
|
-
|
|
1966
|
+
chunkHEHXSV47_cjs.init_poseidon();
|
|
1991
1967
|
var STATE_TREE_DEPTH2 = 32;
|
|
1992
1968
|
var ASP_TREE_DEPTH3 = 20;
|
|
1993
1969
|
function padToDepth2(arr, padValue, depth) {
|
|
@@ -2025,7 +2001,7 @@ function useSwapOrderBook(config) {
|
|
|
2025
2001
|
try {
|
|
2026
2002
|
const logs = await config.publicClient.getLogs({
|
|
2027
2003
|
address: config.poolAddress,
|
|
2028
|
-
event:
|
|
2004
|
+
event: chunk23B5XSS4_cjs.SWAP_ORDER_PLACED_EVENT,
|
|
2029
2005
|
fromBlock: config.fromBlock ?? 0n,
|
|
2030
2006
|
toBlock: "latest"
|
|
2031
2007
|
});
|
|
@@ -2041,10 +2017,10 @@ function useSwapOrderBook(config) {
|
|
|
2041
2017
|
blockNumber: log.blockNumber ?? 0n
|
|
2042
2018
|
}));
|
|
2043
2019
|
if (config.sellToken && config.buyToken) {
|
|
2044
|
-
parsedOrders =
|
|
2020
|
+
parsedOrders = chunk23B5XSS4_cjs.filterOrdersByTokenPair(parsedOrders, config.sellToken, config.buyToken);
|
|
2045
2021
|
}
|
|
2046
2022
|
if (config.acceptableAspIds && config.acceptableAspIds.length > 0) {
|
|
2047
|
-
parsedOrders =
|
|
2023
|
+
parsedOrders = chunk23B5XSS4_cjs.filterOrdersByASP(parsedOrders, config.acceptableAspIds);
|
|
2048
2024
|
}
|
|
2049
2025
|
const enriched = [];
|
|
2050
2026
|
for (const order of parsedOrders) {
|
|
@@ -2141,13 +2117,13 @@ function useSwap(config) {
|
|
|
2141
2117
|
}
|
|
2142
2118
|
setStage("creating_outputs");
|
|
2143
2119
|
const [transferModule, proofModule, sdk, aspModule] = await Promise.all([
|
|
2144
|
-
import('../transfer-
|
|
2145
|
-
import('../proof-
|
|
2120
|
+
import('../transfer-PB6D5VCW.cjs'),
|
|
2121
|
+
import('../proof-XR6XE5PJ.cjs'),
|
|
2146
2122
|
import('../index.cjs'),
|
|
2147
|
-
import('../asp-
|
|
2123
|
+
import('../asp-CUE3NMBN.cjs')
|
|
2148
2124
|
]);
|
|
2149
2125
|
const { syncMerkleTree, getMerkleProofsForNotes } = transferModule;
|
|
2150
|
-
const { generateUPPProof,
|
|
2126
|
+
const { generateUPPProof, formatPlonkProofForContract } = proofModule;
|
|
2151
2127
|
const { generateASPProof: generateASPProof2 } = aspModule;
|
|
2152
2128
|
setStage("syncing_merkle");
|
|
2153
2129
|
const { tree, leaves } = await syncMerkleTree(cfg.publicClient, cfg.poolAddress);
|
|
@@ -2184,7 +2160,7 @@ function useSwap(config) {
|
|
|
2184
2160
|
);
|
|
2185
2161
|
}
|
|
2186
2162
|
const nullifier = await sdk.poseidon([
|
|
2187
|
-
BigInt(selectedNote.ownerSecret) %
|
|
2163
|
+
BigInt(selectedNote.ownerSecret) % chunkHEHXSV47_cjs.BABYJUBJUB_SUBORDER,
|
|
2188
2164
|
BigInt(actualLeafIndex),
|
|
2189
2165
|
storedCommitment
|
|
2190
2166
|
]);
|
|
@@ -2198,7 +2174,7 @@ function useSwap(config) {
|
|
|
2198
2174
|
token: token.toString(),
|
|
2199
2175
|
isRagequit: "0",
|
|
2200
2176
|
inputAmount: selectedNote.amount.toString(),
|
|
2201
|
-
inputOneTimeSecret: (BigInt(selectedNote.ownerSecret) %
|
|
2177
|
+
inputOneTimeSecret: (BigInt(selectedNote.ownerSecret) % chunkHEHXSV47_cjs.BABYJUBJUB_SUBORDER).toString(),
|
|
2202
2178
|
inputBlinding: selectedNote.blinding.toString(),
|
|
2203
2179
|
inputOrigin: origin.toString(),
|
|
2204
2180
|
inputLeafIndex: actualLeafIndex.toString(),
|
|
@@ -2212,23 +2188,13 @@ function useSwap(config) {
|
|
|
2212
2188
|
circuitInputs,
|
|
2213
2189
|
cfg.circuitBaseUrl ?? "/circuits/"
|
|
2214
2190
|
);
|
|
2215
|
-
const formattedProof =
|
|
2216
|
-
const
|
|
2217
|
-
|
|
2218
|
-
formattedProof.a[1],
|
|
2219
|
-
formattedProof.b[0][0],
|
|
2220
|
-
formattedProof.b[0][1],
|
|
2221
|
-
formattedProof.b[1][0],
|
|
2222
|
-
formattedProof.b[1][1],
|
|
2223
|
-
formattedProof.c[0],
|
|
2224
|
-
formattedProof.c[1]
|
|
2225
|
-
];
|
|
2226
|
-
const cancelSecret = chunkKXPZUBPI_cjs.generateCancelSecret();
|
|
2227
|
-
const cancelKeyHash = chunkKXPZUBPI_cjs.computeCancelKeyHash(cancelSecret);
|
|
2191
|
+
const formattedProof = await formatPlonkProofForContract(proof);
|
|
2192
|
+
const cancelSecret = chunk23B5XSS4_cjs.generateCancelSecret();
|
|
2193
|
+
const cancelKeyHash = chunk23B5XSS4_cjs.computeCancelKeyHash(cancelSecret);
|
|
2228
2194
|
const currentBlock = await cfg.publicClient.getBlockNumber();
|
|
2229
2195
|
const expiry = currentBlock + expiryBlocks;
|
|
2230
2196
|
return {
|
|
2231
|
-
proof:
|
|
2197
|
+
proof: formattedProof,
|
|
2232
2198
|
nullifier: viem.toHex(nullifier, { size: 32 }),
|
|
2233
2199
|
stateRoot: stateRootBI,
|
|
2234
2200
|
aspRoot: aspProofData.aspRoot,
|
|
@@ -2272,7 +2238,7 @@ function useSwap(config) {
|
|
|
2272
2238
|
noteOverride
|
|
2273
2239
|
} = params;
|
|
2274
2240
|
const cfg = configRef.current;
|
|
2275
|
-
const giveAmount =
|
|
2241
|
+
const giveAmount = chunk23B5XSS4_cjs.computeGiveAmount(takeAmount, rate);
|
|
2276
2242
|
setStage("selecting_notes");
|
|
2277
2243
|
let selectedNote;
|
|
2278
2244
|
if (noteOverride) {
|
|
@@ -2293,13 +2259,13 @@ function useSwap(config) {
|
|
|
2293
2259
|
}
|
|
2294
2260
|
setStage("creating_outputs");
|
|
2295
2261
|
const [transferModule, proofModule, sdk, aspModule] = await Promise.all([
|
|
2296
|
-
import('../transfer-
|
|
2297
|
-
import('../proof-
|
|
2262
|
+
import('../transfer-PB6D5VCW.cjs'),
|
|
2263
|
+
import('../proof-XR6XE5PJ.cjs'),
|
|
2298
2264
|
import('../index.cjs'),
|
|
2299
|
-
import('../asp-
|
|
2265
|
+
import('../asp-CUE3NMBN.cjs')
|
|
2300
2266
|
]);
|
|
2301
2267
|
const { syncMerkleTree, getMerkleProofsForNotes } = transferModule;
|
|
2302
|
-
const { generateUPPProof,
|
|
2268
|
+
const { generateUPPProof, formatPlonkProofForContract } = proofModule;
|
|
2303
2269
|
const { generateASPProof: generateASPProof2 } = aspModule;
|
|
2304
2270
|
const fillerOrigin = ethAddress ? BigInt(ethAddress) : BigInt(masterKeys.ownerHash);
|
|
2305
2271
|
const fillerNoteData = await createNoteForSelf(
|
|
@@ -2342,7 +2308,7 @@ function useSwap(config) {
|
|
|
2342
2308
|
);
|
|
2343
2309
|
}
|
|
2344
2310
|
const nullifier = await sdk.poseidon([
|
|
2345
|
-
BigInt(selectedNote.ownerSecret) %
|
|
2311
|
+
BigInt(selectedNote.ownerSecret) % chunkHEHXSV47_cjs.BABYJUBJUB_SUBORDER,
|
|
2346
2312
|
BigInt(actualLeafIndex),
|
|
2347
2313
|
storedCommitmentF
|
|
2348
2314
|
]);
|
|
@@ -2356,7 +2322,7 @@ function useSwap(config) {
|
|
|
2356
2322
|
token: token.toString(),
|
|
2357
2323
|
isRagequit: "0",
|
|
2358
2324
|
inputAmount: selectedNote.amount.toString(),
|
|
2359
|
-
inputOneTimeSecret: (BigInt(selectedNote.ownerSecret) %
|
|
2325
|
+
inputOneTimeSecret: (BigInt(selectedNote.ownerSecret) % chunkHEHXSV47_cjs.BABYJUBJUB_SUBORDER).toString(),
|
|
2360
2326
|
inputBlinding: selectedNote.blinding.toString(),
|
|
2361
2327
|
inputOrigin: origin.toString(),
|
|
2362
2328
|
inputLeafIndex: actualLeafIndex.toString(),
|
|
@@ -2370,24 +2336,14 @@ function useSwap(config) {
|
|
|
2370
2336
|
circuitInputs,
|
|
2371
2337
|
cfg.circuitBaseUrl ?? "/circuits/"
|
|
2372
2338
|
);
|
|
2373
|
-
const formattedProof =
|
|
2374
|
-
const proofArray = [
|
|
2375
|
-
formattedProof.a[0],
|
|
2376
|
-
formattedProof.a[1],
|
|
2377
|
-
formattedProof.b[0][0],
|
|
2378
|
-
formattedProof.b[0][1],
|
|
2379
|
-
formattedProof.b[1][0],
|
|
2380
|
-
formattedProof.b[1][1],
|
|
2381
|
-
formattedProof.c[0],
|
|
2382
|
-
formattedProof.c[1]
|
|
2383
|
-
];
|
|
2339
|
+
const formattedProof = await formatPlonkProofForContract(proof);
|
|
2384
2340
|
const { encodePacked: encodePacked3 } = await import('viem');
|
|
2385
2341
|
const packedFillerNote = encodePacked3(
|
|
2386
2342
|
["uint64", "uint256", "bytes"],
|
|
2387
2343
|
[fillerNoteData.searchTag, fillerNoteData.ownerHash, fillerNoteData.encryptedNote]
|
|
2388
2344
|
);
|
|
2389
2345
|
return {
|
|
2390
|
-
proof:
|
|
2346
|
+
proof: formattedProof,
|
|
2391
2347
|
nullifier: viem.toHex(nullifier, { size: 32 }),
|
|
2392
2348
|
stateRoot: stateRootBI,
|
|
2393
2349
|
aspRoot: aspProofData.aspRoot,
|
|
@@ -2523,12 +2479,12 @@ function useSwap(config) {
|
|
|
2523
2479
|
createNoteForSelf(changeAmount, origin, token)
|
|
2524
2480
|
]);
|
|
2525
2481
|
const [transferModule, proofModule, aspModule] = await Promise.all([
|
|
2526
|
-
import('../transfer-
|
|
2527
|
-
import('../proof-
|
|
2528
|
-
import('../asp-
|
|
2482
|
+
import('../transfer-PB6D5VCW.cjs'),
|
|
2483
|
+
import('../proof-XR6XE5PJ.cjs'),
|
|
2484
|
+
import('../asp-CUE3NMBN.cjs')
|
|
2529
2485
|
]);
|
|
2530
2486
|
const { syncMerkleTree, getMerkleProofsForNotes, buildUPPTransferCircuitInputs } = transferModule;
|
|
2531
|
-
const { generateUPPProof,
|
|
2487
|
+
const { generateUPPProof, formatPlonkProofForContract } = proofModule;
|
|
2532
2488
|
const { generateASPProof: generateASPProof2, DEMO_ASP_ID } = aspModule;
|
|
2533
2489
|
setStage("syncing_merkle");
|
|
2534
2490
|
const { tree, leaves } = await syncMerkleTree(cfg.publicClient, cfg.poolAddress);
|
|
@@ -2558,17 +2514,7 @@ function useSwap(config) {
|
|
|
2558
2514
|
circuitInputs,
|
|
2559
2515
|
cfg.circuitBaseUrl ?? "/circuits/"
|
|
2560
2516
|
);
|
|
2561
|
-
const formattedProof =
|
|
2562
|
-
const proofArray = [
|
|
2563
|
-
formattedProof.a[0],
|
|
2564
|
-
formattedProof.a[1],
|
|
2565
|
-
formattedProof.b[0][0],
|
|
2566
|
-
formattedProof.b[0][1],
|
|
2567
|
-
formattedProof.b[1][0],
|
|
2568
|
-
formattedProof.b[1][1],
|
|
2569
|
-
formattedProof.c[0],
|
|
2570
|
-
formattedProof.c[1]
|
|
2571
|
-
];
|
|
2517
|
+
const formattedProof = await formatPlonkProofForContract(proof);
|
|
2572
2518
|
const { encodePacked: encodePacked3 } = await import('viem');
|
|
2573
2519
|
const packNote = (n) => encodePacked3(
|
|
2574
2520
|
["uint64", "uint256", "bytes"],
|
|
@@ -2602,7 +2548,7 @@ function useSwap(config) {
|
|
|
2602
2548
|
timestamp: Date.now()
|
|
2603
2549
|
};
|
|
2604
2550
|
return {
|
|
2605
|
-
proof:
|
|
2551
|
+
proof: formattedProof,
|
|
2606
2552
|
nullifier: viem.toHex(BigInt(circuitInputs.nullifier), { size: 32 }),
|
|
2607
2553
|
stateRoot: BigInt(circuitInputs.stateRoot),
|
|
2608
2554
|
aspRoot: BigInt(circuitInputs.aspRoot),
|
|
@@ -2643,31 +2589,31 @@ function useSwap(config) {
|
|
|
2643
2589
|
|
|
2644
2590
|
Object.defineProperty(exports, "ASP_TREE_DEPTH", {
|
|
2645
2591
|
enumerable: true,
|
|
2646
|
-
get: function () { return
|
|
2592
|
+
get: function () { return chunkXVIICZKW_cjs.ASP_TREE_DEPTH; }
|
|
2647
2593
|
});
|
|
2648
2594
|
Object.defineProperty(exports, "buildASPTree", {
|
|
2649
2595
|
enumerable: true,
|
|
2650
|
-
get: function () { return
|
|
2596
|
+
get: function () { return chunkXVIICZKW_cjs.buildASPTree; }
|
|
2651
2597
|
});
|
|
2652
2598
|
Object.defineProperty(exports, "computeMultiOriginASPRoot", {
|
|
2653
2599
|
enumerable: true,
|
|
2654
|
-
get: function () { return
|
|
2600
|
+
get: function () { return chunkXVIICZKW_cjs.computeMultiOriginASPRoot; }
|
|
2655
2601
|
});
|
|
2656
2602
|
Object.defineProperty(exports, "computeSingleOriginASPRoot", {
|
|
2657
2603
|
enumerable: true,
|
|
2658
|
-
get: function () { return
|
|
2604
|
+
get: function () { return chunkXVIICZKW_cjs.computeSingleOriginASPRoot; }
|
|
2659
2605
|
});
|
|
2660
2606
|
Object.defineProperty(exports, "generateASPProof", {
|
|
2661
2607
|
enumerable: true,
|
|
2662
|
-
get: function () { return
|
|
2608
|
+
get: function () { return chunkXVIICZKW_cjs.generateASPProof; }
|
|
2663
2609
|
});
|
|
2664
2610
|
Object.defineProperty(exports, "generateMultiOriginASPProof", {
|
|
2665
2611
|
enumerable: true,
|
|
2666
|
-
get: function () { return
|
|
2612
|
+
get: function () { return chunkXVIICZKW_cjs.generateMultiOriginASPProof; }
|
|
2667
2613
|
});
|
|
2668
2614
|
Object.defineProperty(exports, "generateSingleOriginASPProof", {
|
|
2669
2615
|
enumerable: true,
|
|
2670
|
-
get: function () { return
|
|
2616
|
+
get: function () { return chunkXVIICZKW_cjs.generateSingleOriginASPProof; }
|
|
2671
2617
|
});
|
|
2672
2618
|
exports.UPPAccountProvider = UPPAccountProvider;
|
|
2673
2619
|
exports.UPPAvatar = UPPAvatar;
|