@kohaku-eth/tornado-cash 0.0.2-alpha.13 → 0.0.2-alpha.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.ts CHANGED
@@ -289,6 +289,15 @@ interface ISyncService {
289
289
  * with the same external-then-chain strategy as {@link getPoolEvents}.
290
290
  */
291
291
  getRelayerRegistryEvents(params: IGetEventsParams): Promise<IGetRelayerRegistryEventsResult>;
292
+ /**
293
+ * Resolves a pool's scan-start block. Uses the external provider's first
294
+ * covered block when available (an O(1) lookup), else falls back to the
295
+ * on-chain deployment-block binary search.
296
+ */
297
+ getPoolDeploymentBlock(params: {
298
+ chainId: bigint;
299
+ address: Address;
300
+ }): Promise<bigint>;
292
301
  }
293
302
 
294
303
  type SpecificAssetBalanceFn<isAsync extends boolean = false> = <const Adresses extends Address | Address[] = Address[], ReturnType = Adresses extends unknown[] ? Map<Address, bigint> : bigint>(assetAddress?: Adresses) => isAsync extends true ? Promise<ReturnType> : ReturnType;
@@ -618,7 +627,28 @@ declare const TornadoPaymasterConfigs: {
618
627
  readonly '0x6921fd1a97441dd603a997ed6ddf388658daf754': "0xbF0a7969dacF8337716d0F283df0574dF56b0479";
619
628
  };
620
629
  };
621
- readonly 1: never;
630
+ readonly 1: {
631
+ readonly bundlerUrl: "https://public.pimlico.io/v2/1/rpc";
632
+ readonly entryPointAddress: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108";
633
+ readonly paymasterAddress: "0xe06CB96C57D2442f8F60F5017354BC08F7e91308";
634
+ readonly poolsAccountsMap: {
635
+ readonly '0x12d66f87a04a9e220743712ce6d9bb1b5616b8fc': "0x4a3F73a23563bB467Aa034d0fAB61e7BcDf26161";
636
+ readonly '0x47ce0c6ed5b0ce3d3a51fdb1c52dc66a7c3c2936': "0xC086b50Dd859Bb15D553327178DEdbC347B5b905";
637
+ readonly '0x910cbd523d972eb0a6f4cae4618ad62622b39dbf': "0x08d1103bff53CBdC9DB1e81B79475CEad2e35870";
638
+ readonly '0xa160cdab225685da1d56aa342ad8841c3b53f291': "0x3aF851f9BeEeE6E9fa06022f34Dc4C453D265aE5";
639
+ readonly '0xd4b88df4d29f5cedd6857912842cff3b20c8cfa3': "0xe6be288aeCa9FAB56D9792686Ec571Fb1AF37F55";
640
+ readonly '0xfd8610d20aa15b7b2e3be39b396a1bc3516c7144': "0xf6f35246EbDA061bB17b6C7ED7B7049065eD61f3";
641
+ readonly '0x07687e702b410Fa43f4cB4Af7FA097918ffD2730': "0x36A5b4bCE77700B9C52cFEE53Fc8cA3B58eb7E35";
642
+ readonly '0x23773e65ed146a459791799d01336db287f25334': "0x83Ff713F0939409E1c6023bc8aaB3E49eD968c8D";
643
+ readonly '0x4736dcf1b7a3d580672cce6e7c65cd5cc9cfba9d': "0xB1C7e712AF153073979AdC5ef8B1Cc5A7b0cf031";
644
+ readonly '0xd96f2b1c14db8458374d9aca76e26c3d18364307': "0x44336242f9766b4c751F6958499C5cc18325e25B";
645
+ readonly '0x169ad27a470d064dede56a2d3ff727986b15d52b': "0xF006862cCa4829D3f3ddD52d93fC49C03D380a5F";
646
+ readonly '0x0836222F2B2B24A3F36f98668Ed8F0B38D1a872f': "0x5DF524b6c9303eD94A7767c2eD787ee223c9bC54";
647
+ readonly '0x178169b423a011fff22b9e3f3abea13414ddd0f1': "0x0fdF2f686B600523F9752aEca0abb6AD9603A22C";
648
+ readonly '0x610b717796ad172b316836ac95a2ffad065ceab4': "0xec3Cca694EEe55808B3f5EFEDd0bC03E52e47834";
649
+ readonly '0xbb93e510bbcd0b7beb5a853875f9ec60275cf498': "0xC2C427E6ADF66F412921C17958CeDD9C7710F521";
650
+ };
651
+ };
622
652
  };
