Skip to content

Commit 055a903

Browse files
authored
Add a chainalysis vanchor contract (#206)
1 parent 4ba54e0 commit 055a903

File tree

17 files changed

+639
-60
lines changed

17 files changed

+639
-60
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,17 @@
6666
"@types/chai": "^4.3.0",
6767
"@types/mocha": "^9.0.0",
6868
"@webb-tools/sdk-core": "0.1.4-113",
69-
"@webb-tools/test-utils": "0.1.4-113",
7069
"@webb-tools/semaphore": "0.0.1-4",
7170
"@webb-tools/semaphore-group": "0.0.1-4",
7271
"@webb-tools/semaphore-identity": "0.0.1-3",
7372
"@webb-tools/semaphore-proof": "0.0.1-3",
73+
"@webb-tools/test-utils": "0.1.4-113",
7474
"babel-plugin-styled-components": "^2.0.7",
7575
"bn.js": "4.11.6",
7676
"chai": "^4.3.5",
7777
"circomlib": "^2.0.5",
7878
"circomlibjs": "0.0.8",
79-
"dotenv": "^8.2.0",
79+
"dotenv": "^16.0.3",
8080
"elliptic": "^6.5.3",
8181
"ethereum-waffle": "^3.4.4",
8282
"hardhat-artifactor": "^0.2.0",
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { ZkComponents } from '@webb-tools/utils';
2+
import { BigNumberish, ethers, BigNumber } from 'ethers';
3+
import { VAnchorEncodeInputs__factory, ChainalysisVAnchor__factory } from '@webb-tools/contracts';
4+
import VAnchor from './VAnchor';
5+
6+
export class ChainalysisVAnchor extends VAnchor {
7+
public static async createVAnchor(
8+
verifier: string,
9+
levels: BigNumberish,
10+
hasher: string,
11+
handler: string,
12+
token: string,
13+
maxEdges: number,
14+
smallCircuitZkComponents: ZkComponents,
15+
largeCircuitZkComponents: ZkComponents,
16+
signer: ethers.Signer
17+
) {
18+
const encodeLibraryFactory = new VAnchorEncodeInputs__factory(signer);
19+
const encodeLibrary = await encodeLibraryFactory.deploy();
20+
await encodeLibrary.deployed();
21+
const factory = new ChainalysisVAnchor__factory(
22+
{ ['contracts/libs/VAnchorEncodeInputs.sol:VAnchorEncodeInputs']: encodeLibrary.address },
23+
signer
24+
);
25+
const vAnchor = await factory.deploy(verifier, levels, hasher, handler, token, maxEdges, {});
26+
await vAnchor.deployed();
27+
const createdVAnchor = new ChainalysisVAnchor(
28+
vAnchor,
29+
signer,
30+
BigNumber.from(levels).toNumber(),
31+
maxEdges,
32+
smallCircuitZkComponents,
33+
largeCircuitZkComponents
34+
);
35+
createdVAnchor.latestSyncedBlock = vAnchor.deployTransaction.blockNumber!;
36+
createdVAnchor.token = token;
37+
return createdVAnchor;
38+
}
39+
}

packages/anchors/src/VAnchor.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { BigNumber, BigNumberish, ContractTransaction, ethers } from 'ethers';
22
import {
33
VAnchor as VAnchorContract,
44
VAnchor__factory,
5+
ChainalysisVAnchor as ChainalysisVAnchorContract,
56
VAnchorEncodeInputs__factory,
67
TokenWrapper__factory,
78
} from '@webb-tools/contracts';
@@ -18,8 +19,6 @@ import {
1819
randomBN,
1920
CircomProvingManager,
2021
ProvingManagerSetupInput,
21-
Note,
22-
NoteGenInput,
2322
MerkleProof,
2423
UtxoGenInput,
2524
CircomUtxo,
@@ -32,7 +31,6 @@ import {
3231
IVariableAnchorPublicInputs,
3332
} from '@webb-tools/interfaces';
3433
import { hexToU8a, u8aToHex, getChainIdType, ZkComponents } from '@webb-tools/utils';
35-
import { solidityPack } from 'ethers/lib/utils';
3634

3735
const zeroAddress = '0x0000000000000000000000000000000000000000';
3836
function checkNativeAddress(tokenAddress: string): boolean {
@@ -50,7 +48,7 @@ export var proofTimeBenchmark = [];
5048
// Functionality relevant to a particular anchor deployment (deposit, withdraw) is implemented in instance methods
5149
export class VAnchor implements IAnchor {
5250
signer: ethers.Signer;
53-
contract: VAnchorContract;
51+
contract: VAnchorContract | ChainalysisVAnchorContract;
5452
tree: MerkleTree;
5553
// hex string of the connected root
5654
maxEdges: number;
@@ -65,7 +63,7 @@ export class VAnchor implements IAnchor {
6563
provingManager: CircomProvingManager;
6664

6765
constructor(
68-
contract: VAnchorContract,
66+
contract: VAnchorContract | ChainalysisVAnchorContract,
6967
signer: ethers.Signer,
7068
treeHeight: number,
7169
maxEdges: number,

packages/anchors/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export { AnchorHandler } from './AnchorHandler';
22
export { VAnchor } from './VAnchor';
3+
export { ChainalysisVAnchor } from './ChainalysisVAnchor';
34
export { IdentityVAnchor } from './IdentityVAnchor';
45
export { OpenVAnchor } from './OpenVAnchor';
56
export { PoseidonHasher } from './PoseidonHasher';

packages/contracts/contracts/handlers/TokenWrapperHandler.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2021 Webb Technologies
2+
* Copyright 2021-2022 Webb Technologies
33
* SPDX-License-Identifier: GPL-3.0-or-later-only
44
*/
55

packages/contracts/contracts/interfaces/external/aave/IAaveLendingPool.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2021 Webb Technologies
2+
* Copyright 2021-2022 Webb Technologies
33
* SPDX-License-Identifier: GPL-3.0-or-later-only
44
*/
55

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Copyright 2021-2022 Webb Technologies
3+
* SPDX-License-Identifier: GPL-3.0-or-later-only
4+
*/
5+
6+
pragma solidity ^0.8.0;
7+
8+
interface ISanctionsList {
9+
function isSanctioned(address addr) external view returns (bool);
10+
}

packages/contracts/contracts/interfaces/tokens/IAaveTokenWrapper.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2021 Webb Technologies
2+
* Copyright 2021-2022 Webb Technologies
33
* SPDX-License-Identifier: GPL-3.0-or-later-only
44
*/
55

packages/contracts/contracts/tokens/AaveTokenWrapper.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2021 Webb Technologies
2+
* Copyright 2021-2022 Webb Technologies
33
* SPDX-License-Identifier: GPL-3.0-or-later-only
44
*/
55

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright 2021-2022 Webb Technologies
3+
* SPDX-License-Identifier: GPL-3.0-or-later-only
4+
*/
5+
6+
import "../interfaces/external/chainalysis/ISanctionsList.sol";
7+
8+
pragma solidity ^0.8.0;
9+
10+
contract SanctionFilter {
11+
address constant SANCTIONS_CONTRACT = 0x40C57923924B5c5c5455c48D93317139ADDaC8fb;
12+
13+
modifier isNotSanctioned(address addr) {
14+
ISanctionsList sanctionsList = ISanctionsList(SANCTIONS_CONTRACT);
15+
require(!sanctionsList.isSanctioned(addr), "SanctionFilter: Sanctioned address");
16+
_;
17+
}
18+
}

0 commit comments

Comments
 (0)