forked from AztecProtocol/aztec-connect-bridges
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dependency update (AztecProtocol#283)
* chore: dependency update * chore: CI and command cleanup * chore: CI and command cleanup 2 * chore: updated config + deps * chore: updated tsconfig * fix: imports after using nodenext * style: formatting * chore: pushed typechain generated files * chore: forge fmt instead of prettier * chore: eslint nodenext compatible config * fix: contract compilation issue * test: jest fix attempt * test: fix attempt * test: most of the client tests working * test: disabled typechecks when using mockImplementation * chore: updated test command * chore: updated linter rules * refactor: cleanup * fix: remove unneeded part of config.yml * fix: only build typechain for interfaces, rollup and bridges + rename ExampleBridgeContract to ExampleBridge * fix: example bridge naming in tests and scripts * fix: add DataProvider to typechain * fix: add python script to esm-ish typechain * fix: run python script to get esm-ish typechain Co-authored-by: LHerskind <[email protected]> Co-authored-by: LHerskind <[email protected]>
- Loading branch information
1 parent
828bd28
commit 0a3949e
Showing
160 changed files
with
49,508 additions
and
907 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ out/ | |
node_modules/ | ||
yarn-error.log | ||
client-dest/ | ||
typechain-types/ | ||
# typechain-types/ | ||
broadcast/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,21 +4,22 @@ | |
"description": "This repo contains the solidity files and typescript helper class for all of the Aztec Connect Bridge Contracts", | ||
"repository": "[email protected]:AztecProtocol/aztec-connect-bridges.git", | ||
"license": "Apache-2.0", | ||
"type": "module", | ||
"scripts": { | ||
"install:foundryup": "curl -L https://foundry.paradigm.xyz | bash", | ||
"install:foundry": "foundryup", | ||
"install:dependencies": "git submodule update --init --recursive && yarn", | ||
"setup": "yarn install:foundryup && yarn install:foundry && yarn", | ||
"setup": "yarn install:foundryup && yarn install:foundry && yarn install:dependencies", | ||
"clean": "rm -rf ./cache ./dest ./out ./typechain-types ./client-dest", | ||
"compile:typechain": "forge build && typechain --target ethers-v5 --out-dir ./typechain-types './out/!(test*|Test*|*.t.sol|*.s.sol)/*.json'", | ||
"compile:client-dest": "yarn compile:typechain && tsc --project tsconfig.client-dest.json", | ||
"build": "forge build && yarn compile:client-dest", | ||
"compile:typechain": "yarn clean && forge build --skip test --skip script && typechain --target ethers-v5 --out-dir ./typechain-types './out/?(DataProvider|RollupProcessor|*Bridge|I*).sol/*.json'", | ||
"compile:client-dest": "tsc --project tsconfig.client-dest.json", | ||
"build": "yarn compile:client-dest", | ||
"test:pinned:14000000": "forge test --fork-block-number 14000000 --match-contract 'Element' --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c", | ||
"test:pinned:14970000": "forge test --fork-block-number 14970000 -m 'testRedistributionSuccessfulSwap|testRedistributionExitWhenICREqualsMCR' --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c", | ||
"test:pinned:14972000": "forge test --fork-block-number 14972000 -m 'testRedistributionFailingSwap' --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c", | ||
"test:pinned": "yarn test:pinned:14000000 && yarn test:pinned:14970000 && yarn test:pinned:14972000", | ||
"test:contracts": "forge test --no-match-contract 'Element' --no-match-test 'testRedistribution' && yarn test:pinned", | ||
"test:clients": "yarn compile:typechain && jest test", | ||
"test:clients": "NODE_OPTIONS=--experimental-vm-modules yarn jest", | ||
"test": "yarn test:contracts && yarn test:clients", | ||
"formatting": "forge fmt && yarn prettier --write ./src/client/**/*.ts", | ||
"formatting:check": "forge fmt --check && prettier --check ./src/client/**/*.ts", | ||
|
@@ -27,15 +28,15 @@ | |
"lint:clients": "eslint \"src/**/*.{ts,tsx}\"" | ||
}, | ||
"dependencies": { | ||
"@aztec/barretenberg": "2.1.45", | ||
"@ethersproject/providers": "^5.7.1", | ||
"@aztec/barretenberg": "2.1.52", | ||
"@ethersproject/providers": "^5.7.2", | ||
"@openzeppelin/contracts": "^4.7.3", | ||
"@typechain/ethers-v5": "^10.1.0", | ||
"ethers": "^5.7.1", | ||
"@typechain/ethers-v5": "^10.1.1", | ||
"ethers": "^5.7.2", | ||
"isomorphic-fetch": "^3.0.0", | ||
"ts-node": "^10.9.1", | ||
"typechain": "^8.1.0", | ||
"typescript": "^4.8.4" | ||
"typechain": "^8.1.1", | ||
"typescript": "^4.9.3" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.2.3", | ||
|
@@ -45,14 +46,25 @@ | |
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jest": "^29.3.1", | ||
"jest-environment-jsdom": "^29.3.1", | ||
"prettier": "^2.7.1", | ||
"solhint": "https://github.com/LHerskind/solhint", | ||
"ts-jest": "^29.0.3" | ||
}, | ||
"jest": { | ||
"preset": "ts-jest/presets/default-esm", | ||
"transform": { | ||
"^.+\\.ts$": "ts-jest" | ||
"^.+\\.ts$": [ | ||
"ts-jest", | ||
{ | ||
"useESM": true | ||
} | ||
] | ||
}, | ||
"moduleNameMapper": { | ||
"^(\\.{1,2}/.*)\\.js$": "$1" | ||
}, | ||
"testEnvironment": "jsdom", | ||
"testRegex": ".*\\.test\\.ts$", | ||
"rootDir": "./src" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import re | ||
from pathlib import Path | ||
|
||
for path in Path('../typechain-types/').rglob('**/*'): | ||
|
||
if Path.is_file(path): | ||
with open(path, 'r') as file: | ||
data = file.read() | ||
|
||
# Fix the ones where we need index.js | ||
outer_pattern = '\* as \w* from \".*\";' | ||
to_fix = re.findall(outer_pattern, data) | ||
y = re.split(outer_pattern, data) | ||
|
||
replacements = [] | ||
for x in to_fix: | ||
inner_pattern = "\* as \w* from \"(.*)\";" | ||
_x = re.search(inner_pattern, x) | ||
cleaned = "{0}/index.js".format(_x[1]) | ||
rep = _x[0].replace(_x[1], cleaned) | ||
replacements.append(rep) | ||
|
||
full = [] | ||
for i in range(len(y)): | ||
full.append(y[i]) | ||
if i < len(replacements): | ||
full.append(replacements[i]) | ||
|
||
data = "".join(full) | ||
|
||
# The more direct .js ones | ||
outer_pattern = '\} from \"[.]{1,2}.*\";' | ||
to_fix = re.findall(outer_pattern, data) | ||
y = re.split(outer_pattern, data) | ||
|
||
replacements = [] | ||
for x in to_fix: | ||
inner_pattern = "\} from \"[.]{1,2}(.*)\";" | ||
_x = re.search(inner_pattern, x) | ||
cleaned = "{0}.js".format(_x[1]) | ||
rep = _x[0].replace(_x[1], cleaned) | ||
replacements.append(rep) | ||
|
||
full = [] | ||
for i in range(len(y)): | ||
full.append(y[i]) | ||
if i < len(replacements): | ||
full.append(replacements[i]) | ||
|
||
data = "".join(full) | ||
|
||
with open(path, 'w+') as f: | ||
f.write(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./web3_provider"; | ||
export * from "./web3_provider.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { EthereumProvider, RequestArguments } from "@aztec/barretenberg/blockchain"; | ||
import { fetch } from "@aztec/barretenberg/iso_fetch"; | ||
import { retry } from "@aztec/barretenberg/retry"; | ||
import { createDebugLogger } from "@aztec/barretenberg/log"; | ||
|
||
const log = createDebugLogger("json_rpc_provider"); | ||
|
||
export class JsonRpcProvider implements EthereumProvider { | ||
private id = 0; | ||
|
||
constructor(private host: string, private netMustSucceed = true) {} | ||
|
||
public async request({ method, params }: RequestArguments): Promise<any> { | ||
const body = { | ||
jsonrpc: "2.0", | ||
id: this.id++, | ||
method, | ||
params, | ||
}; | ||
log(`->`, body); | ||
const res = await this.fetch(body); | ||
log(`<-`, res); | ||
if (res.error) { | ||
throw res.error; | ||
} | ||
return res.result; | ||
} | ||
|
||
on(): this { | ||
throw new Error("Events not supported."); | ||
} | ||
|
||
removeListener(): this { | ||
throw new Error("Events not supported."); | ||
} | ||
|
||
private async fetch(body: any) { | ||
const fn = async () => { | ||
const resp = await fetch(this.host, { | ||
method: "POST", | ||
body: JSON.stringify(body), | ||
headers: { "content-type": "application/json" }, | ||
}); | ||
|
||
if (!resp.ok) { | ||
throw new Error(resp.statusText); | ||
} | ||
|
||
const text = await resp.text(); | ||
try { | ||
return JSON.parse(text); | ||
} catch (err) { | ||
throw new Error(`Failed to parse body as JSON: ${text}`); | ||
} | ||
}; | ||
|
||
if (this.netMustSucceed) { | ||
return await retry(fn, "JsonRpcProvider request"); | ||
} | ||
|
||
return await fn(); | ||
} | ||
} |
Oops, something went wrong.