623
653
  declare const TornadoCashConfigs: {
624
654
  readonly 1: {
package/dist/index.js CHANGED
@@ -356,7 +356,43 @@ var TornadoPaymasterConfigs = {
356
356
  "0x6921fd1a97441dd603a997ed6ddf388658daf754": "0xbF0a7969dacF8337716d0F283df0574dF56b0479"
357
357
  }
358
358
  },
359
- 1: {}
359
+ 1: {
360
+ bundlerUrl: "https://public.pimlico.io/v2/1/rpc",
361
+ entryPointAddress: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
362
+ paymasterAddress: "0xe06CB96C57D2442f8F60F5017354BC08F7e91308",
363
+ poolsAccountsMap: {
364
+ // ETH 0.1
365
+ "0x12d66f87a04a9e220743712ce6d9bb1b5616b8fc": "0x4a3F73a23563bB467Aa034d0fAB61e7BcDf26161",
366
+ // ETH 1
367
+ "0x47ce0c6ed5b0ce3d3a51fdb1c52dc66a7c3c2936": "0xC086b50Dd859Bb15D553327178DEdbC347B5b905",
368
+ // ETH 10
369
+ "0x910cbd523d972eb0a6f4cae4618ad62622b39dbf": "0x08d1103bff53CBdC9DB1e81B79475CEad2e35870",
370
+ // ETH 100
371
+ "0xa160cdab225685da1d56aa342ad8841c3b53f291": "0x3aF851f9BeEeE6E9fa06022f34Dc4C453D265aE5",
372
+ // DAI 100
373
+ "0xd4b88df4d29f5cedd6857912842cff3b20c8cfa3": "0xe6be288aeCa9FAB56D9792686Ec571Fb1AF37F55",
374
+ // DAI 1_000
375
+ "0xfd8610d20aa15b7b2e3be39b396a1bc3516c7144": "0xf6f35246EbDA061bB17b6C7ED7B7049065eD61f3",
376
+ // DAI 10_000
377
+ "0x07687e702b410Fa43f4cB4Af7FA097918ffD2730": "0x36A5b4bCE77700B9C52cFEE53Fc8cA3B58eb7E35",
378
+ // DAI 100_000
379
+ "0x23773e65ed146a459791799d01336db287f25334": "0x83Ff713F0939409E1c6023bc8aaB3E49eD968c8D",
380
+ // USDC 100
381
+ "0x4736dcf1b7a3d580672cce6e7c65cd5cc9cfba9d": "0xB1C7e712AF153073979AdC5ef8B1Cc5A7b0cf031",
382
+ // USDC 1_000
383
+ "0xd96f2b1c14db8458374d9aca76e26c3d18364307": "0x44336242f9766b4c751F6958499C5cc18325e25B",
384
+ // USDT 100
385
+ "0x169ad27a470d064dede56a2d3ff727986b15d52b": "0xF006862cCa4829D3f3ddD52d93fC49C03D380a5F",
386
+ // USDT 1_000
387
+ "0x0836222F2B2B24A3F36f98668Ed8F0B38D1a872f": "0x5DF524b6c9303eD94A7767c2eD787ee223c9bC54",
388
+ // WBTC 0.1
389
+ "0x178169b423a011fff22b9e3f3abea13414ddd0f1": "0x0fdF2f686B600523F9752aEca0abb6AD9603A22C",
390
+ // WBTC 1
391
+ "0x610b717796ad172b316836ac95a2ffad065ceab4": "0xec3Cca694EEe55808B3f5EFEDd0bC03E52e47834",
392
+ // WBTC 10
393
+ "0xbb93e510bbcd0b7beb5a853875f9ec60275cf498": "0xC2C427E6ADF66F412921C17958CeDD9C7710F521"
394
+ }
395
+ }
360
396
  };
