fix: update contracts

This commit is contained in:
nikdementev 2021-07-23 15:46:35 +03:00
parent 69f63a4dba
commit 4809d17f27
No known key found for this signature in database
GPG Key ID: 769B05D57CF16FE2
6 changed files with 747 additions and 325 deletions

View File

@ -208,14 +208,21 @@
{ {
"inputs": [ "inputs": [
{ {
"internalType": "bytes", "components": [
"name": "_pubKey", {
"type": "bytes" "internalType": "bytes",
}, "name": "pubKey",
{ "type": "bytes"
"internalType": "bytes", },
"name": "_account", {
"type": "bytes" "internalType": "bytes",
"name": "account",
"type": "bytes"
}
],
"internalType": "struct TornadoPool.Register",
"name": "args",
"type": "tuple"
} }
], ],
"name": "register", "name": "register",
@ -226,44 +233,73 @@
{ {
"inputs": [ "inputs": [
{ {
"internalType": "bytes", "components": [
"name": "_proof", {
"type": "bytes" "internalType": "bytes",
"name": "pubKey",
"type": "bytes"
},
{
"internalType": "bytes",
"name": "account",
"type": "bytes"
}
],
"internalType": "struct TornadoPool.Register",
"name": "_registerArgs",
"type": "tuple"
}, },
{ {
"internalType": "bytes32", "components": [
"name": "_root", {
"type": "bytes32" "internalType": "bytes",
}, "name": "proof",
{ "type": "bytes"
"internalType": "bytes32", },
"name": "_newRoot", {
"type": "bytes32" "internalType": "bytes32",
}, "name": "root",
{ "type": "bytes32"
"internalType": "bytes32[]", },
"name": "_inputNullifiers", {
"type": "bytes32[]" "internalType": "bytes32",
}, "name": "newRoot",
{ "type": "bytes32"
"internalType": "bytes32[2]", },
"name": "_outputCommitments", {
"type": "bytes32[2]" "internalType": "bytes32[]",
}, "name": "inputNullifiers",
{ "type": "bytes32[]"
"internalType": "uint256", },
"name": "_outPathIndices", {
"type": "uint256" "internalType": "bytes32[2]",
}, "name": "outputCommitments",
{ "type": "bytes32[2]"
"internalType": "uint256", },
"name": "_extAmount", {
"type": "uint256" "internalType": "uint256",
}, "name": "outPathIndices",
{ "type": "uint256"
"internalType": "uint256", },
"name": "_fee", {
"type": "uint256" "internalType": "uint256",
"name": "extAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "fee",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "extDataHash",
"type": "bytes32"
}
],
"internalType": "struct TornadoPool.Proof",
"name": "_proofArgs",
"type": "tuple"
}, },
{ {
"components": [ "components": [
@ -291,11 +327,93 @@
"internalType": "struct TornadoPool.ExtData", "internalType": "struct TornadoPool.ExtData",
"name": "_extData", "name": "_extData",
"type": "tuple" "type": "tuple"
}
],
"name": "registerAndTransact",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "bytes",
"name": "proof",
"type": "bytes"
},
{
"internalType": "bytes32",
"name": "root",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "newRoot",
"type": "bytes32"
},
{
"internalType": "bytes32[]",
"name": "inputNullifiers",
"type": "bytes32[]"
},
{
"internalType": "bytes32[2]",
"name": "outputCommitments",
"type": "bytes32[2]"
},
{
"internalType": "uint256",
"name": "outPathIndices",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "extAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "fee",
"type": "uint256"
},
{
"internalType": "bytes32",
"name": "extDataHash",
"type": "bytes32"
}
],
"internalType": "struct TornadoPool.Proof",
"name": "_args",
"type": "tuple"
}, },
{ {
"internalType": "bytes32", "components": [
"name": "_extDataHash", {
"type": "bytes32" "internalType": "address payable",
"name": "recipient",
"type": "address"
},
{
"internalType": "address payable",
"name": "relayer",
"type": "address"
},
{
"internalType": "bytes",
"name": "encryptedOutput1",
"type": "bytes"
},
{
"internalType": "bytes",
"name": "encryptedOutput2",
"type": "bytes"
}
],
"internalType": "struct TornadoPool.ExtData",
"name": "_extData",
"type": "tuple"
} }
], ],
"name": "transaction", "name": "transaction",
@ -332,49 +450,56 @@
{ {
"inputs": [ "inputs": [
{ {
"internalType": "bytes", "components": [
"name": "_proof", {
"type": "bytes" "internalType": "bytes",
}, "name": "proof",
{ "type": "bytes"
"internalType": "bytes32", },
"name": "_root", {
"type": "bytes32" "internalType": "bytes32",
}, "name": "root",
{ "type": "bytes32"
"internalType": "bytes32", },
"name": "_newRoot", {
"type": "bytes32" "internalType": "bytes32",
}, "name": "newRoot",
{ "type": "bytes32"
"internalType": "bytes32[]", },
"name": "_inputNullifiers", {
"type": "bytes32[]" "internalType": "bytes32[]",
}, "name": "inputNullifiers",
{ "type": "bytes32[]"
"internalType": "bytes32[2]", },
"name": "_outputCommitments", {
"type": "bytes32[2]" "internalType": "bytes32[2]",
}, "name": "outputCommitments",
{ "type": "bytes32[2]"
"internalType": "uint256", },
"name": "_outPathIndices", {
"type": "uint256" "internalType": "uint256",
}, "name": "outPathIndices",
{ "type": "uint256"
"internalType": "uint256", },
"name": "_extAmount", {
"type": "uint256" "internalType": "uint256",
}, "name": "extAmount",
{ "type": "uint256"
"internalType": "uint256", },
"name": "_fee", {
"type": "uint256" "internalType": "uint256",
}, "name": "fee",
{ "type": "uint256"
"internalType": "bytes32", },
"name": "_extDataHash", {
"type": "bytes32" "internalType": "bytes32",
"name": "extDataHash",
"type": "bytes32"
}
],
"internalType": "struct TornadoPool.Proof",
"name": "_args",
"type": "tuple"
} }
], ],
"name": "verifyProof", "name": "verifyProof",

View File

@ -29,11 +29,12 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
"currentRoot()": FunctionFragment; "currentRoot()": FunctionFragment;
"isSpent(bytes32)": FunctionFragment; "isSpent(bytes32)": FunctionFragment;
"nullifierHashes(bytes32)": FunctionFragment; "nullifierHashes(bytes32)": FunctionFragment;
"register(bytes,bytes)": FunctionFragment; "register(tuple)": FunctionFragment;
"transaction(bytes,bytes32,bytes32,bytes32[],bytes32[2],uint256,uint256,uint256,tuple,bytes32)": FunctionFragment; "registerAndTransact(tuple,tuple,tuple)": FunctionFragment;
"transaction(tuple,tuple)": FunctionFragment;
"verifier16()": FunctionFragment; "verifier16()": FunctionFragment;
"verifier2()": FunctionFragment; "verifier2()": FunctionFragment;
"verifyProof(bytes,bytes32,bytes32,bytes32[],bytes32[2],uint256,uint256,uint256,bytes32)": FunctionFragment; "verifyProof(tuple)": FunctionFragment;
}; };
encodeFunctionData( encodeFunctionData(
@ -63,26 +64,51 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
): string; ): string;
encodeFunctionData( encodeFunctionData(
functionFragment: "register", functionFragment: "register",
values: [BytesLike, BytesLike] values: [{ pubKey: BytesLike; account: BytesLike }]
): string; ): string;
encodeFunctionData( encodeFunctionData(
functionFragment: "transaction", functionFragment: "registerAndTransact",
values: [ values: [
BytesLike, { pubKey: BytesLike; account: BytesLike },
BytesLike, {
BytesLike, proof: BytesLike;
BytesLike[], root: BytesLike;
[BytesLike, BytesLike], newRoot: BytesLike;
BigNumberish, inputNullifiers: BytesLike[];
BigNumberish, outputCommitments: [BytesLike, BytesLike];
BigNumberish, outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
{ {
recipient: string; recipient: string;
relayer: string; relayer: string;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
}
]
): string;
encodeFunctionData(
functionFragment: "transaction",
values: [
{
proof: BytesLike;
root: BytesLike;
newRoot: BytesLike;
inputNullifiers: BytesLike[];
outputCommitments: [BytesLike, BytesLike];
outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
}, },
BytesLike {
recipient: string;
relayer: string;
encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike;
}
] ]
): string; ): string;
encodeFunctionData( encodeFunctionData(
@ -93,15 +119,17 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
encodeFunctionData( encodeFunctionData(
functionFragment: "verifyProof", functionFragment: "verifyProof",
values: [ values: [
BytesLike, {
BytesLike, proof: BytesLike;
BytesLike, root: BytesLike;
BytesLike[], newRoot: BytesLike;
[BytesLike, BytesLike], inputNullifiers: BytesLike[];
BigNumberish, outputCommitments: [BytesLike, BytesLike];
BigNumberish, outPathIndices: BigNumberish;
BigNumberish, extAmount: BigNumberish;
BytesLike fee: BigNumberish;
extDataHash: BytesLike;
}
] ]
): string; ): string;
@ -128,6 +156,10 @@ interface TornadoPoolInterface extends ethers.utils.Interface {
data: BytesLike data: BytesLike
): Result; ): Result;
decodeFunctionResult(functionFragment: "register", data: BytesLike): Result; decodeFunctionResult(functionFragment: "register", data: BytesLike): Result;
decodeFunctionResult(
functionFragment: "registerAndTransact",
data: BytesLike
): Result;
decodeFunctionResult( decodeFunctionResult(
functionFragment: "transaction", functionFragment: "transaction",
data: BytesLike data: BytesLike
@ -220,27 +252,50 @@ export class TornadoPool extends BaseContract {
): Promise<[boolean]>; ): Promise<[boolean]>;
register( register(
_pubKey: BytesLike, args: { pubKey: BytesLike; account: BytesLike },
_account: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
transaction( registerAndTransact(
_proof: BytesLike, _registerArgs: { pubKey: BytesLike; account: BytesLike },
_root: BytesLike, _proofArgs: {
_newRoot: BytesLike, proof: BytesLike;
_inputNullifiers: BytesLike[], root: BytesLike;
_outputCommitments: [BytesLike, BytesLike], newRoot: BytesLike;
_outPathIndices: BigNumberish, inputNullifiers: BytesLike[];
_extAmount: BigNumberish, outputCommitments: [BytesLike, BytesLike];
_fee: BigNumberish, outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
_extData: {
recipient: string;
relayer: string;
encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike;
},
overrides?: PayableOverrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
transaction(
_args: {
proof: BytesLike;
root: BytesLike;
newRoot: BytesLike;
inputNullifiers: BytesLike[];
outputCommitments: [BytesLike, BytesLike];
outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
_extData: { _extData: {
recipient: string; recipient: string;
relayer: string; relayer: string;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
}, },
_extDataHash: BytesLike,
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: PayableOverrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
@ -249,15 +304,17 @@ export class TornadoPool extends BaseContract {
verifier2(overrides?: CallOverrides): Promise<[string]>; verifier2(overrides?: CallOverrides): Promise<[string]>;
verifyProof( verifyProof(
_proof: BytesLike, _args: {
_root: BytesLike, proof: BytesLike;
_newRoot: BytesLike, root: BytesLike;
_inputNullifiers: BytesLike[], newRoot: BytesLike;
_outputCommitments: [BytesLike, BytesLike], inputNullifiers: BytesLike[];
_outPathIndices: BigNumberish, outputCommitments: [BytesLike, BytesLike];
_extAmount: BigNumberish, outPathIndices: BigNumberish;
_fee: BigNumberish, extAmount: BigNumberish;
_extDataHash: BytesLike, fee: BigNumberish;
extDataHash: BytesLike;
},
overrides?: CallOverrides overrides?: CallOverrides
): Promise<[boolean]>; ): Promise<[boolean]>;
}; };
@ -283,27 +340,50 @@ export class TornadoPool extends BaseContract {
nullifierHashes(arg0: BytesLike, overrides?: CallOverrides): Promise<boolean>; nullifierHashes(arg0: BytesLike, overrides?: CallOverrides): Promise<boolean>;
register( register(
_pubKey: BytesLike, args: { pubKey: BytesLike; account: BytesLike },
_account: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
transaction( registerAndTransact(
_proof: BytesLike, _registerArgs: { pubKey: BytesLike; account: BytesLike },
_root: BytesLike, _proofArgs: {
_newRoot: BytesLike, proof: BytesLike;
_inputNullifiers: BytesLike[], root: BytesLike;
_outputCommitments: [BytesLike, BytesLike], newRoot: BytesLike;
_outPathIndices: BigNumberish, inputNullifiers: BytesLike[];
_extAmount: BigNumberish, outputCommitments: [BytesLike, BytesLike];
_fee: BigNumberish, outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
_extData: {
recipient: string;
relayer: string;
encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike;
},
overrides?: PayableOverrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>;
transaction(
_args: {
proof: BytesLike;
root: BytesLike;
newRoot: BytesLike;
inputNullifiers: BytesLike[];
outputCommitments: [BytesLike, BytesLike];
outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
_extData: { _extData: {
recipient: string; recipient: string;
relayer: string; relayer: string;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
}, },
_extDataHash: BytesLike,
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: PayableOverrides & { from?: string | Promise<string> }
): Promise<ContractTransaction>; ): Promise<ContractTransaction>;
@ -312,15 +392,17 @@ export class TornadoPool extends BaseContract {
verifier2(overrides?: CallOverrides): Promise<string>; verifier2(overrides?: CallOverrides): Promise<string>;
verifyProof( verifyProof(
_proof: BytesLike, _args: {
_root: BytesLike, proof: BytesLike;
_newRoot: BytesLike, root: BytesLike;
_inputNullifiers: BytesLike[], newRoot: BytesLike;
_outputCommitments: [BytesLike, BytesLike], inputNullifiers: BytesLike[];
_outPathIndices: BigNumberish, outputCommitments: [BytesLike, BytesLike];
_extAmount: BigNumberish, outPathIndices: BigNumberish;
_fee: BigNumberish, extAmount: BigNumberish;
_extDataHash: BytesLike, fee: BigNumberish;
extDataHash: BytesLike;
},
overrides?: CallOverrides overrides?: CallOverrides
): Promise<boolean>; ): Promise<boolean>;
@ -349,27 +431,50 @@ export class TornadoPool extends BaseContract {
): Promise<boolean>; ): Promise<boolean>;
register( register(
_pubKey: BytesLike, args: { pubKey: BytesLike; account: BytesLike },
_account: BytesLike,
overrides?: CallOverrides overrides?: CallOverrides
): Promise<void>; ): Promise<void>;
transaction( registerAndTransact(
_proof: BytesLike, _registerArgs: { pubKey: BytesLike; account: BytesLike },
_root: BytesLike, _proofArgs: {
_newRoot: BytesLike, proof: BytesLike;
_inputNullifiers: BytesLike[], root: BytesLike;
_outputCommitments: [BytesLike, BytesLike], newRoot: BytesLike;
_outPathIndices: BigNumberish, inputNullifiers: BytesLike[];
_extAmount: BigNumberish, outputCommitments: [BytesLike, BytesLike];
_fee: BigNumberish, outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
_extData: {
recipient: string;
relayer: string;
encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike;
},
overrides?: CallOverrides
): Promise<void>;
transaction(
_args: {
proof: BytesLike;
root: BytesLike;
newRoot: BytesLike;
inputNullifiers: BytesLike[];
outputCommitments: [BytesLike, BytesLike];
outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
_extData: { _extData: {
recipient: string; recipient: string;
relayer: string; relayer: string;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
}, },
_extDataHash: BytesLike,
overrides?: CallOverrides overrides?: CallOverrides
): Promise<void>; ): Promise<void>;
@ -378,15 +483,17 @@ export class TornadoPool extends BaseContract {
verifier2(overrides?: CallOverrides): Promise<string>; verifier2(overrides?: CallOverrides): Promise<string>;
verifyProof( verifyProof(
_proof: BytesLike, _args: {
_root: BytesLike, proof: BytesLike;
_newRoot: BytesLike, root: BytesLike;
_inputNullifiers: BytesLike[], newRoot: BytesLike;
_outputCommitments: [BytesLike, BytesLike], inputNullifiers: BytesLike[];
_outPathIndices: BigNumberish, outputCommitments: [BytesLike, BytesLike];
_extAmount: BigNumberish, outPathIndices: BigNumberish;
_fee: BigNumberish, extAmount: BigNumberish;
_extDataHash: BytesLike, fee: BigNumberish;
extDataHash: BytesLike;
},
overrides?: CallOverrides overrides?: CallOverrides
): Promise<boolean>; ): Promise<boolean>;
}; };
@ -441,27 +548,50 @@ export class TornadoPool extends BaseContract {
): Promise<BigNumber>; ): Promise<BigNumber>;
register( register(
_pubKey: BytesLike, args: { pubKey: BytesLike; account: BytesLike },
_account: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<BigNumber>; ): Promise<BigNumber>;
transaction( registerAndTransact(
_proof: BytesLike, _registerArgs: { pubKey: BytesLike; account: BytesLike },
_root: BytesLike, _proofArgs: {
_newRoot: BytesLike, proof: BytesLike;
_inputNullifiers: BytesLike[], root: BytesLike;
_outputCommitments: [BytesLike, BytesLike], newRoot: BytesLike;
_outPathIndices: BigNumberish, inputNullifiers: BytesLike[];
_extAmount: BigNumberish, outputCommitments: [BytesLike, BytesLike];
_fee: BigNumberish, outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
_extData: {
recipient: string;
relayer: string;
encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike;
},
overrides?: PayableOverrides & { from?: string | Promise<string> }
): Promise<BigNumber>;
transaction(
_args: {
proof: BytesLike;
root: BytesLike;
newRoot: BytesLike;
inputNullifiers: BytesLike[];
outputCommitments: [BytesLike, BytesLike];
outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
_extData: { _extData: {
recipient: string; recipient: string;
relayer: string; relayer: string;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
}, },
_extDataHash: BytesLike,
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: PayableOverrides & { from?: string | Promise<string> }
): Promise<BigNumber>; ): Promise<BigNumber>;
@ -470,15 +600,17 @@ export class TornadoPool extends BaseContract {
verifier2(overrides?: CallOverrides): Promise<BigNumber>; verifier2(overrides?: CallOverrides): Promise<BigNumber>;
verifyProof( verifyProof(
_proof: BytesLike, _args: {
_root: BytesLike, proof: BytesLike;
_newRoot: BytesLike, root: BytesLike;
_inputNullifiers: BytesLike[], newRoot: BytesLike;
_outputCommitments: [BytesLike, BytesLike], inputNullifiers: BytesLike[];
_outPathIndices: BigNumberish, outputCommitments: [BytesLike, BytesLike];
_extAmount: BigNumberish, outPathIndices: BigNumberish;
_fee: BigNumberish, extAmount: BigNumberish;
_extDataHash: BytesLike, fee: BigNumberish;
extDataHash: BytesLike;
},
overrides?: CallOverrides overrides?: CallOverrides
): Promise<BigNumber>; ): Promise<BigNumber>;
}; };
@ -510,27 +642,50 @@ export class TornadoPool extends BaseContract {
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
register( register(
_pubKey: BytesLike, args: { pubKey: BytesLike; account: BytesLike },
_account: BytesLike,
overrides?: Overrides & { from?: string | Promise<string> } overrides?: Overrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
transaction( registerAndTransact(
_proof: BytesLike, _registerArgs: { pubKey: BytesLike; account: BytesLike },
_root: BytesLike, _proofArgs: {
_newRoot: BytesLike, proof: BytesLike;
_inputNullifiers: BytesLike[], root: BytesLike;
_outputCommitments: [BytesLike, BytesLike], newRoot: BytesLike;
_outPathIndices: BigNumberish, inputNullifiers: BytesLike[];
_extAmount: BigNumberish, outputCommitments: [BytesLike, BytesLike];
_fee: BigNumberish, outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
_extData: {
recipient: string;
relayer: string;
encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike;
},
overrides?: PayableOverrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>;
transaction(
_args: {
proof: BytesLike;
root: BytesLike;
newRoot: BytesLike;
inputNullifiers: BytesLike[];
outputCommitments: [BytesLike, BytesLike];
outPathIndices: BigNumberish;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: BytesLike;
},
_extData: { _extData: {
recipient: string; recipient: string;
relayer: string; relayer: string;
encryptedOutput1: BytesLike; encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike; encryptedOutput2: BytesLike;
}, },
_extDataHash: BytesLike,
overrides?: PayableOverrides & { from?: string | Promise<string> } overrides?: PayableOverrides & { from?: string | Promise<string> }
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
@ -539,15 +694,17 @@ export class TornadoPool extends BaseContract {
verifier2(overrides?: CallOverrides): Promise<PopulatedTransaction>; verifier2(overrides?: CallOverrides): Promise<PopulatedTransaction>;
verifyProof( verifyProof(
_proof: BytesLike, _args: {
_root: BytesLike, proof: BytesLike;
_newRoot: BytesLike, root: BytesLike;
_inputNullifiers: BytesLike[], newRoot: BytesLike;
_outputCommitments: [BytesLike, BytesLike], inputNullifiers: BytesLike[];
_outPathIndices: BigNumberish, outputCommitments: [BytesLike, BytesLike];
_extAmount: BigNumberish, outPathIndices: BigNumberish;
_fee: BigNumberish, extAmount: BigNumberish;
_extDataHash: BytesLike, fee: BigNumberish;
extDataHash: BytesLike;
},
overrides?: CallOverrides overrides?: CallOverrides
): Promise<PopulatedTransaction>; ): Promise<PopulatedTransaction>;
}; };

View File

@ -216,14 +216,21 @@ const _abi = [
{ {
inputs: [ inputs: [
{ {
internalType: "bytes", components: [
name: "_pubKey", {
type: "bytes", internalType: "bytes",
}, name: "pubKey",
{ type: "bytes",
internalType: "bytes", },
name: "_account", {
type: "bytes", internalType: "bytes",
name: "account",
type: "bytes",
},
],
internalType: "struct TornadoPool.Register",
name: "args",
type: "tuple",
}, },
], ],
name: "register", name: "register",
@ -234,44 +241,73 @@ const _abi = [
{ {
inputs: [ inputs: [
{ {
internalType: "bytes", components: [
name: "_proof", {
type: "bytes", internalType: "bytes",
name: "pubKey",
type: "bytes",
},
{
internalType: "bytes",
name: "account",
type: "bytes",
},
],
internalType: "struct TornadoPool.Register",
name: "_registerArgs",
type: "tuple",
}, },
{ {
internalType: "bytes32", components: [
name: "_root", {
type: "bytes32", internalType: "bytes",
}, name: "proof",
{ type: "bytes",
internalType: "bytes32", },
name: "_newRoot", {
type: "bytes32", internalType: "bytes32",
}, name: "root",
{ type: "bytes32",
internalType: "bytes32[]", },
name: "_inputNullifiers", {
type: "bytes32[]", internalType: "bytes32",
}, name: "newRoot",
{ type: "bytes32",
internalType: "bytes32[2]", },
name: "_outputCommitments", {
type: "bytes32[2]", internalType: "bytes32[]",
}, name: "inputNullifiers",
{ type: "bytes32[]",
internalType: "uint256", },
name: "_outPathIndices", {
type: "uint256", internalType: "bytes32[2]",
}, name: "outputCommitments",
{ type: "bytes32[2]",
internalType: "uint256", },
name: "_extAmount", {
type: "uint256", internalType: "uint256",
}, name: "outPathIndices",
{ type: "uint256",
internalType: "uint256", },
name: "_fee", {
type: "uint256", internalType: "uint256",
name: "extAmount",
type: "uint256",
},
{
internalType: "uint256",
name: "fee",
type: "uint256",
},
{
internalType: "bytes32",
name: "extDataHash",
type: "bytes32",
},
],
internalType: "struct TornadoPool.Proof",
name: "_proofArgs",
type: "tuple",
}, },
{ {
components: [ components: [
@ -300,10 +336,92 @@ const _abi = [
name: "_extData", name: "_extData",
type: "tuple", type: "tuple",
}, },
],
name: "registerAndTransact",
outputs: [],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{ {
internalType: "bytes32", components: [
name: "_extDataHash", {
type: "bytes32", internalType: "bytes",
name: "proof",
type: "bytes",
},
{
internalType: "bytes32",
name: "root",
type: "bytes32",
},
{
internalType: "bytes32",
name: "newRoot",
type: "bytes32",
},
{
internalType: "bytes32[]",
name: "inputNullifiers",
type: "bytes32[]",
},
{
internalType: "bytes32[2]",
name: "outputCommitments",
type: "bytes32[2]",
},
{
internalType: "uint256",
name: "outPathIndices",
type: "uint256",
},
{
internalType: "uint256",
name: "extAmount",
type: "uint256",
},
{
internalType: "uint256",
name: "fee",
type: "uint256",
},
{
internalType: "bytes32",
name: "extDataHash",
type: "bytes32",
},
],
internalType: "struct TornadoPool.Proof",
name: "_args",
type: "tuple",
},
{
components: [
{
internalType: "address payable",
name: "recipient",
type: "address",
},
{
internalType: "address payable",
name: "relayer",
type: "address",
},
{
internalType: "bytes",
name: "encryptedOutput1",
type: "bytes",
},
{
internalType: "bytes",
name: "encryptedOutput2",
type: "bytes",
},
],
internalType: "struct TornadoPool.ExtData",
name: "_extData",
type: "tuple",
}, },
], ],
name: "transaction", name: "transaction",
@ -340,49 +458,56 @@ const _abi = [
{ {
inputs: [ inputs: [
{ {
internalType: "bytes", components: [
name: "_proof", {
type: "bytes", internalType: "bytes",
}, name: "proof",
{ type: "bytes",
internalType: "bytes32", },
name: "_root", {
type: "bytes32", internalType: "bytes32",
}, name: "root",
{ type: "bytes32",
internalType: "bytes32", },
name: "_newRoot", {
type: "bytes32", internalType: "bytes32",
}, name: "newRoot",
{ type: "bytes32",
internalType: "bytes32[]", },
name: "_inputNullifiers", {
type: "bytes32[]", internalType: "bytes32[]",
}, name: "inputNullifiers",
{ type: "bytes32[]",
internalType: "bytes32[2]", },
name: "_outputCommitments", {
type: "bytes32[2]", internalType: "bytes32[2]",
}, name: "outputCommitments",
{ type: "bytes32[2]",
internalType: "uint256", },
name: "_outPathIndices", {
type: "uint256", internalType: "uint256",
}, name: "outPathIndices",
{ type: "uint256",
internalType: "uint256", },
name: "_extAmount", {
type: "uint256", internalType: "uint256",
}, name: "extAmount",
{ type: "uint256",
internalType: "uint256", },
name: "_fee", {
type: "uint256", internalType: "uint256",
}, name: "fee",
{ type: "uint256",
internalType: "bytes32", },
name: "_extDataHash", {
type: "bytes32", internalType: "bytes32",
name: "extDataHash",
type: "bytes32",
},
],
internalType: "struct TornadoPool.Proof",
name: "_args",
type: "tuple",
}, },
], ],
name: "verifyProof", name: "verifyProof",

View File

@ -2,15 +2,12 @@ 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]: '0x20a2D506cf52453D681F9E8E814A3437c6242B9e', [ChainId.GOERLI]: '0x5900e35C0ED9807d36d6b9b06701e2004194fd5A',
[ChainId.OPTIMISM]: '0x1Ed4dcDB4b78985008199f451E88C6448C4EDd94', [ChainId.OPTIMISM]: '0xa7727c7807f401FF83a5F96D8b5C4E591b3B0E28',
}; };
export const RPC_LIST: { [chainId in ChainId]: string } = { export const RPC_LIST: { [chainId in ChainId]: string } = {
[ChainId.MAINNET]: [ChainId.MAINNET]: 'https://mainnet.infura.io/v3/eb6a84e726614079948e0b1efce5baa5',
'https://mainnet.infura.io/v3/eb6a84e726614079948e0b1efce5baa5', [ChainId.GOERLI]: 'https://eth-goerli.alchemyapi.io/v2/hlSj0EqPUuLGyyTExs6UqFKnXDrc_eOh',
[ChainId.GOERLI]: [ChainId.OPTIMISM]: 'https://optimism-kovan.infura.io/v3/8f786b96d16046b78e0287fa61c6fcf8',
'https://eth-goerli.alchemyapi.io/v2/hlSj0EqPUuLGyyTExs6UqFKnXDrc_eOh',
[ChainId.OPTIMISM]:
'https://optimism-kovan.infura.io/v3/8f786b96d16046b78e0287fa61c6fcf8',
}; };

View File

@ -22,7 +22,7 @@ const numbers = {
TWO: 2, TWO: 2,
SECOND: 1000, SECOND: 1000,
ETH_DECIMALS: 18, ETH_DECIMALS: 18,
MERKLE_TREE_HEIGHT: 32, MERKLE_TREE_HEIGHT: 23,
}; };
const BG_ZERO = BigNumber.from(numbers.ZERO); const BG_ZERO = BigNumber.from(numbers.ZERO);

View File

@ -1,5 +1,6 @@
import { Job, Queue } from 'bull'; import { Job, Queue } from 'bull';
import { BigNumber } from 'ethers'; import { BigNumber, BigNumberish } from 'ethers';
import { BytesLike } from '@ethersproject/bytes';
import { TxManager } from 'tx-manager'; import { TxManager } from 'tx-manager';
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
@ -13,9 +14,28 @@ import txMangerConfig from '@/config/txManager.config';
import { BaseProcessor } from './base.processor'; import { BaseProcessor } from './base.processor';
import { ChainId } from '@/types'; import { ChainId } from '@/types';
export type ExtData = {
recipient: string;
relayer: string;
encryptedOutput1: BytesLike;
encryptedOutput2: BytesLike;
};
export type ArgsProof = {
proof: BytesLike;
root: BytesLike;
newRoot: BytesLike;
inputNullifiers: string[];
outputCommitments: BytesLike[];
outPathIndices: string;
extAmount: BigNumberish;
fee: BigNumberish;
extDataHash: string;
};
export interface Withdrawal { export interface Withdrawal {
args: string[]; extData: ExtData;
proof: string; args: ArgsProof;
amount: string; amount: string;
txHash: string; txHash: string;
status: string; status: string;
@ -90,20 +110,18 @@ export class WithdrawalProcessor extends BaseProcessor<Withdrawal> {
} }
} }
async prepareTransaction({ proof, args }) { async prepareTransaction({ extData, args }) {
const { chainId, address } = this.configService.get('base'); const { chainId, address } = this.configService.get('base');
const contract = this.providerService.getTornadoPool(); const contract = this.providerService.getTornadoPool();
// @ts-ignore const data = contract.interface.encodeFunctionData('transaction', [args, extData]);
const data = contract.interface.encodeFunctionData('transaction', [proof, ...args]);
let gasLimit = this.configService.get<BigNumber>('base.gasLimit'); let gasLimit = this.configService.get<BigNumber>('base.gasLimit');
// need because optimism has dynamic gas limit // need because optimism has dynamic gas limit
if (chainId === ChainId.OPTIMISM) { if (chainId === ChainId.OPTIMISM) {
// @ts-ignore gasLimit = await contract.estimateGas.transaction(args, extData, {
gasLimit = await contract.estimateGas.transaction(proof, ...args, {
from: address, from: address,
value: BigNumber.from(0)._hex, value: BigNumber.from(0)._hex,
gasPrice: toWei('0.015', 'gwei'), gasPrice: toWei('0.015', 'gwei'),