@kohaku-eth/tornado-cash 0.0.2-alpha.12 → 0.0.2-alpha.13
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 +93 -18
- package/dist/index.js +70 -114
- package/dist/state-manager.worker.js +17031 -17990
- package/dist/state-manager.worker.node.js +16216 -17175
- package/dist/worker-loader.browser.d.ts +53 -8
- package/dist/worker-loader.node.d.ts +53 -8
- package/package.json +4 -4
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as comlink from 'comlink';
|
|
2
2
|
import { combineReducers } from '@reduxjs/toolkit';
|
|
3
3
|
import * as _kohaku_eth_plugins from '@kohaku-eth/plugins';
|
|
4
|
-
import {
|
|
4
|
+
import { ExternalSyncPoolId, ExternalRawEvent, AccountId } from '@kohaku-eth/plugins';
|
|
5
|
+
import { Hex } from 'ox/Hex';
|
|
5
6
|
import * as _kohaku_eth_provider from '@kohaku-eth/provider';
|
|
7
|
+
import { TxData } from '@kohaku-eth/provider';
|
|
8
|
+
import { Address as Address$1 } from 'ox/Address';
|
|
6
9
|
|
|
7
10
|
type Address = bigint & {};
|
|
8
11
|
type Commitment = bigint & {};
|
|
@@ -49,6 +52,21 @@ interface IDepositWithBalance extends IDepositWithAsset {
|
|
|
49
52
|
balance: bigint;
|
|
50
53
|
}
|
|
51
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Worker-facing view of the host's `ExternalSyncProvider`. The host exposes a
|
|
57
|
+
* streaming provider (`streamEvents` returning an async iterator), but async
|
|
58
|
+
* iterators cannot cross the Comlink worker boundary. The plugin adapts the
|
|
59
|
+
* provider into this materialized-array shape on the main thread before proxying
|
|
60
|
+
* it into the state-manager worker (see `plugin/base.ts`).
|
|
61
|
+
*/
|
|
62
|
+
type ExternalSyncClient = {
|
|
63
|
+
getEvents(params: ExternalSyncPoolId & {
|
|
64
|
+
fromBlock: Hex;
|
|
65
|
+
toBlock: Hex;
|
|
66
|
+
}): Promise<ExternalRawEvent[]>;
|
|
67
|
+
lastCoveredBlock(params: ExternalSyncPoolId): Promise<Hex | null>;
|
|
68
|
+
};
|
|
69
|
+
|
|
52
70
|
interface IRelayerStatusResponse {
|
|
53
71
|
currentQueue: number;
|
|
54
72
|
netId: number;
|
|
@@ -92,10 +110,36 @@ declare enum DepositStrategy {
|
|
|
92
110
|
MinFee = 1
|
|
93
111
|
}
|
|
94
112
|
|
|
95
|
-
interface
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
interface SerializedAuth {
|
|
114
|
+
address: Address$1;
|
|
115
|
+
chainId: Hex;
|
|
116
|
+
nonce: Hex;
|
|
117
|
+
r: Hex;
|
|
118
|
+
s: Hex;
|
|
119
|
+
yParity: Hex;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* A userOp serialized to the hex shape expected by `eth_sendUserOperation`, so
|
|
123
|
+
* it can be carried as plain (JSON-serializable) data from the prepare phase
|
|
124
|
+
* (thunk) to the broadcast phase.
|
|
125
|
+
*/
|
|
126
|
+
interface SerializedUserOperation {
|
|
127
|
+
sender: `0x${string}`;
|
|
128
|
+
nonce: `0x${string}`;
|
|
129
|
+
callData: `0x${string}`;
|
|
130
|
+
callGasLimit: `0x${string}`;
|
|
131
|
+
verificationGasLimit: `0x${string}`;
|
|
132
|
+
preVerificationGas: `0x${string}`;
|
|
133
|
+
maxFeePerGas: `0x${string}`;
|
|
134
|
+
maxPriorityFeePerGas: `0x${string}`;
|
|
135
|
+
paymaster?: `0x${string}`;
|
|
136
|
+
paymasterVerificationGasLimit?: `0x${string}`;
|
|
137
|
+
paymasterPostOpGasLimit?: `0x${string}`;
|
|
138
|
+
paymasterData?: `0x${string}`;
|
|
139
|
+
signature: `0x${string}`;
|
|
140
|
+
eip7702Auth?: SerializedAuth;
|
|
98
141
|
}
|
|
142
|
+
|
|
99
143
|
interface IGenericPaymasterWithdrawalPayload {
|
|
100
144
|
mode: 'paymaster';
|
|
101
145
|
proof: TornadoProveOutput;
|
|
@@ -104,8 +148,7 @@ interface IGenericPaymasterWithdrawalPayload {
|
|
|
104
148
|
paymasterAddress: `0x${string}`;
|
|
105
149
|
entryPointAddress: `0x${string}`;
|
|
106
150
|
bundlerUrl: string;
|
|
107
|
-
|
|
108
|
-
delegation?: SignedDelegation;
|
|
151
|
+
userOperation: SerializedUserOperation;
|
|
109
152
|
}
|
|
110
153
|
|
|
111
154
|
type DelegationConfig = {
|
|
@@ -152,6 +195,7 @@ interface IRelayerWithdrawParams extends IWithdrawBaseParams {
|
|
|
152
195
|
interface IPaymasterWithdrawParams extends IWithdrawBaseParams {
|
|
153
196
|
mode: 'paymaster';
|
|
154
197
|
delegation?: DelegationConfig;
|
|
198
|
+
tailCalls?: (address: AccountId) => Promise<TxData[]>;
|
|
155
199
|
}
|
|
156
200
|
type IWithdrawapOperationParams = IRelayerWithdrawParams | IPaymasterWithdrawParams;
|
|
157
201
|
interface IGetNotesParams extends IBaseOperationParams {
|
|
@@ -171,16 +215,17 @@ interface WorkerInitOptions {
|
|
|
171
215
|
relayerConfig?: IRelayerFeeConfig;
|
|
172
216
|
accountIndex: number;
|
|
173
217
|
paymasterConfig: IChainsPaymastersConfig;
|
|
218
|
+
minExternalSyncBlocksAmount?: number;
|
|
174
219
|
}
|
|
175
220
|
|
|
176
221
|
declare function loadStateManagerWorker(workerUrl?: string | URL): {
|
|
177
222
|
remote: comlink.Remote<{
|
|
178
|
-
init(provider: _kohaku_eth_provider.EthereumProvider, relayerClient: IRelayerClient, keystore: _kohaku_eth_plugins.Keystore, rawStorage: Omit<_kohaku_eth_plugins.Storage, "_brand">, initialState: () => Promise<Record<string, PublicRootState>>, artifactsLoader: () => Promise<ITornadoArtifacts>, { protocolConfig, accountIndex, relayerConfig, paymasterConfig }: WorkerInitOptions): Promise<void>;
|
|
223
|
+
init(provider: _kohaku_eth_provider.EthereumProvider, relayerClient: IRelayerClient, keystore: _kohaku_eth_plugins.Keystore, rawStorage: Omit<_kohaku_eth_plugins.Storage, "_brand">, initialState: () => Promise<Record<string, PublicRootState>>, artifactsLoader: () => Promise<ITornadoArtifacts>, externalSyncProvider: ExternalSyncClient | undefined, { protocolConfig, accountIndex, relayerConfig, paymasterConfig, minExternalSyncBlocksAmount }: WorkerInitOptions): Promise<void>;
|
|
179
224
|
sync(): Promise<void>;
|
|
180
225
|
getBalances(assets?: Address[]): Promise<Map<Address, bigint>>;
|
|
181
226
|
getNotes(params: IGetNotesParams): Promise<TCNote[]>;
|
|
182
227
|
getDepositPayload(params: IDepositOperationParams): Promise<_kohaku_eth_provider.TxData[]>;
|
|
183
|
-
getWithdrawalPayloads(params: IWithdrawapOperationParams): Promise<IWithdrawalPayload[]>;
|
|
228
|
+
getWithdrawalPayloads(params: IWithdrawapOperationParams, tailCalls?: IPaymasterWithdrawParams["tailCalls"]): Promise<IWithdrawalPayload[]>;
|
|
184
229
|
dumpState(): Record<StoreStorageKey, Omit<RootState, "userSecrets">>;
|
|
185
230
|
}>;
|
|
186
231
|
onError: (handler: (err: Error) => void) => void;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as comlink from 'comlink';
|
|
2
2
|
import { combineReducers } from '@reduxjs/toolkit';
|
|
3
3
|
import * as _kohaku_eth_plugins from '@kohaku-eth/plugins';
|
|
4
|
-
import {
|
|
4
|
+
import { ExternalSyncPoolId, ExternalRawEvent, AccountId } from '@kohaku-eth/plugins';
|
|
5
|
+
import { Hex } from 'ox/Hex';
|
|
5
6
|
import * as _kohaku_eth_provider from '@kohaku-eth/provider';
|
|
7
|
+
import { TxData } from '@kohaku-eth/provider';
|
|
8
|
+
import { Address as Address$1 } from 'ox/Address';
|
|
6
9
|
import { Worker } from 'worker_threads';
|
|
7
10
|
|
|
8
11
|
type Address = bigint & {};
|
|
@@ -50,6 +53,21 @@ interface IDepositWithBalance extends IDepositWithAsset {
|
|
|
50
53
|
balance: bigint;
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Worker-facing view of the host's `ExternalSyncProvider`. The host exposes a
|
|
58
|
+
* streaming provider (`streamEvents` returning an async iterator), but async
|
|
59
|
+
* iterators cannot cross the Comlink worker boundary. The plugin adapts the
|
|
60
|
+
* provider into this materialized-array shape on the main thread before proxying
|
|
61
|
+
* it into the state-manager worker (see `plugin/base.ts`).
|
|
62
|
+
*/
|
|
63
|
+
type ExternalSyncClient = {
|
|
64
|
+
getEvents(params: ExternalSyncPoolId & {
|
|
65
|
+
fromBlock: Hex;
|
|
66
|
+
toBlock: Hex;
|
|
67
|
+
}): Promise<ExternalRawEvent[]>;
|
|
68
|
+
lastCoveredBlock(params: ExternalSyncPoolId): Promise<Hex | null>;
|
|
69
|
+
};
|
|
70
|
+
|
|
53
71
|
interface IRelayerStatusResponse {
|
|
54
72
|
currentQueue: number;
|
|
55
73
|
netId: number;
|
|
@@ -93,10 +111,36 @@ declare enum DepositStrategy {
|
|
|
93
111
|
MinFee = 1
|
|
94
112
|
}
|
|
95
113
|
|
|
96
|
-
interface
|
|
97
|
-
|
|
98
|
-
|
|
114
|
+
interface SerializedAuth {
|
|
115
|
+
address: Address$1;
|
|
116
|
+
chainId: Hex;
|
|
117
|
+
nonce: Hex;
|
|
118
|
+
r: Hex;
|
|
119
|
+
s: Hex;
|
|
120
|
+
yParity: Hex;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A userOp serialized to the hex shape expected by `eth_sendUserOperation`, so
|
|
124
|
+
* it can be carried as plain (JSON-serializable) data from the prepare phase
|
|
125
|
+
* (thunk) to the broadcast phase.
|
|
126
|
+
*/
|
|
127
|
+
interface SerializedUserOperation {
|
|
128
|
+
sender: `0x${string}`;
|
|
129
|
+
nonce: `0x${string}`;
|
|
130
|
+
callData: `0x${string}`;
|
|
131
|
+
callGasLimit: `0x${string}`;
|
|
132
|
+
verificationGasLimit: `0x${string}`;
|
|
133
|
+
preVerificationGas: `0x${string}`;
|
|
134
|
+
maxFeePerGas: `0x${string}`;
|
|
135
|
+
maxPriorityFeePerGas: `0x${string}`;
|
|
136
|
+
paymaster?: `0x${string}`;
|
|
137
|
+
paymasterVerificationGasLimit?: `0x${string}`;
|
|
138
|
+
paymasterPostOpGasLimit?: `0x${string}`;
|
|
139
|
+
paymasterData?: `0x${string}`;
|
|
140
|
+
signature: `0x${string}`;
|
|
141
|
+
eip7702Auth?: SerializedAuth;
|
|
99
142
|
}
|
|
143
|
+
|
|
100
144
|
interface IGenericPaymasterWithdrawalPayload {
|
|
101
145
|
mode: 'paymaster';
|
|
102
146
|
proof: TornadoProveOutput;
|
|
@@ -105,8 +149,7 @@ interface IGenericPaymasterWithdrawalPayload {
|
|
|
105
149
|
paymasterAddress: `0x${string}`;
|
|
106
150
|
entryPointAddress: `0x${string}`;
|
|
107
151
|
bundlerUrl: string;
|
|
108
|
-
|
|
109
|
-
delegation?: SignedDelegation;
|
|
152
|
+
userOperation: SerializedUserOperation;
|
|
110
153
|
}
|
|
111
154
|
|
|
112
155
|
type DelegationConfig = {
|
|
@@ -153,6 +196,7 @@ interface IRelayerWithdrawParams extends IWithdrawBaseParams {
|
|
|
153
196
|
interface IPaymasterWithdrawParams extends IWithdrawBaseParams {
|
|
154
197
|
mode: 'paymaster';
|
|
155
198
|
delegation?: DelegationConfig;
|
|
199
|
+
tailCalls?: (address: AccountId) => Promise<TxData[]>;
|
|
156
200
|
}
|
|
157
201
|
type IWithdrawapOperationParams = IRelayerWithdrawParams | IPaymasterWithdrawParams;
|
|
158
202
|
interface IGetNotesParams extends IBaseOperationParams {
|
|
@@ -172,16 +216,17 @@ interface WorkerInitOptions {
|
|
|
172
216
|
relayerConfig?: IRelayerFeeConfig;
|
|
173
217
|
accountIndex: number;
|
|
174
218
|
paymasterConfig: IChainsPaymastersConfig;
|
|
219
|
+
minExternalSyncBlocksAmount?: number;
|
|
175
220
|
}
|
|
176
221
|
|
|
177
222
|
declare function loadStateManagerWorker(workerUrl?: string | URL): {
|
|
178
223
|
remote: comlink.Remote<{
|
|
179
|
-
init(provider: _kohaku_eth_provider.EthereumProvider, relayerClient: IRelayerClient, keystore: _kohaku_eth_plugins.Keystore, rawStorage: Omit<_kohaku_eth_plugins.Storage, "_brand">, initialState: () => Promise<Record<string, PublicRootState>>, artifactsLoader: () => Promise<ITornadoArtifacts>, { protocolConfig, accountIndex, relayerConfig, paymasterConfig }: WorkerInitOptions): Promise<void>;
|
|
224
|
+
init(provider: _kohaku_eth_provider.EthereumProvider, relayerClient: IRelayerClient, keystore: _kohaku_eth_plugins.Keystore, rawStorage: Omit<_kohaku_eth_plugins.Storage, "_brand">, initialState: () => Promise<Record<string, PublicRootState>>, artifactsLoader: () => Promise<ITornadoArtifacts>, externalSyncProvider: ExternalSyncClient | undefined, { protocolConfig, accountIndex, relayerConfig, paymasterConfig, minExternalSyncBlocksAmount }: WorkerInitOptions): Promise<void>;
|
|
180
225
|
sync(): Promise<void>;
|
|
181
226
|
getBalances(assets?: Address[]): Promise<Map<Address, bigint>>;
|
|
182
227
|
getNotes(params: IGetNotesParams): Promise<TCNote[]>;
|
|
183
228
|
getDepositPayload(params: IDepositOperationParams): Promise<_kohaku_eth_provider.TxData[]>;
|
|
184
|
-
getWithdrawalPayloads(params: IWithdrawapOperationParams): Promise<IWithdrawalPayload[]>;
|
|
229
|
+
getWithdrawalPayloads(params: IWithdrawapOperationParams, tailCalls?: IPaymasterWithdrawParams["tailCalls"]): Promise<IWithdrawalPayload[]>;
|
|
185
230
|
dumpState(): Record<StoreStorageKey, Omit<RootState, "userSecrets">>;
|
|
186
231
|
}>;
|
|
187
232
|
onError: (handler: (err: Error) => void) => Worker;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kohaku-eth/tornado-cash",
|
|
3
|
-
"version": "0.0.2-alpha.
|
|
3
|
+
"version": "0.0.2-alpha.13",
|
|
4
4
|
"description": "Tornado Cash Shielded Pool Kohaku Plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -68,15 +68,15 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@noble/curves": "^2.2.0",
|
|
70
70
|
"@noble/hashes": "^2.2.0",
|
|
71
|
-
"@privacy-paymasters/sdk": "0.0.
|
|
71
|
+
"@privacy-paymasters/sdk": "0.0.4",
|
|
72
72
|
"@reduxjs/toolkit": "^2.11.2",
|
|
73
73
|
"comlink": "^4.4.2",
|
|
74
74
|
"micro-zk-proofs": "0.3.1",
|
|
75
75
|
"ox": "^0.12.0",
|
|
76
76
|
"viem": "^2.51.3",
|
|
77
|
-
"@kohaku-eth/plugins": "0.0.1-alpha.10",
|
|
78
77
|
"@kohaku-eth/provider": "0.1.0-alpha.8",
|
|
79
|
-
"mimc-tree": "0.1.0"
|
|
78
|
+
"mimc-tree": "0.1.0",
|
|
79
|
+
"@kohaku-eth/plugins": "0.0.1-alpha.11"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/node": "^24.12.2",
|