feat: L2 (XDAI) transfer & withdrawal

This commit is contained in:
nikdementev 2021-10-11 19:06:41 +03:00
parent 631a1c054a
commit 8d735f4a97
No known key found for this signature in database
GPG Key ID: 769B05D57CF16FE2
11 changed files with 683 additions and 157 deletions

@ -33,7 +33,7 @@
"bull": "^3.22.11", "bull": "^3.22.11",
"class-validator": "^0.13.1", "class-validator": "^0.13.1",
"ethers": "^5.4.1", "ethers": "^5.4.1",
"gas-price-oracle": "^0.3.3", "gas-price-oracle": "^0.4.0",
"redis": "^3.1.2", "redis": "^3.1.2",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",

@ -20,30 +20,31 @@
"internalType": "address", "internalType": "address",
"name": "_hasher", "name": "_hasher",
"type": "address" "type": "address"
},
{
"internalType": "contract IERC6777",
"name": "_token",
"type": "address"
},
{
"internalType": "address",
"name": "_omniBridge",
"type": "address"
},
{
"internalType": "address",
"name": "_l1Unwrapper",
"type": "address"
},
{
"internalType": "address",
"name": "_governance",
"type": "address"
} }
], ],
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "constructor" "type": "constructor"
}, },
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes",
"name": "account",
"type": "bytes"
}
],
"name": "EncryptedAccount",
"type": "event"
},
{ {
"anonymous": false, "anonymous": false,
"inputs": [ "inputs": [
@ -190,6 +191,24 @@
"stateMutability": "pure", "stateMutability": "pure",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "uint256",
"name": "_minimalWithdrawalAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_maximumDepositAmount",
"type": "uint256"
}
],
"name": "configureLimits",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "currentRootIndex", "name": "currentRootIndex",
@ -235,6 +254,19 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "governance",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@ -273,7 +305,18 @@
"type": "function" "type": "function"
}, },
{ {
"inputs": [], "inputs": [
{
"internalType": "uint256",
"name": "_minimalWithdrawalAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_maximumDepositAmount",
"type": "uint256"
}
],
"name": "initialize", "name": "initialize",
"outputs": [], "outputs": [],
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
@ -317,6 +360,32 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "l1Unwrapper",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lastBalance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "levels", "name": "levels",
@ -330,6 +399,32 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "maximumDepositAmount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "minimalWithdrawalAmount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "nextIndex", "name": "nextIndex",
@ -362,23 +457,59 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "omniBridge",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IERC6777",
"name": "_token",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "_data",
"type": "bytes"
}
],
"name": "onTokenBridged",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
"components": [ "components": [
{ {
"internalType": "bytes", "internalType": "address",
"name": "pubKey", "name": "owner",
"type": "bytes" "type": "address"
}, },
{ {
"internalType": "bytes", "internalType": "bytes",
"name": "account", "name": "publicKey",
"type": "bytes" "type": "bytes"
} }
], ],
"internalType": "struct TornadoPool.Register", "internalType": "struct TornadoPool.Account",
"name": "args", "name": "_account",
"type": "tuple" "type": "tuple"
} }
], ],
@ -392,18 +523,18 @@
{ {
"components": [ "components": [
{ {
"internalType": "bytes", "internalType": "address",
"name": "pubKey", "name": "owner",
"type": "bytes" "type": "address"
}, },
{ {
"internalType": "bytes", "internalType": "bytes",
"name": "account", "name": "publicKey",
"type": "bytes" "type": "bytes"
} }
], ],
"internalType": "struct TornadoPool.Register", "internalType": "struct TornadoPool.Account",
"name": "_registerArgs", "name": "_account",
"type": "tuple" "type": "tuple"
}, },
{ {
@ -446,7 +577,7 @@
{ {
"components": [ "components": [
{ {
"internalType": "address payable", "internalType": "address",
"name": "recipient", "name": "recipient",
"type": "address" "type": "address"
}, },
@ -456,7 +587,7 @@
"type": "int256" "type": "int256"
}, },
{ {
"internalType": "address payable", "internalType": "address",
"name": "relayer", "name": "relayer",
"type": "address" "type": "address"
}, },
@ -474,6 +605,11 @@
"internalType": "bytes", "internalType": "bytes",
"name": "encryptedOutput2", "name": "encryptedOutput2",
"type": "bytes" "type": "bytes"
},
{
"internalType": "bool",
"name": "isL1Withdrawal",
"type": "bool"
} }
], ],
"internalType": "struct TornadoPool.ExtData", "internalType": "struct TornadoPool.ExtData",
@ -483,7 +619,7 @@
], ],
"name": "registerAndTransact", "name": "registerAndTransact",
"outputs": [], "outputs": [],
"stateMutability": "payable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {
@ -505,6 +641,19 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "token",
"outputs": [
{
"internalType": "contract IERC6777",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
@ -547,7 +696,7 @@
{ {
"components": [ "components": [
{ {
"internalType": "address payable", "internalType": "address",
"name": "recipient", "name": "recipient",
"type": "address" "type": "address"
}, },
@ -557,7 +706,7 @@
"type": "int256" "type": "int256"
}, },
{ {
"internalType": "address payable", "internalType": "address",
"name": "relayer", "name": "relayer",
"type": "address" "type": "address"
}, },
@ -575,6 +724,11 @@
"internalType": "bytes", "internalType": "bytes",
"name": "encryptedOutput2", "name": "encryptedOutput2",
"type": "bytes" "type": "bytes"
},
{
"internalType": "bool",
"name": "isL1Withdrawal",
"type": "bool"
} }
], ],
"internalType": "struct TornadoPool.ExtData", "internalType": "struct TornadoPool.ExtData",
@ -582,9 +736,9 @@
"type": "tuple" "type": "tuple"
} }
], ],
"name": "transaction", "name": "transact",
"outputs": [], "outputs": [],
"stateMutability": "payable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{ {

