mirror of
https://github.com/tornadocash/tornado-pool-relayer
synced 2024-02-02 15:04:09 +01:00
fix: transfer
This commit is contained in:
parent
1e08f78316
commit
886205ca55
@ -11,8 +11,8 @@
|
|||||||
"build": "nest build",
|
"build": "nest build",
|
||||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
"start": "nest start",
|
"start": "nest start",
|
||||||
"start:dev": "nest start --watch",
|
"start:dev": "NODE_ENV=development nest start --watch",
|
||||||
"start:debug": "nest start --debug --watch",
|
"start:debug": "NODE_ENV=development nest start --debug --watch",
|
||||||
"start:prod": "yarn prebuild; yarn build; node dist/main",
|
"start:prod": "yarn prebuild; yarn build; node dist/main",
|
||||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
|
@ -10,11 +10,6 @@
|
|||||||
"internalType": "contract IVerifier",
|
"internalType": "contract IVerifier",
|
||||||
"name": "_verifier16",
|
"name": "_verifier16",
|
||||||
"type": "address"
|
"type": "address"
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "bytes32",
|
|
||||||
"name": "_currentRoot",
|
|
||||||
"type": "bytes32"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateMutability": "nonpayable",
|
"stateMutability": "nonpayable",
|
||||||
@ -112,6 +107,19 @@
|
|||||||
{
|
{
|
||||||
"inputs": [],
|
"inputs": [],
|
||||||
"name": "MAX_EXT_AMOUNT",
|
"name": "MAX_EXT_AMOUNT",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"internalType": "int256",
|
||||||
|
"name": "",
|
||||||
|
"type": "int256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateMutability": "view",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"inputs": [],
|
||||||
|
"name": "MAX_FEE",
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
@ -125,17 +133,22 @@
|
|||||||
{
|
{
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "int256",
|
||||||
"name": "_extAmount",
|
"name": "_extAmount",
|
||||||
|
"type": "int256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "_fee",
|
||||||
"type": "uint256"
|
"type": "uint256"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "calculateExternalAmount",
|
"name": "calculatePublicAmount",
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"internalType": "int256",
|
"internalType": "uint256",
|
||||||
"name": "",
|
"name": "",
|
||||||
"type": "int256"
|
"type": "uint256"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateMutability": "pure",
|
"stateMutability": "pure",
|
||||||
@ -167,6 +180,19 @@
|
|||||||
"stateMutability": "view",
|
"stateMutability": "view",
|
||||||
"type": "function"
|
"type": "function"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"internalType": "bytes32",
|
||||||
|
"name": "_currentRoot",
|
||||||
|
"type": "bytes32"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "initialize",
|
||||||
|
"outputs": [],
|
||||||
|
"stateMutability": "nonpayable",
|
||||||
|
"type": "function"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
@ -283,12 +309,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
"name": "extAmount",
|
"name": "publicAmount",
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "fee",
|
|
||||||
"type": "uint256"
|
"type": "uint256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -308,11 +329,21 @@
|
|||||||
"name": "recipient",
|
"name": "recipient",
|
||||||
"type": "address"
|
"type": "address"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"internalType": "int256",
|
||||||
|
"name": "extAmount",
|
||||||
|
"type": "int256"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"internalType": "address payable",
|
"internalType": "address payable",
|
||||||
"name": "relayer",
|
"name": "relayer",
|
||||||
"type": "address"
|
"type": "address"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "fee",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"internalType": "bytes",
|
"internalType": "bytes",
|
||||||
"name": "encryptedOutput1",
|
"name": "encryptedOutput1",
|
||||||
@ -370,12 +401,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
"name": "extAmount",
|
"name": "publicAmount",
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "fee",
|
|
||||||
"type": "uint256"
|
"type": "uint256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -395,11 +421,21 @@
|
|||||||
"name": "recipient",
|
"name": "recipient",
|
||||||
"type": "address"
|
"type": "address"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"internalType": "int256",
|
||||||
|
"name": "extAmount",
|
||||||
|
"type": "int256"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"internalType": "address payable",
|
"internalType": "address payable",
|
||||||
"name": "relayer",
|
"name": "relayer",
|
||||||
"type": "address"
|
"type": "address"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"internalType": "uint256",
|
||||||
|
"name": "fee",
|
||||||
|
"type": "uint256"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"internalType": "bytes",
|
"internalType": "bytes",
|
||||||
"name": "encryptedOutput1",
|
"name": "encryptedOutput1",
|
||||||
@ -483,12 +519,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"internalType": "uint256",
|
"internalType": "uint256",
|
||||||
"name": "extAmount",
|
"name": "publicAmount",
|
||||||
"type": "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"internalType": "uint256",
|
|
||||||
"name": "fee",
|
|
||||||
"type": "uint256"
|
"type": "uint256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
145
src/artifacts/TornadoPool.d.ts
vendored
145
src/artifacts/TornadoPool.d.ts
vendored
@ -24,9 +24,11 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
|
|||||||
functions: {
|
functions: {
|
||||||
"FIELD_SIZE()": FunctionFragment;
|
"FIELD_SIZE()": FunctionFragment;
|
||||||
"MAX_EXT_AMOUNT()": FunctionFragment;
|
"MAX_EXT_AMOUNT()": FunctionFragment;
|
||||||
"calculateExternalAmount(uint256)": FunctionFragment;
|
"MAX_FEE()": FunctionFragment;
|
||||||
|
"calculatePublicAmount(int256,uint256)": FunctionFragment;
|
||||||
"currentCommitmentIndex()": FunctionFragment;
|
"currentCommitmentIndex()": FunctionFragment;
|
||||||
"currentRoot()": FunctionFragment;
|
"currentRoot()": FunctionFragment;
|
||||||
|
"initialize(bytes32)": FunctionFragment;
|
||||||
"isSpent(bytes32)": FunctionFragment;
|
"isSpent(bytes32)": FunctionFragment;
|
||||||
"nullifierHashes(bytes32)": FunctionFragment;
|
"nullifierHashes(bytes32)": FunctionFragment;
|
||||||
"register(tuple)": FunctionFragment;
|
"register(tuple)": FunctionFragment;
|
||||||
@ -45,9 +47,10 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
|
|||||||
functionFragment: "MAX_EXT_AMOUNT",
|
functionFragment: "MAX_EXT_AMOUNT",
|
||||||
values?: undefined
|
values?: undefined
|
||||||
): string;
|
): string;
|
||||||
|
encodeFunctionData(functionFragment: "MAX_FEE", values?: undefined): string;
|
||||||
encodeFunctionData(
|
encodeFunctionData(
|
||||||
functionFragment: "calculateExternalAmount",
|
functionFragment: "calculatePublicAmount",
|
||||||
values: [BigNumberish]
|
values: [BigNumberish, BigNumberish]
|
||||||
): string;
|
): string;
|
||||||
encodeFunctionData(
|
encodeFunctionData(
|
||||||
functionFragment: "currentCommitmentIndex",
|
functionFragment: "currentCommitmentIndex",
|
||||||
@ -57,6 +60,10 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
|
|||||||
functionFragment: "currentRoot",
|
functionFragment: "currentRoot",
|
||||||
values?: undefined
|
values?: undefined
|
||||||
): string;
|
): string;
|
||||||
|
encodeFunctionData(
|
||||||
|
functionFragment: "initialize",
|
||||||
|
values: [BytesLike]
|
||||||
|
): string;
|
||||||
encodeFunctionData(functionFragment: "isSpent", values: [BytesLike]): string;
|
encodeFunctionData(functionFragment: "isSpent", values: [BytesLike]): string;
|
||||||
encodeFunctionData(
|
encodeFunctionData(
|
||||||
functionFragment: "nullifierHashes",
|
functionFragment: "nullifierHashes",
|
||||||
@ -77,13 +84,14 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
}
|
}
|
||||||
@ -99,13 +107,14 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
}
|
}
|
||||||
@ -126,8 +135,7 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -138,8 +146,9 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
|
|||||||
functionFragment: "MAX_EXT_AMOUNT",
|
functionFragment: "MAX_EXT_AMOUNT",
|
||||||
data: BytesLike
|
data: BytesLike
|
||||||
): Result;
|
): Result;
|
||||||
|
decodeFunctionResult(functionFragment: "MAX_FEE", data: BytesLike): Result;
|
||||||
decodeFunctionResult(
|
decodeFunctionResult(
|
||||||
functionFragment: "calculateExternalAmount",
|
functionFragment: "calculatePublicAmount",
|
||||||
data: BytesLike
|
data: BytesLike
|
||||||
): Result;
|
): Result;
|
||||||
decodeFunctionResult(
|
decodeFunctionResult(
|
||||||
@ -150,6 +159,7 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
|
|||||||
functionFragment: "currentRoot",
|
functionFragment: "currentRoot",
|
||||||
data: BytesLike
|
data: BytesLike
|
||||||
): Result;
|
): Result;
|
||||||
|
decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result;
|
||||||
decodeFunctionResult(functionFragment: "isSpent", data: BytesLike): Result;
|
decodeFunctionResult(functionFragment: "isSpent", data: BytesLike): Result;
|
||||||
decodeFunctionResult(
|
decodeFunctionResult(
|
||||||
functionFragment: "nullifierHashes",
|
functionFragment: "nullifierHashes",
|
||||||
@ -232,8 +242,11 @@ export class TornadoPool extends BaseContract {
|
|||||||
|
|
||||||
MAX_EXT_AMOUNT(overrides?: CallOverrides): Promise<[BigNumber]>;
|
MAX_EXT_AMOUNT(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||||
|
|
||||||
calculateExternalAmount(
|
MAX_FEE(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||||
|
|
||||||
|
calculatePublicAmount(
|
||||||
_extAmount: BigNumberish,
|
_extAmount: BigNumberish,
|
||||||
|
_fee: BigNumberish,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
): Promise<[BigNumber]>;
|
): Promise<[BigNumber]>;
|
||||||
|
|
||||||
@ -241,6 +254,11 @@ export class TornadoPool extends BaseContract {
|
|||||||
|
|
||||||
currentRoot(overrides?: CallOverrides): Promise<[string]>;
|
currentRoot(overrides?: CallOverrides): Promise<[string]>;
|
||||||
|
|
||||||
|
initialize(
|
||||||
|
_currentRoot: BytesLike,
|
||||||
|
overrides?: Overrides & { from?: string | Promise<string> }
|
||||||
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
isSpent(
|
isSpent(
|
||||||
_nullifierHash: BytesLike,
|
_nullifierHash: BytesLike,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -265,13 +283,14 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
_extData: {
|
_extData: {
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
},
|
},
|
||||||
@ -286,13 +305,14 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
_extData: {
|
_extData: {
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
},
|
},
|
||||||
@ -311,8 +331,7 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -323,8 +342,11 @@ export class TornadoPool extends BaseContract {
|
|||||||
|
|
||||||
MAX_EXT_AMOUNT(overrides?: CallOverrides): Promise<BigNumber>;
|
MAX_EXT_AMOUNT(overrides?: CallOverrides): Promise<BigNumber>;
|
||||||
|
|
||||||
calculateExternalAmount(
|
MAX_FEE(overrides?: CallOverrides): Promise<BigNumber>;
|
||||||
|
|
||||||
|
calculatePublicAmount(
|
||||||
_extAmount: BigNumberish,
|
_extAmount: BigNumberish,
|
||||||
|
_fee: BigNumberish,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
): Promise<BigNumber>;
|
): Promise<BigNumber>;
|
||||||
|
|
||||||
@ -332,6 +354,11 @@ export class TornadoPool extends BaseContract {
|
|||||||
|
|
||||||
currentRoot(overrides?: CallOverrides): Promise<string>;
|
currentRoot(overrides?: CallOverrides): Promise<string>;
|
||||||
|
|
||||||
|
initialize(
|
||||||
|
_currentRoot: BytesLike,
|
||||||
|
overrides?: Overrides & { from?: string | Promise<string> }
|
||||||
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
isSpent(
|
isSpent(
|
||||||
_nullifierHash: BytesLike,
|
_nullifierHash: BytesLike,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -353,13 +380,14 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
_extData: {
|
_extData: {
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
},
|
},
|
||||||
@ -374,13 +402,14 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
_extData: {
|
_extData: {
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
},
|
},
|
||||||
@ -399,8 +428,7 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -411,8 +439,11 @@ export class TornadoPool extends BaseContract {
|
|||||||
|
|
||||||
MAX_EXT_AMOUNT(overrides?: CallOverrides): Promise<BigNumber>;
|
MAX_EXT_AMOUNT(overrides?: CallOverrides): Promise<BigNumber>;
|
||||||
|
|
||||||
calculateExternalAmount(
|
MAX_FEE(overrides?: CallOverrides): Promise<BigNumber>;
|
||||||
|
|
||||||
|
calculatePublicAmount(
|
||||||
_extAmount: BigNumberish,
|
_extAmount: BigNumberish,
|
||||||
|
_fee: BigNumberish,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
): Promise<BigNumber>;
|
): Promise<BigNumber>;
|
||||||
|
|
||||||
@ -420,6 +451,11 @@ export class TornadoPool extends BaseContract {
|
|||||||
|
|
||||||
currentRoot(overrides?: CallOverrides): Promise<string>;
|
currentRoot(overrides?: CallOverrides): Promise<string>;
|
||||||
|
|
||||||
|
initialize(
|
||||||
|
_currentRoot: BytesLike,
|
||||||
|
overrides?: CallOverrides
|
||||||
|
): Promise<void>;
|
||||||
|
|
||||||
isSpent(
|
isSpent(
|
||||||
_nullifierHash: BytesLike,
|
_nullifierHash: BytesLike,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -444,13 +480,14 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
_extData: {
|
_extData: {
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
},
|
},
|
||||||
@ -465,13 +502,14 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
_extData: {
|
_extData: {
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
},
|
},
|
||||||
@ -490,8 +528,7 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -528,8 +565,11 @@ export class TornadoPool extends BaseContract {
|
|||||||
|
|
||||||
MAX_EXT_AMOUNT(overrides?: CallOverrides): Promise<BigNumber>;
|
MAX_EXT_AMOUNT(overrides?: CallOverrides): Promise<BigNumber>;
|
||||||
|
|
||||||
calculateExternalAmount(
|
MAX_FEE(overrides?: CallOverrides): Promise<BigNumber>;
|
||||||
|
|
||||||
|
calculatePublicAmount(
|
||||||
_extAmount: BigNumberish,
|
_extAmount: BigNumberish,
|
||||||
|
_fee: BigNumberish,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
): Promise<BigNumber>;
|
): Promise<BigNumber>;
|
||||||
|
|
||||||
@ -537,6 +577,11 @@ export class TornadoPool extends BaseContract {
|
|||||||
|
|
||||||
currentRoot(overrides?: CallOverrides): Promise<BigNumber>;
|
currentRoot(overrides?: CallOverrides): Promise<BigNumber>;
|
||||||
|
|
||||||
|
initialize(
|
||||||
|
_currentRoot: BytesLike,
|
||||||
|
overrides?: Overrides & { from?: string | Promise<string> }
|
||||||
|
): Promise<BigNumber>;
|
||||||
|
|
||||||
isSpent(
|
isSpent(
|
||||||
_nullifierHash: BytesLike,
|
_nullifierHash: BytesLike,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -561,13 +606,14 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
_extData: {
|
_extData: {
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
},
|
},
|
||||||
@ -582,13 +628,14 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
_extData: {
|
_extData: {
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
},
|
},
|
||||||
@ -607,8 +654,7 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -620,8 +666,11 @@ export class TornadoPool extends BaseContract {
|
|||||||
|
|
||||||
MAX_EXT_AMOUNT(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
MAX_EXT_AMOUNT(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||||
|
|
||||||
calculateExternalAmount(
|
MAX_FEE(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||||
|
|
||||||
|
calculatePublicAmount(
|
||||||
_extAmount: BigNumberish,
|
_extAmount: BigNumberish,
|
||||||
|
_fee: BigNumberish,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
): Promise<PopulatedTransaction>;
|
): Promise<PopulatedTransaction>;
|
||||||
|
|
||||||
@ -631,6 +680,11 @@ export class TornadoPool extends BaseContract {
|
|||||||
|
|
||||||
currentRoot(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
currentRoot(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||||
|
|
||||||
|
initialize(
|
||||||
|
_currentRoot: BytesLike,
|
||||||
|
overrides?: Overrides & { from?: string | Promise<string> }
|
||||||
|
): Promise<PopulatedTransaction>;
|
||||||
|
|
||||||
isSpent(
|
isSpent(
|
||||||
_nullifierHash: BytesLike,
|
_nullifierHash: BytesLike,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -655,13 +709,14 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
_extData: {
|
_extData: {
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
},
|
},
|
||||||
@ -676,13 +731,14 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
_extData: {
|
_extData: {
|
||||||
recipient: string;
|
recipient: string;
|
||||||
|
extAmount: BigNumberish;
|
||||||
relayer: string;
|
relayer: string;
|
||||||
|
fee: BigNumberish;
|
||||||
encryptedOutput1: BytesLike;
|
encryptedOutput1: BytesLike;
|
||||||
encryptedOutput2: BytesLike;
|
encryptedOutput2: BytesLike;
|
||||||
},
|
},
|
||||||
@ -701,8 +757,7 @@ export class TornadoPool extends BaseContract {
|
|||||||
inputNullifiers: BytesLike[];
|
inputNullifiers: BytesLike[];
|
||||||
outputCommitments: [BytesLike, BytesLike];
|
outputCommitments: [BytesLike, BytesLike];
|
||||||
outPathIndices: BigNumberish;
|
outPathIndices: BigNumberish;
|
||||||
extAmount: BigNumberish;
|
publicAmount: BigNumberish;
|
||||||
fee: BigNumberish;
|
|
||||||
extDataHash: BytesLike;
|
extDataHash: BytesLike;
|
||||||
},
|
},
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
|
@ -19,11 +19,6 @@ const _abi = [
|
|||||||
name: "_verifier16",
|
name: "_verifier16",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
internalType: "bytes32",
|
|
||||||
name: "_currentRoot",
|
|
||||||
type: "bytes32",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
stateMutability: "nonpayable",
|
stateMutability: "nonpayable",
|
||||||
type: "constructor",
|
type: "constructor",
|
||||||
@ -120,6 +115,19 @@ const _abi = [
|
|||||||
{
|
{
|
||||||
inputs: [],
|
inputs: [],
|
||||||
name: "MAX_EXT_AMOUNT",
|
name: "MAX_EXT_AMOUNT",
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
internalType: "int256",
|
||||||
|
name: "",
|
||||||
|
type: "int256",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
stateMutability: "view",
|
||||||
|
type: "function",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
inputs: [],
|
||||||
|
name: "MAX_FEE",
|
||||||
outputs: [
|
outputs: [
|
||||||
{
|
{
|
||||||
internalType: "uint256",
|
internalType: "uint256",
|
||||||
@ -133,17 +141,22 @@ const _abi = [
|
|||||||
{
|
{
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
internalType: "uint256",
|
internalType: "int256",
|
||||||
name: "_extAmount",
|
name: "_extAmount",
|
||||||
|
type: "int256",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "_fee",
|
||||||
type: "uint256",
|
type: "uint256",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
name: "calculateExternalAmount",
|
name: "calculatePublicAmount",
|
||||||
outputs: [
|
outputs: [
|
||||||
{
|
{
|
||||||
internalType: "int256",
|
internalType: "uint256",
|
||||||
name: "",
|
name: "",
|
||||||
type: "int256",
|
type: "uint256",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
stateMutability: "pure",
|
stateMutability: "pure",
|
||||||
@ -175,6 +188,19 @@ const _abi = [
|
|||||||
stateMutability: "view",
|
stateMutability: "view",
|
||||||
type: "function",
|
type: "function",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "bytes32",
|
||||||
|
name: "_currentRoot",
|
||||||
|
type: "bytes32",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
name: "initialize",
|
||||||
|
outputs: [],
|
||||||
|
stateMutability: "nonpayable",
|
||||||
|
type: "function",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
@ -291,12 +317,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
internalType: "uint256",
|
internalType: "uint256",
|
||||||
name: "extAmount",
|
name: "publicAmount",
|
||||||
type: "uint256",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint256",
|
|
||||||
name: "fee",
|
|
||||||
type: "uint256",
|
type: "uint256",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -316,11 +337,21 @@ const _abi = [
|
|||||||
name: "recipient",
|
name: "recipient",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
internalType: "int256",
|
||||||
|
name: "extAmount",
|
||||||
|
type: "int256",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
internalType: "address payable",
|
internalType: "address payable",
|
||||||
name: "relayer",
|
name: "relayer",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "fee",
|
||||||
|
type: "uint256",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
internalType: "bytes",
|
internalType: "bytes",
|
||||||
name: "encryptedOutput1",
|
name: "encryptedOutput1",
|
||||||
@ -378,12 +409,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
internalType: "uint256",
|
internalType: "uint256",
|
||||||
name: "extAmount",
|
name: "publicAmount",
|
||||||
type: "uint256",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint256",
|
|
||||||
name: "fee",
|
|
||||||
type: "uint256",
|
type: "uint256",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -403,11 +429,21 @@ const _abi = [
|
|||||||
name: "recipient",
|
name: "recipient",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
internalType: "int256",
|
||||||
|
name: "extAmount",
|
||||||
|
type: "int256",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
internalType: "address payable",
|
internalType: "address payable",
|
||||||
name: "relayer",
|
name: "relayer",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "fee",
|
||||||
|
type: "uint256",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
internalType: "bytes",
|
internalType: "bytes",
|
||||||
name: "encryptedOutput1",
|
name: "encryptedOutput1",
|
||||||
@ -491,12 +527,7 @@ const _abi = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
internalType: "uint256",
|
internalType: "uint256",
|
||||||
name: "extAmount",
|
name: "publicAmount",
|
||||||
type: "uint256",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint256",
|
|
||||||
name: "fee",
|
|
||||||
type: "uint256",
|
type: "uint256",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { registerAs } from '@nestjs/config';
|
import { registerAs } from '@nestjs/config';
|
||||||
|
|
||||||
export default registerAs('bull', () => ({
|
export default registerAs('bull', () => ({
|
||||||
name: 'withdrawal',
|
name: 'transaction',
|
||||||
redis: {
|
redis: {
|
||||||
host: process.env.NODE_ENV === 'development' ? 'localhost' : 'redis',
|
host: process.env.NODE_ENV === 'development' ? 'localhost' : 'redis',
|
||||||
port: 6379,
|
port: 6379,
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { ChainId } from '@/types';
|
import { ChainId } from '@/types';
|
||||||
|
|
||||||
export const CONTRACT_NETWORKS: { [chainId in ChainId]: string } = {
|
export const CONTRACT_NETWORKS: { [chainId in ChainId]: string } = {
|
||||||
[ChainId.MAINNET]: '0x8Bfac9EF3d73cE08C7CEC339C0fE3B2e57814c1E',
|
// [ChainId.MAINNET]: '0x8Bfac9EF3d73cE08C7CEC339C0fE3B2e57814c1E',
|
||||||
[ChainId.GOERLI]: '0x5900e35C0ED9807d36d6b9b06701e2004194fd5A',
|
[ChainId.GOERLI]: '0x3a4cbAC9C28abb1205B5Ca8AdC54b3306B18eEE7',
|
||||||
[ChainId.OPTIMISM]: '0xa7727c7807f401FF83a5F96D8b5C4E591b3B0E28',
|
[ChainId.OPTIMISM]: '0xcd7318c299A82E887f5180EF865a4c350dFC9fe5',
|
||||||
};
|
};
|
||||||
|
|
||||||
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',
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@ import { Controller, Body, Param, Res, Get, Post, HttpStatus } from '@nestjs/com
|
|||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
|
|
||||||
import { ApiService } from './api.service';
|
import { ApiService } from './api.service';
|
||||||
import { validateWithdrawRequest } from './api.validator';
|
import { validateTransactionRequest } from './api.validator';
|
||||||
|
|
||||||
@Controller()
|
@Controller()
|
||||||
export class ApiController {
|
export class ApiController {
|
||||||
@ -29,15 +29,15 @@ export class ApiController {
|
|||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('/withdrawal')
|
@Post('/transaction')
|
||||||
async withdrawal(@Res() res: Response, @Body() { body }: any) {
|
async transaction(@Res() res: Response, @Body() { body }: any) {
|
||||||
const inputError = validateWithdrawRequest(body);
|
const inputError = validateTransactionRequest(body);
|
||||||
|
|
||||||
if (inputError) {
|
if (inputError) {
|
||||||
console.log('Invalid input:', inputError);
|
console.log('Invalid input:', inputError);
|
||||||
return res.status(HttpStatus.BAD_REQUEST).json({ error: inputError });
|
return res.status(HttpStatus.BAD_REQUEST).json({ error: inputError });
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.service.withdrawal(JSON.parse(body));
|
return await this.service.transaction(JSON.parse(body));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ class ApiService {
|
|||||||
constructor(
|
constructor(
|
||||||
private configService: ConfigService,
|
private configService: ConfigService,
|
||||||
private providerService: ProviderService,
|
private providerService: ProviderService,
|
||||||
@InjectQueue('withdrawal') private withdrawalQueue: Queue,
|
@InjectQueue('transaction') private transactionQueue: Queue,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async status(): Promise<Status> {
|
async status(): Promise<Status> {
|
||||||
@ -31,14 +31,14 @@ class ApiService {
|
|||||||
return `This is <a href=https://tornado.cash>tornado.cash</a> Relayer service. Check the <a href=/status>/status</a> for settings`;
|
return `This is <a href=https://tornado.cash>tornado.cash</a> Relayer service. Check the <a href=/status>/status</a> for settings`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async withdrawal(data: any): Promise<string> {
|
async transaction(data: any): Promise<string> {
|
||||||
const job = await this.withdrawalQueue.add(data);
|
const job = await this.transactionQueue.add(data);
|
||||||
|
|
||||||
return String(job.id);
|
return String(job.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getJob(id: string): Promise<Job | null> {
|
async getJob(id: string): Promise<Job | null> {
|
||||||
return await this.withdrawalQueue.getJob(id);
|
return await this.transactionQueue.getJob(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async healthCheck(): Promise<Health> {
|
private async healthCheck(): Promise<Health> {
|
||||||
|
@ -31,7 +31,7 @@ const recipientType = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const withdrawSchema = {
|
const transactionSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
proof: proofType,
|
proof: proofType,
|
||||||
@ -46,9 +46,9 @@ const withdrawSchema = {
|
|||||||
required: ['proof', 'args'],
|
required: ['proof', 'args'],
|
||||||
};
|
};
|
||||||
|
|
||||||
const validateTornadoWithdraw = ajv.compile(withdrawSchema);
|
const validateTornadoTransaction = ajv.compile(transactionSchema);
|
||||||
|
|
||||||
function getInputError(validator: ValidateFunction, data: typeof withdrawSchema) {
|
function getInputError(validator: ValidateFunction, data: typeof transactionSchema) {
|
||||||
validator(data);
|
validator(data);
|
||||||
if (validator.errors) {
|
if (validator.errors) {
|
||||||
const [error] = validator.errors;
|
const [error] = validator.errors;
|
||||||
@ -57,8 +57,8 @@ function getInputError(validator: ValidateFunction, data: typeof withdrawSchema)
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateWithdrawRequest(data: typeof withdrawSchema) {
|
function validateTransactionRequest(data: typeof transactionSchema) {
|
||||||
return getInputError(validateTornadoWithdraw, data);
|
return getInputError(validateTornadoTransaction, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { validateWithdrawRequest };
|
export { validateTransactionRequest };
|
||||||
|
@ -3,13 +3,13 @@ import { Module } from '@nestjs/common';
|
|||||||
|
|
||||||
import { GasPriceService, ProviderService } from '@/services';
|
import { GasPriceService, ProviderService } from '@/services';
|
||||||
|
|
||||||
import { WithdrawalProcessor } from './withdrawal.processor';
|
import { TransactionProcessor } from './transaction.processor';
|
||||||
|
|
||||||
import bullConfig from '@/config/bull.config';
|
import bullConfig from '@/config/bull.config';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [BullModule.registerQueue(bullConfig())],
|
imports: [BullModule.registerQueue(bullConfig())],
|
||||||
providers: [GasPriceService, ProviderService, WithdrawalProcessor],
|
providers: [GasPriceService, ProviderService, TransactionProcessor],
|
||||||
exports: [BullModule],
|
exports: [BullModule],
|
||||||
})
|
})
|
||||||
export class QueueModule {}
|
export class QueueModule {}
|
||||||
|
@ -33,7 +33,7 @@ export type ArgsProof = {
|
|||||||
extDataHash: string;
|
extDataHash: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface Withdrawal {
|
export interface Transaction {
|
||||||
extData: ExtData;
|
extData: ExtData;
|
||||||
args: ArgsProof;
|
args: ArgsProof;
|
||||||
amount: string;
|
amount: string;
|
||||||
@ -43,21 +43,21 @@ export interface Withdrawal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@Processor('withdrawal')
|
@Processor('transaction')
|
||||||
export class WithdrawalProcessor extends BaseProcessor<Withdrawal> {
|
export class TransactionProcessor extends BaseProcessor<Transaction> {
|
||||||
constructor(
|
constructor(
|
||||||
@InjectQueue('withdrawal') public withdrawalQueue: Queue,
|
@InjectQueue('transaction') public transactionQueue: Queue,
|
||||||
private gasPriceService: GasPriceService,
|
private gasPriceService: GasPriceService,
|
||||||
private providerService: ProviderService,
|
private providerService: ProviderService,
|
||||||
private configService: ConfigService,
|
private configService: ConfigService,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.queueName = 'withdrawal';
|
this.queueName = 'transaction';
|
||||||
this.queue = withdrawalQueue;
|
this.queue = transactionQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Process()
|
@Process()
|
||||||
async processWithdrawals(job: Job<Withdrawal>) {
|
async processTransactions(job: Job<Transaction>) {
|
||||||
try {
|
try {
|
||||||
await job.isActive();
|
await job.isActive();
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ export class WithdrawalProcessor extends BaseProcessor<Withdrawal> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async submitTx(job: Job<Withdrawal>) {
|
async submitTx(job: Job<Transaction>) {
|
||||||
try {
|
try {
|
||||||
const txManager = new TxManager(txMangerConfig());
|
const txManager = new TxManager(txMangerConfig());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user