361
397
  var TornadoCashConfigs = {
362
398
  1: {
@@ -440,6 +476,7 @@ var TornadoCashProtocol = class {
440
476
  }
441
477
  return events;
442
478
  },
479
+ firstCoveredBlock: (params) => externalSyncProvider.firstCoveredBlock(params),
443
480
  lastCoveredBlock: (params) => externalSyncProvider.lastCoveredBlock(params)
444
481
  };
445
482
  await Promise.race([
@@ -1,5 +1,5 @@
1
1
  // src/utils/merkle-tree/merkle-tree.util.browser.ts
2
- import { generateMimcMerkleProof, createMimcMerkleTreeParallel } from "mimc-tree";
2
+ import { generateMimcMerkleProof, createMimcMerkleTreeParallel } from "@kohaku-eth/mimc-tree";
3
3
  var buildTree = async (leaves) => {
4
4
  return createMimcMerkleTreeParallel(leaves, { workerUrl: "./merkle-tree-worker.browser.js" });
5
5
  };
@@ -1,5 +1,5 @@
1
1
  // src/utils/merkle-tree/merkle-tree.util.node.ts
2
- import { generateMimcMerkleProof, createMimcMerkleTreeNodejsParallel } from "mimc-tree";
2
+ import { generateMimcMerkleProof, createMimcMerkleTreeNodejsParallel } from "@kohaku-eth/mimc-tree";
3
3
  var buildTree = async (leaves) => {
4
4
  return createMimcMerkleTreeNodejsParallel(leaves);
5
5
  };
@@ -18009,6 +18009,24 @@ var SyncService = class {
18009
18009
  toBlock: head
18010
18010
  };
18011
18011
  }
18012
+ async getPoolDeploymentBlock({
18013
+ chainId,
18014
+ address
18015
+ }) {
18016
+ const provider = this.externalSyncProvider;
18017
+ if (provider) {
18018
+ try {
18019
+ return BigInt(
18020
+ await provider.firstCoveredBlock({
18021
+ chainId: toHex(chainId),
18022
+ address: toHex(address, { size: 20 })
18023
+ })
18024
+ );
18025
+ } catch {
18026
+ }
18027
+ }
18028
+ return this.dataService.getContractDeploymentBlock(address);
18029
+ }
18012
18030
  /**
18013
18031
  * Decides whether to use the external provider and, if so, streams its raw
18014
18032
  * events for `[fromBlock, coverage]`. Event-agnostic: callers parse the raw
@@ -18028,11 +18046,12 @@ var SyncService = class {
18028
18046
  }
18029
18047
  const chainId = toHex(rawChainId);
18030
18048
  const hexAddress = toHex(address, { size: 20 });
18031
- const rawCoverage = await provider.lastCoveredBlock({ chainId, address: hexAddress });
18032
- if (!rawCoverage) {
18049
+ let coverage;
18050
+ try {
18051
+ coverage = BigInt(await provider.lastCoveredBlock({ chainId, address: hexAddress }));
18052
+ } catch {
18033
18053
  return null;
18034
18054
  }
18035
- const coverage = BigInt(rawCoverage);
18036
18055
  if (coverage <= fromBlock) {
18037
18056
  return null;
18038
18057
  }
@@ -21290,10 +21309,11 @@ var storeFactory = ({
21290
21309
  var syncPoolsThunk = createAsyncThunk(
21291
21310
  "sync/pools",
21292
21311
  async ({
21293
- dataService
21312
+ dataService,
21313
+ syncService
21294
21314
  }, { dispatch, getState }) => {
21295
21315
  const state = getState();
21296
- const { instanceRegistry: { address: instanceRegistryAddress } } = instanceRegistryInfoSelector(state);
21316
+ const { chainId, instanceRegistry: { address: instanceRegistryAddress } } = instanceRegistryInfoSelector(state);
21297
21317
  const existingPools = poolsSelector(state);
21298
21318
  const poolsAddressses = await dataService.getAllPoolsAddresses(instanceRegistryAddress);
21299
21319
  const unsyncedPools = poolsAddressses.filter((address) => !existingPools.has(address));
@@ -21301,7 +21321,7 @@ var syncPoolsThunk = createAsyncThunk(
21301
21321
  unsyncedPools.map(async (poolAddress) => {
21302
21322
  const [config, registeredBlock] = await Promise.all([
21303
21323
  dataService.getPoolConfig(instanceRegistryAddress, poolAddress),
21304
- dataService.getContractDeploymentBlock(poolAddress)
21324
+ syncService.getPoolDeploymentBlock({ chainId, address: poolAddress })
21305
21325
  ]);
21306
21326
  return { config, registeredBlock };
21307
21327
  })
@@ -22010,7 +22030,8 @@ var syncThunk = createAsyncThunk(
22010
22030
  "sync/syncEverything",
22011
22031
  async ({ dataService, syncService, secretManager, verify = false, ...params }, { dispatch }) => {
22012
22032
  unwrapResult(await dispatch(syncPoolsThunk({
22013
- dataService
22033
+ dataService,
22034
+ syncService
22014
22035
  })));
22015
22036
  unwrapResult(await dispatch(syncRelayersThunk({ dataService, syncService })));
22016
22037
  const syncEventsResult = await dispatch(syncEventsThunk({ syncService }));
@@ -17581,6 +17581,24 @@ var SyncService = class {
17581
17581
  toBlock: head
17582
17582
  };
17583
17583
  }
17584
+ async getPoolDeploymentBlock({
17585
+ chainId,
17586
+ address
17587
+ }) {
17588
+ const provider = this.externalSyncProvider;
17589
+ if (provider) {
17590
+ try {
17591
+ return BigInt(
17592
+ await provider.firstCoveredBlock({
17593
+ chainId: toHex(chainId),
17594
+ address: toHex(address, { size: 20 })
17595
+ })
17596
+ );
17597
+ } catch {
17598
+ }
17599
+ }
17600
+ return this.dataService.getContractDeploymentBlock(address);
17601
+ }
17584
17602
  /**
17585
17603
  * Decides whether to use the external provider and, if so, streams its raw
17586
17604
  * events for `[fromBlock, coverage]`. Event-agnostic: callers parse the raw
@@ -17600,11 +17618,12 @@ var SyncService = class {
17600
17618
  }
17601
17619
  const chainId = toHex(rawChainId);
17602
17620
  const hexAddress = toHex(address, { size: 20 });
17603
- const rawCoverage = await provider.lastCoveredBlock({ chainId, address: hexAddress });
17604
- if (!rawCoverage) {
17621
+ let coverage;
17622
+ try {
17623
+ coverage = BigInt(await provider.lastCoveredBlock({ chainId, address: hexAddress }));
17624
+ } catch {
17605
17625
  return null;
17606
17626
  }
17607
- const coverage = BigInt(rawCoverage);
17608
17627
  if (coverage <= fromBlock) {
17609
17628
  return null;
17610
17629
  }
@@ -20868,10 +20887,11 @@ var storeFactory = ({
20868
20887
  var syncPoolsThunk = createAsyncThunk(
20869
20888
  "sync/pools",
20870
20889
  async ({
20871
- dataService
20890
+ dataService,
20891
+ syncService
20872
20892
  }, { dispatch, getState }) => {
20873
20893
  const state = getState();
20874
- const { instanceRegistry: { address: instanceRegistryAddress } } = instanceRegistryInfoSelector(state);
20894
+ const { chainId, instanceRegistry: { address: instanceRegistryAddress } } = instanceRegistryInfoSelector(state);
20875
20895
  const existingPools = poolsSelector(state);
20876
20896
  const poolsAddressses = await dataService.getAllPoolsAddresses(instanceRegistryAddress);
20877
20897
  const unsyncedPools = poolsAddressses.filter((address) => !existingPools.has(address));
@@ -20879,7 +20899,7 @@ var syncPoolsThunk = createAsyncThunk(
20879
20899
  unsyncedPools.map(async (poolAddress) => {
20880
20900
  const [config, registeredBlock] = await Promise.all([
20881
20901
  dataService.getPoolConfig(instanceRegistryAddress, poolAddress),
20882
- dataService.getContractDeploymentBlock(poolAddress)
20902
+ syncService.getPoolDeploymentBlock({ chainId, address: poolAddress })
20883
20903
  ]);
20884
20904
  return { config, registeredBlock };
20885
20905
  })
@@ -21236,7 +21256,8 @@ var syncThunk = createAsyncThunk(
21236
21256
  "sync/syncEverything",
21237
21257
  async ({ dataService, syncService, secretManager, verify = false, ...params }, { dispatch }) => {
21238
21258
  unwrapResult(await dispatch(syncPoolsThunk({
21239
- dataService
21259
+ dataService,
21260
+ syncService
21240
21261
  })));
21241
21262
  unwrapResult(await dispatch(syncRelayersThunk({ dataService, syncService })));
21242
21263
  const syncEventsResult = await dispatch(syncEventsThunk({ syncService }));
@@ -64,7 +64,10 @@ type ExternalSyncClient = {
64
64
  fromBlock: Hex;
65
65
  toBlock: Hex;
66
66
  }): Promise<ExternalRawEvent[]>;
67
- lastCoveredBlock(params: ExternalSyncPoolId): Promise<Hex | null>;
67
+ /** @throws if the provider has no data for the pool. */
68
+ firstCoveredBlock(params: ExternalSyncPoolId): Promise<Hex>;
69
+ /** @throws if the provider has no data for the pool. */
70
+ lastCoveredBlock(params: ExternalSyncPoolId): Promise<Hex>;
68
71
  };