@ -12,7 +12,6 @@ import {
BaseContract, BaseContract,
ContractTransaction, ContractTransaction,
Overrides, Overrides,
PayableOverrides,
CallOverrides, CallOverrides,
} from "ethers"; } from "ethers";
import { BytesLike } from "@ethersproject/bytes"; import { BytesLike } from "@ethersproject/bytes";
@ -28,21 +27,30 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
"ROOT_HISTORY_SIZE()": FunctionFragment; "ROOT_HISTORY_SIZE()": FunctionFragment;
"ZERO_VALUE()": FunctionFragment; "ZERO_VALUE()": FunctionFragment;
"calculatePublicAmount(int256,uint256)": FunctionFragment; "calculatePublicAmount(int256,uint256)": FunctionFragment;
"configureLimits(uint256,uint256)": FunctionFragment;
"currentRootIndex()": FunctionFragment; "currentRootIndex()": FunctionFragment;
"filledSubtrees(uint256)": FunctionFragment; "filledSubtrees(uint256)": FunctionFragment;
"getLastRoot()": FunctionFragment; "getLastRoot()": FunctionFragment;
"governance()": FunctionFragment;
"hashLeftRight(bytes32,bytes32)": FunctionFragment; "hashLeftRight(bytes32,bytes32)": FunctionFragment;
"hasher()": FunctionFragment; "hasher()": FunctionFragment;
"initialize()": FunctionFragment; "initialize(uint256,uint256)": FunctionFragment;
"isKnownRoot(bytes32)": FunctionFragment; "isKnownRoot(bytes32)": FunctionFragment;
"isSpent(bytes32)": FunctionFragment; "isSpent(bytes32)": FunctionFragment;
"l1Unwrapper()": FunctionFragment;
"lastBalance()": FunctionFragment;
"levels()": FunctionFragment; "levels()": FunctionFragment;
"maximumDepositAmount()": FunctionFragment;
"minimalWithdrawalAmount()": FunctionFragment;
"nextIndex()": FunctionFragment; "nextIndex()": FunctionFragment;
"nullifierHashes(bytes32)": FunctionFragment; "nullifierHashes(bytes32)": FunctionFragment;
"omniBridge()": FunctionFragment;
"onTokenBridged(address,uint256,bytes)": FunctionFragment;
"register(tuple)": FunctionFragment; "register(tuple)": FunctionFragment;
"registerAndTransact(tuple,tuple,tuple)": FunctionFragment; "registerAndTransact(tuple,tuple,tuple)": FunctionFragment;
"roots(uint256)": FunctionFragment; "roots(uint256)": FunctionFragment;
"transaction(tuple,tuple)": FunctionFragment; "token()": FunctionFragment;
"transact(tuple,tuple)": FunctionFragment;
"verifier16()": FunctionFragment; "verifier16()": FunctionFragment;
"verifier2()": FunctionFragment; "verifier2()": FunctionFragment;
"verifyProof(tuple)": FunctionFragment; "verifyProof(tuple)": FunctionFragment;
@ -70,6 +78,10 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
functionFragment: "calculatePublicAmount", functionFragment: "calculatePublicAmount",
values: [BigNumberish, BigNumberish] values: [BigNumberish, BigNumberish]
): string; ): string;
encodeFunctionData(
functionFragment: "configureLimits",
values: [BigNumberish, BigNumberish]
): string;
encodeFunctionData( encodeFunctionData(
functionFragment: "currentRootIndex", functionFragment: "currentRootIndex",
values?: undefined values?: undefined
@ -82,6 +94,10 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
functionFragment: "getLastRoot", functionFragment: "getLastRoot",
values?: undefined values?: undefined
): string; ): string;
encodeFunctionData(
functionFragment: "governance",
values?: undefined
): string;
encodeFunctionData( encodeFunctionData(
functionFragment: "hashLeftRight", functionFragment: "hashLeftRight",
values: [BytesLike, BytesLike] values: [BytesLike, BytesLike]
@ -89,27 +105,51 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
encodeFunctionData(functionFragment: "hasher", values?: undefined): string; encodeFunctionData(functionFragment: "hasher", values?: undefined): string;
encodeFunctionData( encodeFunctionData(
functionFragment: "initialize", functionFragment: "initialize",
values?: undefined values: [BigNumberish, BigNumberish]
): string; ): string;
encodeFunctionData( encodeFunctionData(
functionFragment: "isKnownRoot", functionFragment: "isKnownRoot",
values: [BytesLike] values: [BytesLike]
): string; ): string;
encodeFunctionData(functionFragment: "isSpent", values: [BytesLike]): string; encodeFunctionData(functionFragment: "isSpent", values: [BytesLike]): string;
encodeFunctionData(
functionFragment: "l1Unwrapper",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "lastBalance",
values?: undefined
): string;
encodeFunctionData(functionFragment: "levels", values?: undefined): string; encodeFunctionData(functionFragment: "levels", values?: undefined): string;
encodeFunctionData(
functionFragment: "maximumDepositAmount",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "minimalWithdrawalAmount",
values?: undefined
): string;
encodeFunctionData(functionFragment: "nextIndex", values?: undefined): string; encodeFunctionData(functionFragment: "nextIndex", values?: undefined): string;
encodeFunctionData( encodeFunctionData(
functionFragment: "nullifierHashes", functionFragment: "nullifierHashes",
values: [BytesLike] values: [BytesLike]
): string; ): string;
encodeFunctionData(
functionFragment: "omniBridge",
values?: undefined
): string;
encodeFunctionData(
functionFragment: "onTokenBridged",
values: [string, BigNumberish, BytesLike]
): string;
encodeFunctionData( encodeFunctionData(
functionFragment: "register", functionFragment: "register",
values: [{ pubKey: BytesLike; account: BytesLike }] values: [{ owner: string; publicKey: BytesLike }]
): string; ): string;
encodeFunctionData( encodeFunctionData(
functionFragment: "registerAndTransact", functionFragment: "registerAndTransact",
values: [ values: [
{ pubKey: BytesLike; account: BytesLike }, { owner: string; publicKey: BytesLike },
{ {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -125,12 +165,14 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
} }
] ]
): string; ): string;
encodeFunctionData(functionFragment: "roots", values: [BigNumberish]): string; encodeFunctionData(functionFragment: "roots", values: [BigNumberish]): string;
encodeFunctionData(functionFragment: "token", values?: undefined): string;
encodeFunctionData( encodeFunctionData(
functionFragment: "transaction", functionFragment: "transact",
values: [ values: [
{ {
proof: BytesLike; proof: BytesLike;
@ -147,6 +189,7 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
} }
] ]
): string; ): string;
@ -185,6 +228,10 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
functionFragment: "calculatePublicAmount", functionFragment: "calculatePublicAmount",
data: BytesLike data: BytesLike
): Result; ): Result;
decodeFunctionResult(
functionFragment: "configureLimits",
data: BytesLike
): Result;
decodeFunctionResult( decodeFunctionResult(
functionFragment: "currentRootIndex", functionFragment: "currentRootIndex",
data: BytesLike data: BytesLike
@ -197,6 +244,7 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
functionFragment: "getLastRoot", functionFragment: "getLastRoot",
data: BytesLike data: BytesLike
): Result; ): Result;
decodeFunctionResult(functionFragment: "governance", data: BytesLike): Result;
decodeFunctionResult( decodeFunctionResult(
functionFragment: "hashLeftRight", functionFragment: "hashLeftRight",
data: BytesLike data: BytesLike
@ -208,22 +256,41 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
data: BytesLike data: BytesLike
): Result; ): Result;
decodeFunctionResult(functionFragment: "isSpent", data: BytesLike): Result; decodeFunctionResult(functionFragment: "isSpent", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "l1Unwrapper",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "lastBalance",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "levels", data: BytesLike): Result; decodeFunctionResult(functionFragment: "levels", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "maximumDepositAmount",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "minimalWithdrawalAmount",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "nextIndex", data: BytesLike): Result; decodeFunctionResult(functionFragment: "nextIndex", data: BytesLike): Result;
decodeFunctionResult( decodeFunctionResult(
functionFragment: "nullifierHashes", functionFragment: "nullifierHashes",
data: BytesLike data: BytesLike
): Result; ): Result;
decodeFunctionResult(functionFragment: "omniBridge", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "onTokenBridged",
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "register", data: BytesLike): Result; decodeFunctionResult(functionFragment: "register", data: BytesLike): Result;
decodeFunctionResult( decodeFunctionResult(
functionFragment: "registerAndTransact", functionFragment: "registerAndTransact",
data: BytesLike data: BytesLike
): Result; ): Result;
decodeFunctionResult(functionFragment: "roots", data: BytesLike): Result; decodeFunctionResult(functionFragment: "roots", data: BytesLike): Result;
decodeFunctionResult( decodeFunctionResult(functionFragment: "token", data: BytesLike): Result;
functionFragment: "transaction", decodeFunctionResult(functionFragment: "transact", data: BytesLike): Result;
data: BytesLike
): Result;
decodeFunctionResult(functionFragment: "verifier16", data: BytesLike): Result; decodeFunctionResult(functionFragment: "verifier16", data: BytesLike): Result;
decodeFunctionResult(functionFragment: "verifier2", data: BytesLike): Result; decodeFunctionResult(functionFragment: "verifier2", data: BytesLike): Result;
decodeFunctionResult( decodeFunctionResult(
@ -233,13 +300,11 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
decodeFunctionResult(functionFragment: "zeros", data: BytesLike): Result; decodeFunctionResult(functionFragment: "zeros", data: BytesLike): Result;
events: { events: {
"EncryptedAccount(address,bytes)": EventFragment;
"NewCommitment(bytes32,uint256,bytes)": EventFragment; "NewCommitment(bytes32,uint256,bytes)": EventFragment;
"NewNullifier(bytes32)": EventFragment; "NewNullifier(bytes32)": EventFragment;
"PublicKey(address,bytes)": EventFragment; "PublicKey(address,bytes)": EventFragment;
}; };
getEvent(nameOrSignatureOrTopic: "EncryptedAccount"): EventFragment;
getEvent(nameOrSignatureOrTopic: "NewCommitment"): EventFragment; getEvent(nameOrSignatureOrTopic: "NewCommitment"): EventFragment;
getEvent(nameOrSignatureOrTopic: "NewNullifier"): EventFragment; getEvent(nameOrSignatureOrTopic: "NewNullifier"): EventFragment;
getEvent(nameOrSignatureOrTopic: "PublicKey"): EventFragment; getEvent(nameOrSignatureOrTopic: "PublicKey"): EventFragment;
@ -305,6 +370,12 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<[BigNumber]>; ): Promise<[BigNumber]>;
configureLimits(
_minimalWithdrawalAmount: BigNumberish,
_maximumDepositAmount: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
currentRootIndex(overrides?: CallOverrides): Promise<[number]>; currentRootIndex(overrides?: CallOverrides): Promise<[number]>;
filledSubtrees( filledSubtrees(
@ -314,6 +385,8 @@ export class TornadoPool extends BaseContract {
getLastRoot(overrides?: CallOverrides): Promise<[string]>; getLastRoot(overrides?: CallOverrides): Promise<[string]>;
governance(overrides?: CallOverrides): Promise<[string]>;
hashLeftRight( hashLeftRight(
_left: BytesLike, _left: BytesLike,
_right: BytesLike, _right: BytesLike,
@ -323,6 +396,8 @@ export class TornadoPool extends BaseContract {
hasher(overrides?: CallOverrides): Promise<[string]>; hasher(overrides?: CallOverrides): Promise<[string]>;
initialize( initialize(
_minimalWithdrawalAmount: BigNumberish,
_maximumDepositAmount: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
@ -336,8 +411,16 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<[boolean]>; ): Promise<[boolean]>;
l1Unwrapper(overrides?: CallOverrides): Promise<[string]>;
lastBalance(overrides?: CallOverrides): Promise<[BigNumber]>;
levels(overrides?: CallOverrides): Promise<[number]>; levels(overrides?: CallOverrides): Promise<[number]>;
maximumDepositAmount(overrides?: CallOverrides): Promise<[BigNumber]>;
minimalWithdrawalAmount(overrides?: CallOverrides): Promise<[BigNumber]>;
nextIndex(overrides?: CallOverrides): Promise<[number]>; nextIndex(overrides?: CallOverrides): Promise<[number]>;
nullifierHashes( nullifierHashes(
@ -345,13 +428,22 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<[boolean]>; ): Promise<[boolean]>;
omniBridge(overrides?: CallOverrides): Promise<[string]>;
onTokenBridged(
_token: string,
_amount: BigNumberish,
_data: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
register( register(
args: { pubKey: BytesLike; account: BytesLike }, _account: { owner: string; publicKey: BytesLike },
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
registerAndTransact( registerAndTransact(
_registerArgs: { pubKey: BytesLike; account: BytesLike }, _account: { owner: string; publicKey: BytesLike },
_proofArgs: { _proofArgs: {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -367,13 +459,16 @@ export class TornadoPool extends BaseContract {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
}, },
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
roots(arg0: BigNumberish, overrides?: CallOverrides): Promise<[string]>; roots(arg0: BigNumberish, overrides?: CallOverrides): Promise<[string]>;
transaction( token(overrides?: CallOverrides): Promise<[string]>;
transact(
_args: { _args: {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -389,8 +484,9 @@ export class TornadoPool extends BaseContract {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
}, },
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
verifier16(overrides?: CallOverrides): Promise<[string]>; verifier16(overrides?: CallOverrides): Promise<[string]>;
@ -428,6 +524,12 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<BigNumber>; ): Promise<BigNumber>;
configureLimits(
_minimalWithdrawalAmount: BigNumberish,
_maximumDepositAmount: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
currentRootIndex(overrides?: CallOverrides): Promise<number>; currentRootIndex(overrides?: CallOverrides): Promise<number>;
filledSubtrees( filledSubtrees(
@ -437,6 +539,8 @@ export class TornadoPool extends BaseContract {
getLastRoot(overrides?: CallOverrides): Promise<string>; getLastRoot(overrides?: CallOverrides): Promise<string>;
governance(overrides?: CallOverrides): Promise<string>;
hashLeftRight( hashLeftRight(
_left: BytesLike, _left: BytesLike,
_right: BytesLike, _right: BytesLike,
@ -446,6 +550,8 @@ export class TornadoPool extends BaseContract {
hasher(overrides?: CallOverrides): Promise<string>; hasher(overrides?: CallOverrides): Promise<string>;
initialize( initialize(
_minimalWithdrawalAmount: BigNumberish,
_maximumDepositAmount: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
@ -456,19 +562,36 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<boolean>; ): Promise<boolean>;
l1Unwrapper(overrides?: CallOverrides): Promise<string>;
lastBalance(overrides?: CallOverrides): Promise<BigNumber>;
levels(overrides?: CallOverrides): Promise<number>; levels(overrides?: CallOverrides): Promise<number>;
maximumDepositAmount(overrides?: CallOverrides): Promise<BigNumber>;
minimalWithdrawalAmount(overrides?: CallOverrides): Promise<BigNumber>;
nextIndex(overrides?: CallOverrides): Promise<number>; nextIndex(overrides?: CallOverrides): Promise<number>;
nullifierHashes(arg0: BytesLike, overrides?: CallOverrides): Promise<boolean>; nullifierHashes(arg0: BytesLike, overrides?: CallOverrides): Promise<boolean>;
omniBridge(overrides?: CallOverrides): Promise<string>;
onTokenBridged(
_token: string,
_amount: BigNumberish,
_data: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
register( register(
args: { pubKey: BytesLike; account: BytesLike }, _account: { owner: string; publicKey: BytesLike },
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
registerAndTransact( registerAndTransact(
_registerArgs: { pubKey: BytesLike; account: BytesLike }, _account: { owner: string; publicKey: BytesLike },
_proofArgs: { _proofArgs: {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -484,13 +607,16 @@ export class TornadoPool extends BaseContract {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
}, },
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
roots(arg0: BigNumberish, overrides?: CallOverrides): Promise<string>; roots(arg0: BigNumberish, overrides?: CallOverrides): Promise<string>;
transaction( token(overrides?: CallOverrides): Promise<string>;
transact(
_args: { _args: {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -506,8 +632,9 @@ export class TornadoPool extends BaseContract {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
}, },
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
verifier16(overrides?: CallOverrides): Promise<string>; verifier16(overrides?: CallOverrides): Promise<string>;
@ -545,6 +672,12 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<BigNumber>; ): Promise<BigNumber>;
configureLimits(
_minimalWithdrawalAmount: BigNumberish,
_maximumDepositAmount: BigNumberish,
overrides?: CallOverrides
): Promise<void>;
currentRootIndex(overrides?: CallOverrides): Promise<number>; currentRootIndex(overrides?: CallOverrides): Promise<number>;
filledSubtrees( filledSubtrees(
@ -554,6 +687,8 @@ export class TornadoPool extends BaseContract {
getLastRoot(overrides?: CallOverrides): Promise<string>; getLastRoot(overrides?: CallOverrides): Promise<string>;
governance(overrides?: CallOverrides): Promise<string>;
hashLeftRight( hashLeftRight(
_left: BytesLike, _left: BytesLike,
_right: BytesLike, _right: BytesLike,
@ -562,7 +697,11 @@ export class TornadoPool extends BaseContract {
hasher(overrides?: CallOverrides): Promise<string>; hasher(overrides?: CallOverrides): Promise<string>;
initialize(overrides?: CallOverrides): Promise<void>; initialize(
_minimalWithdrawalAmount: BigNumberish,
_maximumDepositAmount: BigNumberish,
overrides?: CallOverrides
): Promise<void>;
isKnownRoot(_root: BytesLike, overrides?: CallOverrides): Promise<boolean>; isKnownRoot(_root: BytesLike, overrides?: CallOverrides): Promise<boolean>;
@ -571,8 +710,16 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<boolean>; ): Promise<boolean>;
l1Unwrapper(overrides?: CallOverrides): Promise<string>;
lastBalance(overrides?: CallOverrides): Promise<BigNumber>;
levels(overrides?: CallOverrides): Promise<number>; levels(overrides?: CallOverrides): Promise<number>;
maximumDepositAmount(overrides?: CallOverrides): Promise<BigNumber>;
minimalWithdrawalAmount(overrides?: CallOverrides): Promise<BigNumber>;
nextIndex(overrides?: CallOverrides): Promise<number>; nextIndex(overrides?: CallOverrides): Promise<number>;
nullifierHashes( nullifierHashes(
@ -580,13 +727,22 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<boolean>; ): Promise<boolean>;
omniBridge(overrides?: CallOverrides): Promise<string>;
onTokenBridged(
_token: string,
_amount: BigNumberish,
_data: BytesLike,
overrides?: CallOverrides
): Promise<void>;
register( register(
args: { pubKey: BytesLike; account: BytesLike }, _account: { owner: string; publicKey: BytesLike },
overrides?: CallOverrides overrides?: CallOverrides
): Promise<void>; ): Promise<void>;
registerAndTransact( registerAndTransact(
_registerArgs: { pubKey: BytesLike; account: BytesLike }, _account: { owner: string; publicKey: BytesLike },
_proofArgs: { _proofArgs: {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -602,13 +758,16 @@ export class TornadoPool extends BaseContract {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
}, },
overrides?: CallOverrides overrides?: CallOverrides
): Promise<void>; ): Promise<void>;
roots(arg0: BigNumberish, overrides?: CallOverrides): Promise<string>; roots(arg0: BigNumberish, overrides?: CallOverrides): Promise<string>;
transaction( token(overrides?: CallOverrides): Promise<string>;
transact(
_args: { _args: {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -624,6 +783,7 @@ export class TornadoPool extends BaseContract {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
}, },
overrides?: CallOverrides overrides?: CallOverrides
): Promise<void>; ): Promise<void>;
@ -648,11 +808,6 @@ export class TornadoPool extends BaseContract {
}; };
filters: { filters: {
EncryptedAccount(
owner?: string | null,
account?: null
): TypedEventFilter<[string, string], { owner: string; account: string }>;
NewCommitment( NewCommitment(
commitment?: null, commitment?: null,
index?: null, index?: null,
@ -689,6 +844,12 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<BigNumber>; ): Promise<BigNumber>;
configureLimits(
_minimalWithdrawalAmount: BigNumberish,
_maximumDepositAmount: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>;
currentRootIndex(overrides?: CallOverrides): Promise<BigNumber>; currentRootIndex(overrides?: CallOverrides): Promise<BigNumber>;
filledSubtrees( filledSubtrees(
@ -698,6 +859,8 @@ export class TornadoPool extends BaseContract {
getLastRoot(overrides?: CallOverrides): Promise<BigNumber>; getLastRoot(overrides?: CallOverrides): Promise<BigNumber>;
governance(overrides?: CallOverrides): Promise<BigNumber>;
hashLeftRight( hashLeftRight(
_left: BytesLike, _left: BytesLike,
_right: BytesLike, _right: BytesLike,
@ -707,6 +870,8 @@ export class TornadoPool extends BaseContract {
hasher(overrides?: CallOverrides): Promise<BigNumber>; hasher(overrides?: CallOverrides): Promise<BigNumber>;
initialize( initialize(
_minimalWithdrawalAmount: BigNumberish,
_maximumDepositAmount: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>; ): Promise<BigNumber>;
@ -720,8 +885,16 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<BigNumber>; ): Promise<BigNumber>;
l1Unwrapper(overrides?: CallOverrides): Promise<BigNumber>;
lastBalance(overrides?: CallOverrides): Promise<BigNumber>;
levels(overrides?: CallOverrides): Promise<BigNumber>; levels(overrides?: CallOverrides): Promise<BigNumber>;
maximumDepositAmount(overrides?: CallOverrides): Promise<BigNumber>;
minimalWithdrawalAmount(overrides?: CallOverrides): Promise<BigNumber>;
nextIndex(overrides?: CallOverrides): Promise<BigNumber>; nextIndex(overrides?: CallOverrides): Promise<BigNumber>;
nullifierHashes( nullifierHashes(
@ -729,13 +902,22 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<BigNumber>; ): Promise<BigNumber>;
omniBridge(overrides?: CallOverrides): Promise<BigNumber>;
onTokenBridged(
_token: string,
_amount: BigNumberish,
_data: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>;
register( register(
args: { pubKey: BytesLike; account: BytesLike }, _account: { owner: string; publicKey: BytesLike },
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>; ): Promise<BigNumber>;
registerAndTransact( registerAndTransact(
_registerArgs: { pubKey: BytesLike; account: BytesLike }, _account: { owner: string; publicKey: BytesLike },
_proofArgs: { _proofArgs: {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -751,13 +933,16 @@ export class TornadoPool extends BaseContract {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
}, },
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>; ): Promise<BigNumber>;
roots(arg0: BigNumberish, overrides?: CallOverrides): Promise<BigNumber>; roots(arg0: BigNumberish, overrides?: CallOverrides): Promise<BigNumber>;
transaction( token(overrides?: CallOverrides): Promise<BigNumber>;
transact(
_args: { _args: {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -773,8 +958,9 @@ export class TornadoPool extends BaseContract {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
}, },
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>; ): Promise<BigNumber>;
verifier16(overrides?: CallOverrides): Promise<BigNumber>; verifier16(overrides?: CallOverrides): Promise<BigNumber>;
@ -813,6 +999,12 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
configureLimits(
_minimalWithdrawalAmount: BigNumberish,
_maximumDepositAmount: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>;
currentRootIndex(overrides?: CallOverrides): Promise<PopulatedTransaction>; currentRootIndex(overrides?: CallOverrides): Promise<PopulatedTransaction>;
filledSubtrees( filledSubtrees(
@ -822,6 +1014,8 @@ export class TornadoPool extends BaseContract {
getLastRoot(overrides?: CallOverrides): Promise<PopulatedTransaction>; getLastRoot(overrides?: CallOverrides): Promise<PopulatedTransaction>;
governance(overrides?: CallOverrides): Promise<PopulatedTransaction>;
hashLeftRight( hashLeftRight(
_left: BytesLike, _left: BytesLike,
_right: BytesLike, _right: BytesLike,
@ -831,6 +1025,8 @@ export class TornadoPool extends BaseContract {
hasher(overrides?: CallOverrides): Promise<PopulatedTransaction>; hasher(overrides?: CallOverrides): Promise<PopulatedTransaction>;
initialize( initialize(
_minimalWithdrawalAmount: BigNumberish,
_maximumDepositAmount: BigNumberish,
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
@ -844,8 +1040,20 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
l1Unwrapper(overrides?: CallOverrides): Promise<PopulatedTransaction>;
lastBalance(overrides?: CallOverrides): Promise<PopulatedTransaction>;
levels(overrides?: CallOverrides): Promise<PopulatedTransaction>; levels(overrides?: CallOverrides): Promise<PopulatedTransaction>;
maximumDepositAmount(
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
minimalWithdrawalAmount(
overrides?: CallOverrides
): Promise<PopulatedTransaction>;
nextIndex(overrides?: CallOverrides): Promise<PopulatedTransaction>; nextIndex(overrides?: CallOverrides): Promise<PopulatedTransaction>;
nullifierHashes( nullifierHashes(
@ -853,13 +1061,22 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
omniBridge(overrides?: CallOverrides): Promise<PopulatedTransaction>;
onTokenBridged(
_token: string,
_amount: BigNumberish,
_data: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>;
register( register(
args: { pubKey: BytesLike; account: BytesLike }, _account: { owner: string; publicKey: BytesLike },
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
registerAndTransact( registerAndTransact(
_registerArgs: { pubKey: BytesLike; account: BytesLike }, _account: { owner: string; publicKey: BytesLike },
_proofArgs: { _proofArgs: {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -875,8 +1092,9 @@ export class TornadoPool extends BaseContract {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
}, },
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
roots( roots(
@ -884,7 +1102,9 @@ export class TornadoPool extends BaseContract {
overrides?: CallOverrides overrides?: CallOverrides
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
transaction( token(overrides?: CallOverrides): Promise<PopulatedTransaction>;
transact(
_args: { _args: {
proof: BytesLike; proof: BytesLike;
root: BytesLike; root: BytesLike;
@ -900,8 +1120,9 @@ export class TornadoPool extends BaseContract {
fee: BigNumberish; fee: BigNumberish;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
isL1Withdrawal: boolean;
}, },
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
verifier16(overrides?: CallOverrides): Promise<PopulatedTransaction>; verifier16(overrides?: CallOverrides): Promise<PopulatedTransaction>;

@ -29,28 +29,29 @@ const _abi = [
name: "_hasher", name: "_hasher",
type: "address", type: "address",
}, },
],
stateMutability: "nonpayable",
type: "constructor",
},
{ {
anonymous: false, internalType: "contract IERC6777",
inputs: [ name: "_token",
{
indexed: true,
internalType: "address",
name: "owner",
type: "address", type: "address",
}, },
{ {
indexed: false, internalType: "address",
internalType: "bytes", name: "_omniBridge",
name: "account", type: "address",
type: "bytes", },
{
internalType: "address",
name: "_l1Unwrapper",
type: "address",
},
{
internalType: "address",
name: "_governance",
type: "address",
}, },
], ],
name: "EncryptedAccount", stateMutability: "nonpayable",
type: "event", type: "constructor",
}, },
{ {
anonymous: false, anonymous: false,
@ -198,6 +199,24 @@ const _abi = [
stateMutability: "pure", stateMutability: "pure",
type: "function", type: "function",
}, },
{
inputs: [
{
internalType: "uint256",
name: "_minimalWithdrawalAmount",
type: "uint256",
},
{
internalType: "uint256",
name: "_maximumDepositAmount",
type: "uint256",
},
],
name: "configureLimits",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{ {
inputs: [], inputs: [],
name: "currentRootIndex", name: "currentRootIndex",
@ -243,6 +262,19 @@ const _abi = [
stateMutability: "view", stateMutability: "view",
type: "function", type: "function",
}, },
{
inputs: [],
name: "governance",
outputs: [
{
internalType: "address",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{ {
inputs: [ inputs: [
{ {
@ -281,7 +313,18 @@ const _abi = [
type: "function", type: "function",
}, },
{ {
inputs: [], inputs: [
{
internalType: "uint256",
name: "_minimalWithdrawalAmount",
type: "uint256",
},
{
internalType: "uint256",
name: "_maximumDepositAmount",
type: "uint256",
},
],
name: "initialize", name: "initialize",
outputs: [], outputs: [],
stateMutability: "nonpayable", stateMutability: "nonpayable",
@ -325,6 +368,32 @@ const _abi = [
stateMutability: "view", stateMutability: "view",
type: "function", type: "function",
}, },
{
inputs: [],
name: "l1Unwrapper",
outputs: [
{
internalType: "address",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "lastBalance",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{ {
inputs: [], inputs: [],
name: "levels", name: "levels",
@ -338,6 +407,32 @@ const _abi = [
stateMutability: "view", stateMutability: "view",
type: "function", type: "function",
}, },
{
inputs: [],
name: "maximumDepositAmount",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "minimalWithdrawalAmount",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{ {
inputs: [], inputs: [],
name: "nextIndex", name: "nextIndex",
@ -370,23 +465,59 @@ const _abi = [
stateMutability: "view", stateMutability: "view",
type: "function", type: "function",
}, },
{
inputs: [],
name: "omniBridge",
outputs: [
{
internalType: "address",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "contract IERC6777",
name: "_token",
type: "address",
},
{
internalType: "uint256",
name: "_amount",
type: "uint256",
},
{
internalType: "bytes",
name: "_data",
type: "bytes",
},
],
name: "onTokenBridged",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{ {
inputs: [ inputs: [
{ {
components: [ components: [
{ {
internalType: "bytes", internalType: "address",
name: "pubKey", name: "owner",
type: "bytes", type: "address",
}, },
{ {
internalType: "bytes", internalType: "bytes",
name: "account", name: "publicKey",
type: "bytes", type: "bytes",
}, },
], ],
internalType: "struct TornadoPool.Register", internalType: "struct TornadoPool.Account",
name: "args", name: "_account",
type: "tuple", type: "tuple",
}, },
], ],
@ -400,18 +531,18 @@ const _abi = [
{ {
components: [ components: [
{ {
internalType: "bytes", internalType: "address",
name: "pubKey", name: "owner",
type: "bytes", type: "address",
}, },
{ {
internalType: "bytes", internalType: "bytes",
name: "account", name: "publicKey",
type: "bytes", type: "bytes",
}, },
], ],
internalType: "struct TornadoPool.Register", internalType: "struct TornadoPool.Account",
name: "_registerArgs", name: "_account",
type: "tuple", type: "tuple",
}, },
{ {
@ -454,7 +585,7 @@ const _abi = [
{ {
components: [ components: [
{ {
internalType: "address payable", internalType: "address",
name: "recipient", name: "recipient",
type: "address", type: "address",
}, },
@ -464,7 +595,7 @@ const _abi = [
type: "int256", type: "int256",
}, },
{ {
internalType: "address payable", internalType: "address",
name: "relayer", name: "relayer",
type: "address", type: "address",
}, },
@ -483,6 +614,11 @@ const _abi = [
name: "encryptedOutput2", name: "encryptedOutput2",
type: "bytes", type: "bytes",
}, },
{
internalType: "bool",
name: "isL1Withdrawal",
type: "bool",
},
], ],
internalType: "struct TornadoPool.ExtData", internalType: "struct TornadoPool.ExtData",
name: "_extData", name: "_extData",
@ -491,7 +627,7 @@ const _abi = [
], ],
name: "registerAndTransact", name: "registerAndTransact",
outputs: [], outputs: [],
stateMutability: "payable", stateMutability: "nonpayable",
type: "function", type: "function",
}, },
{ {
@ -513,6 +649,19 @@ const _abi = [
stateMutability: "view", stateMutability: "view",
type: "function", type: "function",
}, },
{
inputs: [],
name: "token",
outputs: [
{
internalType: "contract IERC6777",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{ {
inputs: [ inputs: [
{ {
@ -555,7 +704,7 @@ const _abi = [
{ {
components: [ components: [
{ {
internalType: "address payable", internalType: "address",
name: "recipient", name: "recipient",
type: "address", type: "address",
}, },
@ -565,7 +714,7 @@ const _abi = [
type: "int256", type: "int256",
}, },
{ {
internalType: "address payable", internalType: "address",
name: "relayer", name: "relayer",
type: "address", type: "address",
}, },
@ -584,15 +733,20 @@ const _abi = [
name: "encryptedOutput2", name: "encryptedOutput2",
type: "bytes", type: "bytes",
}, },
{
internalType: "bool",
name: "isL1Withdrawal",
type: "bool",
},
], ],
internalType: "struct TornadoPool.ExtData", internalType: "struct TornadoPool.ExtData",
name: "_extData", name: "_extData",
type: "tuple", type: "tuple",
}, },
], ],
name: "transaction", name: "transact",
outputs: [], outputs: [],
stateMutability: "payable", stateMutability: "nonpayable",
type: "function", type: "function",
}, },
{ {

@ -4,10 +4,12 @@ export const CONTRACT_NETWORKS: { [chainId in ChainId]: string } = {
// [ChainId.MAINNET]: '0x8Bfac9EF3d73cE08C7CEC339C0fE3B2e57814c1E', // [ChainId.MAINNET]: '0x8Bfac9EF3d73cE08C7CEC339C0fE3B2e57814c1E',
[ChainId.GOERLI]: '0xE2D9aF526edeB16a02FBC3B68B0eB9B534f9c114', [ChainId.GOERLI]: '0xE2D9aF526edeB16a02FBC3B68B0eB9B534f9c114',
[ChainId.OPTIMISM]: '0xcd7318c299A82E887f5180EF865a4c350dFC9fe5', [ChainId.OPTIMISM]: '0xcd7318c299A82E887f5180EF865a4c350dFC9fe5',
[ChainId.XDAI]: '0xf7Ca3B0522A4Db061eEeaE4A086a79E48F2aCD25',
}; };
export const RPC_LIST: { [chainId in ChainId]: string } = { export const RPC_LIST: { [chainId in ChainId]: string } = {
// [ChainId.MAINNET]: 'https://mainnet.infura.io/v3/eb6a84e726614079948e0b1efce5baa5', // [ChainId.MAINNET]: 'https://mainnet.infura.io/v3/eb6a84e726614079948e0b1efce5baa5',
[ChainId.GOERLI]: 'https://eth-goerli.alchemyapi.io/v2/hlSj0EqPUuLGyyTExs6UqFKnXDrc_eOh', [ChainId.GOERLI]: 'https://eth-goerli.alchemyapi.io/v2/hlSj0EqPUuLGyyTExs6UqFKnXDrc_eOh',
[ChainId.OPTIMISM]: 'https://optimism-kovan.infura.io/v3/8f786b96d16046b78e0287fa61c6fcf8', [ChainId.OPTIMISM]: 'https://optimism-kovan.infura.io/v3/8f786b96d16046b78e0287fa61c6fcf8',
[ChainId.XDAI]: 'https://rpc.xdaichain.com',
}; };

@ -14,6 +14,10 @@ const NETWORKS_INFO: { [chainId in ChainId] } = {
gasLimit: '', gasLimit: '',
minimumBalance: '0.5', minimumBalance: '0.5',
}, },
[ChainId.XDAI]: {
gasLimit: BigNumber.from(2500000),
minimumBalance: '0.5',
},
}; };
const numbers = { const numbers = {

@ -22,6 +22,7 @@ const bytes32Type = { type: 'string', pattern: '^0x[a-fA-F0-9]{64}$' };
const externalAmountType = { type: 'string', pattern: '^(0x[a-fA-F0-9]{64}|-0x[a-fA-F0-9]{63})$' }; const externalAmountType = { type: 'string', pattern: '^(0x[a-fA-F0-9]{64}|-0x[a-fA-F0-9]{63})$' };
const encryptedOutputType = { type: 'string', pattern: '^0x[a-fA-F0-9]{312}$' }; const encryptedOutputType = { type: 'string', pattern: '^0x[a-fA-F0-9]{312}$' };
const arrayType = { type: 'array', items: bytes32Type }; const arrayType = { type: 'array', items: bytes32Type };
const booleanType = { type: 'boolean' };
const transactionSchema = { const transactionSchema = {
type: 'object', type: 'object',
@ -35,6 +36,7 @@ const transactionSchema = {
fee: bytes32Type, fee: bytes32Type,
recipient: addressType, recipient: addressType,
relayer: addressType, relayer: addressType,
isL1Withdrawal: booleanType,
}, },
}, },
args: { args: {

@ -7,12 +7,12 @@ import { ConfigService } from '@nestjs/config';
import { InjectQueue, Process, Processor, OnQueueActive, OnQueueCompleted, OnQueueFailed } from '@nestjs/bull'; import { InjectQueue, Process, Processor, OnQueueActive, OnQueueCompleted, OnQueueFailed } from '@nestjs/bull';
import { numbers, CONTRACT_ERRORS } from '@/constants'; import { numbers, CONTRACT_ERRORS } from '@/constants';
import { toWei, getToIntegerMultiplier } from '@/utilities'; import { getToIntegerMultiplier } from '@/utilities';
import { GasPriceService, ProviderService } from '@/services'; import { GasPriceService, ProviderService } from '@/services';
import txMangerConfig from '@/config/txManager.config'; import txMangerConfig from '@/config/txManager.config';
import { BaseProcessor } from './base.processor'; import { BaseProcessor } from './base.processor';
import { ChainId, Transaction } from '@/types'; import { Transaction } from '@/types';
@Injectable() @Injectable()
@Processor('transaction') @Processor('transaction')
export class TransactionProcessor extends BaseProcessor<Transaction> { export class TransactionProcessor extends BaseProcessor<Transaction> {
@ -98,30 +98,19 @@ export class TransactionProcessor extends BaseProcessor<Transaction> {
} }
async prepareTransaction({ extData, args }) { async prepareTransaction({ extData, args }) {
const { chainId, address } = this.configService.get('base');
const contract = this.providerService.getTornadoPool(); const contract = this.providerService.getTornadoPool();
const data = contract.interface.encodeFunctionData('transaction', [args, extData]); const data = contract.interface.encodeFunctionData('transact', [args, extData]);
let gasLimit = this.configService.get<BigNumber>('base.gasLimit'); let gasLimit = this.configService.get<BigNumber>('base.gasLimit');
// need because optimism has dynamic gas limit
if (chainId === ChainId.OPTIMISM) {
gasLimit = await contract.estimateGas.transaction(args, extData, {
from: address,
value: BigNumber.from(0)._hex,
gasPrice: toWei('0.015', 'gwei'),
});
}
const { fast } = await this.gasPriceService.getGasPrice(); const { fast } = await this.gasPriceService.getGasPrice();
return { return {
data, data,
gasLimit, gasLimit,
to: contract.address, to: contract.address,
gasPrice: toWei(fast.toString(), 'gwei'), gasPrice: fast,
value: BigNumber.from(0)._hex, value: BigNumber.from(0)._hex,
}; };
} }
@ -133,6 +122,7 @@ export class TransactionProcessor extends BaseProcessor<Transaction> {
// for withdrawals the amount is negative // for withdrawals the amount is negative
if (amount.isNegative()) { if (amount.isNegative()) {
const integerMultiplier = getToIntegerMultiplier(serviceFee.withdrawal); const integerMultiplier = getToIntegerMultiplier(serviceFee.withdrawal);
return BigNumber.from(amount) return BigNumber.from(amount)
.mul(serviceFee.withdrawal * integerMultiplier) .mul(serviceFee.withdrawal * integerMultiplier)
.div(numbers.ONE_HUNDRED * integerMultiplier); .div(numbers.ONE_HUNDRED * integerMultiplier);
@ -146,7 +136,7 @@ export class TransactionProcessor extends BaseProcessor<Transaction> {
const { fast } = await this.gasPriceService.getGasPrice(); const { fast } = await this.gasPriceService.getGasPrice();
const expense = BigNumber.from(toWei(fast.toString(), 'gwei')).mul(gasLimit); const expense = BigNumber.from(fast).mul(gasLimit);
const feePercent = this.getServiceFee(externalAmount); const feePercent = this.getServiceFee(externalAmount);

@ -1,12 +1,12 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import { BigNumber } from 'ethers';
import { GasPriceOracle } from 'gas-price-oracle'; import { GasPriceOracle } from 'gas-price-oracle';
import { GasPrice } from 'gas-price-oracle/lib/types';
import { ChainId } from '@/types'; import { ChainId } from '@/types';
import { toWei } from '@/utilities';
import { RPC_LIST, numbers } from '@/constants'; import { RPC_LIST, numbers } from '@/constants';
import { toWei } from '@/utilities';
@Injectable() @Injectable()
export class GasPriceService { export class GasPriceService {
@ -16,30 +16,24 @@ export class GasPriceService {
this.chainId = this.configService.get<number>('base.chainId'); this.chainId = this.configService.get<number>('base.chainId');
} }
async getGasPrice(): Promise<GasPrice> { async getGasPrice() {
if (this.chainId === ChainId.OPTIMISM) { const TIMER = 3;
return GasPriceService.getOptimismPrice();
}
const TIMER = 10;
const INTERVAL = TIMER * numbers.SECOND; const INTERVAL = TIMER * numbers.SECOND;
const instance = new GasPriceOracle({ const instance = new GasPriceOracle({
timeout: INTERVAL, timeout: INTERVAL,
defaultRpc: RPC_LIST[ChainId.MAINNET], defaultRpc: RPC_LIST[ChainId.XDAI],
}); });
return await instance.gasPrices(); const fast = await instance.fetchGasPriceFromRpc();
}
private static getOptimismPrice() { const bnGas = BigNumber.from(toWei(String(fast), 'gwei'));
const OPTIMISM_GAS = toWei('0.015', 'gwei').toNumber();
return { return {
fast: OPTIMISM_GAS, instant: bnGas.mul(130).div(100).toHexString(),
low: OPTIMISM_GAS, fast: bnGas,
instant: OPTIMISM_GAS, standard: bnGas.mul(85).div(100).toHexString(),
standard: OPTIMISM_GAS, low: bnGas.mul(50).div(100).toHexString(),
}; };
} }
} }

@ -4,11 +4,13 @@ import { BytesLike } from '@ethersproject/bytes';
const MAINNET_CHAIN_ID = 1; const MAINNET_CHAIN_ID = 1;
const GOERLI_CHAIN_ID = 5; const GOERLI_CHAIN_ID = 5;
const OPTIMISM_CHAIN_ID = 69; const OPTIMISM_CHAIN_ID = 69;
const XDAI_CHAIN_ID = 100;
export enum ChainId { export enum ChainId {
MAINNET = MAINNET_CHAIN_ID, MAINNET = MAINNET_CHAIN_ID,
GOERLI = GOERLI_CHAIN_ID, GOERLI = GOERLI_CHAIN_ID,
OPTIMISM = OPTIMISM_CHAIN_ID, OPTIMISM = OPTIMISM_CHAIN_ID,
XDAI = XDAI_CHAIN_ID,
} }
export type ExtData = { export type ExtData = {

@ -3140,6 +3140,14 @@ gas-price-oracle@^0.3.3:
axios "^0.19.2" axios "^0.19.2"
bignumber.js "^9.0.0" bignumber.js "^9.0.0"
gas-price-oracle@^0.4.0:
version "0.4.0"
resolved "https://registry.npmjs.org/gas-price-oracle/-/gas-price-oracle-0.4.0.tgz#1b8426bce92ebcff6cc98a0c5638769cb22417b1"
integrity sha512-5ct4VwTqTigD1V3EvUn513e41OIA+/Ubw0FITVfarw7AjVpg4LQSt9anRt+LcDU4+u+eMUEA3VP0VnvMN8nybA==
dependencies:
axios "^0.19.2"
bignumber.js "^9.0.0"
gensync@^1.0.0-beta.2: gensync@^1.0.0-beta.2:
version "1.0.0-beta.2" version "1.0.0-beta.2"
resolved "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" resolved "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0"
@ -5871,16 +5879,11 @@ utils-merge@1.0.1:
resolved "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" resolved "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
uuid@8.3.2, uuid@^8.3.0: uuid@8.3.2, uuid@^8.3.0, uuid@^8.3.2:
version "8.3.2" version "8.3.2"
resolved "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" resolved "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
v8-compile-cache@^2.0.3: v8-compile-cache@^2.0.3:
version "2.3.0" version "2.3.0"
resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"