69
72
 
70
73
  interface IRelayerStatusResponse {
@@ -65,7 +65,10 @@ type ExternalSyncClient = {
65
65
  fromBlock: Hex;
66
66
  toBlock: Hex;
67
67
  }): Promise<ExternalRawEvent[]>;
68
- lastCoveredBlock(params: ExternalSyncPoolId): Promise<Hex | null>;
68
+ /** @throws if the provider has no data for the pool. */
69
+ firstCoveredBlock(params: ExternalSyncPoolId): Promise<Hex>;
70
+ /** @throws if the provider has no data for the pool. */
71
+ lastCoveredBlock(params: ExternalSyncPoolId): Promise<Hex>;
69
72
  };
70
73
 
71
74
  interface IRelayerStatusResponse {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kohaku-eth/tornado-cash",
3
- "version": "0.0.2-alpha.13",
3
+ "version": "0.0.2-alpha.15",
4
4
  "description": "Tornado Cash Shielded Pool Kohaku Plugin",
5
5
  "type": "module",
6
6
  "private": false,
@@ -74,8 +74,8 @@
74
74
  "micro-zk-proofs": "0.3.1",
75
75
  "ox": "^0.12.0",
76
76
  "viem": "^2.51.3",
77
+ "@kohaku-eth/mimc-tree": "0.0.3",
77
78
  "@kohaku-eth/provider": "0.1.0-alpha.8",
78
- "mimc-tree": "0.1.0",
79
79
  "@kohaku-eth/plugins": "0.0.1-alpha.11"
80
80
  },
81
81
  "devDependencies": {