From 9527f362d4bbb8ee69ec81cc8946ccf34c9a53a8 Mon Sep 17 00:00:00 2001 From: Asa Oines Date: Thu, 17 Mar 2022 08:59:18 -0700 Subject: [PATCH] Remove typechain package (#238) --- package-lock.json | 230 ++++----- package.json | 1 - solidity/abacus-core/.gitignore | 3 +- solidity/abacus-core/hardhat.config.ts | 2 +- solidity/abacus-core/package.json | 13 +- solidity/abacus-core/test/common.test.ts | 2 +- solidity/abacus-core/test/inbox.test.ts | 3 +- .../abacus-core/test/lib/AbacusDeployment.ts | 3 +- solidity/abacus-core/test/lib/upgrade.ts | 3 +- solidity/abacus-core/test/merkle.test.ts | 2 +- solidity/abacus-core/test/message.test.ts | 2 +- solidity/abacus-core/test/outbox.test.ts | 3 +- solidity/abacus-core/test/upgrade.test.ts | 2 +- .../abacus-core/test/validatorManager.test.ts | 2 +- .../test/xAppConnectionManager.test.ts | 9 +- solidity/abacus-core/tsconfig.json | 83 +-- solidity/abacus-xapps/.gitignore | 3 +- .../contracts/bridge/BridgeRouter.sol | 10 +- .../contracts/bridge/BridgeToken.sol | 4 +- .../contracts/bridge/ETHHelper.sol | 2 +- .../contracts/bridge/TokenRegistry.sol | 6 +- .../contracts/governance/GovernanceRouter.sol | 6 +- .../contracts/ping-pong/PingPongRouter.sol | 4 +- .../xapp-template/RouterTemplate.sol | 4 +- solidity/abacus-xapps/hardhat.config.ts | 2 +- solidity/abacus-xapps/package.json | 13 +- solidity/abacus-xapps/recoveryManager.test.ts | 484 ------------------ .../test/bridge/BridgeToken.test.ts | 2 +- .../test/bridge/EthHelper.test.ts | 34 +- .../abacus-xapps/test/bridge/bridge.test.ts | 39 +- .../test/bridge/bridgeMessage.test.ts | 2 +- .../abacus-xapps/test/bridge/encoding.test.ts | 2 +- .../test/bridge/lib/BridgeDeploy.ts | 7 +- .../test/bridge/lib/BridgeDeployment.ts | 130 ----- .../abacus-xapps/test/bridge/lib/permit.ts | 2 +- .../abacus-xapps/test/bridge/lib/utils.ts | 10 - .../test/governance/governanceRouter.test.ts | 7 +- .../test/governance/lib/GovernanceDeploy.ts | 7 +- .../governance/lib/GovernanceDeployment.ts | 79 --- solidity/abacus-xapps/tsconfig.json | 83 +-- ...nfig.package.json => tsconfig.package.json | 2 +- typescript/abacus-deploy/package.json | 4 +- .../src/bridge/BridgeContracts.ts | 25 +- .../abacus-deploy/src/bridge/BridgeDeploy.ts | 8 +- .../src/bridge/BridgeInstance.ts | 33 +- .../abacus-deploy/src/common/BeaconProxy.ts | 33 +- .../abacus-deploy/src/core/CoreContracts.ts | 44 +- .../abacus-deploy/src/core/CoreDeploy.ts | 18 +- .../abacus-deploy/src/core/CoreInstance.ts | 61 ++- .../abacus-deploy/src/core/implementation.ts | 6 +- .../src/governance/GovernanceContracts.ts | 11 +- .../src/governance/GovernanceDeploy.ts | 4 +- .../src/governance/GovernanceInstance.ts | 24 +- .../abacus-deploy/src/verification/utils.ts | 9 +- typescript/abacus-deploy/tsconfig.json | 2 +- typescript/abacus-sdk/.gitignore | 1 - typescript/abacus-sdk/package.json | 12 +- .../abacus-sdk/src/abacus/AbacusContext.ts | 18 +- .../src/abacus/contracts/BridgeContracts.ts | 17 +- .../src/abacus/contracts/CoreContracts.ts | 29 +- .../src/abacus/events/abacusEvents.ts | 2 +- .../src/abacus/events/bridgeEvents.ts | 2 +- .../abacus-sdk/src/abacus/events/fetch.ts | 2 +- .../src/abacus/messages/AbacusMessage.ts | 8 +- .../src/abacus/messages/BridgeMessage.ts | 6 +- .../abacus-sdk/src/abacus/tokens/index.ts | 4 +- typescript/abacus-sdk/tsconfig.json | 2 +- typescript/contract-metrics/.gitignore | 1 - typescript/contract-metrics/package.json | 6 +- .../src/monitor/governance.ts | 4 +- typescript/contract-metrics/tsconfig.json | 2 +- typescript/hardhat/package.json | 7 +- typescript/hardhat/src/TestAbacusDeploy.ts | 4 +- typescript/hardhat/tsconfig.json | 2 +- typescript/typechain/.gitignore | 4 - typescript/typechain/.npmignore | 0 typescript/typechain/index.ts | 2 - typescript/typechain/package.json | 23 - typescript/typechain/tsconfig.json | 20 - typescript/utils/package.json | 4 +- typescript/utils/tsconfig.json | 2 +- 81 files changed, 424 insertions(+), 1349 deletions(-) delete mode 100644 solidity/abacus-xapps/recoveryManager.test.ts delete mode 100644 solidity/abacus-xapps/test/bridge/lib/BridgeDeployment.ts delete mode 100644 solidity/abacus-xapps/test/governance/lib/GovernanceDeployment.ts rename typescript/tsconfig.package.json => tsconfig.package.json (95%) delete mode 100644 typescript/typechain/.gitignore delete mode 100644 typescript/typechain/.npmignore delete mode 100644 typescript/typechain/index.ts delete mode 100644 typescript/typechain/package.json delete mode 100644 typescript/typechain/tsconfig.json diff --git a/package-lock.json b/package-lock.json index d1f87616b..d6e117976 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,17 +10,12 @@ "solidity/abacus-core", "typescript/hardhat", "solidity/abacus-xapps", - "typescript/typechain", "typescript/abacus-sdk", "typescript/contract-metrics", "typescript/abacus-deploy" ] }, - "node_modules/@abacus-network/abacus-sol": { - "resolved": "solidity/abacus-core", - "link": true - }, - "node_modules/@abacus-network/abacus-xapps-sol": { + "node_modules/@abacus-network/apps": { "resolved": "solidity/abacus-xapps", "link": true }, @@ -28,6 +23,10 @@ "resolved": "typescript/contract-metrics", "link": true }, + "node_modules/@abacus-network/core": { + "resolved": "solidity/abacus-core", + "link": true + }, "node_modules/@abacus-network/deploy": { "resolved": "typescript/abacus-deploy", "link": true @@ -40,10 +39,6 @@ "resolved": "typescript/abacus-sdk", "link": true }, - "node_modules/@abacus-network/ts-interface": { - "resolved": "typescript/typechain", - "link": true - }, "node_modules/@abacus-network/utils": { "resolved": "typescript/utils", "link": true @@ -24788,8 +24783,8 @@ } }, "solidity/abacus-core": { - "name": "@abacus-network/abacus-sol", - "version": "0.0.0", + "name": "@abacus-network/core", + "version": "0.0.1", "license": "MIT OR Apache-2.0", "dependencies": { "@abacus-network/utils": "^0.0.5", @@ -24819,11 +24814,11 @@ } }, "solidity/abacus-xapps": { - "name": "@abacus-network/abacus-xapps-sol", + "name": "@abacus-network/apps", "version": "0.0.0", "license": "MIT OR Apache-2.0", "dependencies": { - "@abacus-network/abacus-sol": "file:../abacus-core", + "@abacus-network/core": "file:../core", "@abacus-network/hardhat": "^0.0.5", "@abacus-network/utils": "^0.0.5", "@openzeppelin/contracts": "~3.4.2", @@ -24851,13 +24846,20 @@ "typescript": "^4.3.5" } }, + "solidity/abacus-xapps/node_modules/@abacus-network/core": { + "resolved": "solidity/core", + "link": true + }, + "solidity/apps": {}, + "solidity/core": {}, "typescript/abacus-deploy": { "name": "@abacus-network/deploy", "version": "0.0.5", "license": "MIT OR Apache-2.0", "dependencies": { + "@abacus-network/apps": "file:../../solidity/apps", + "@abacus-network/core": "file:../../solidity/core", "@abacus-network/sdk": "^0.0.1", - "@abacus-network/ts-interface": "^0.0.1", "@aws-sdk/client-kms": "3.48.0", "@ethersproject/experimental": "^5.3.0", "@nomiclabs/hardhat-etherscan": "^3.0.3", @@ -24885,6 +24887,14 @@ "typescript": "^4.3.2" } }, + "typescript/abacus-deploy/node_modules/@abacus-network/apps": { + "resolved": "solidity/apps", + "link": true + }, + "typescript/abacus-deploy/node_modules/@abacus-network/core": { + "resolved": "solidity/core", + "link": true + }, "typescript/abacus-deploy/node_modules/@types/node": { "version": "16.11.26", "license": "MIT" @@ -24894,7 +24904,8 @@ "version": "0.0.1", "license": "MIT OR Apache-2.0", "dependencies": { - "@abacus-network/ts-interface": "^0.0.1", + "@abacus-network/apps": "file:../../solidity/apps", + "@abacus-network/core": "file:../../solidity/core", "@ethersproject/bignumber": "^5.5.0", "@ethersproject/bytes": "^5.5.0", "celo-ethers-provider": "0.0.0", @@ -24912,47 +24923,25 @@ "typescript": "^4.4.3" } }, + "typescript/abacus-sdk/node_modules/@abacus-network/apps": { + "resolved": "solidity/apps", + "link": true + }, + "typescript/abacus-sdk/node_modules/@abacus-network/core": { + "resolved": "solidity/core", + "link": true + }, "typescript/abacus-sdk/node_modules/@types/node": { "version": "16.11.26", "dev": true, "license": "MIT" }, - "typescript/abacus-tests": { - "name": "@abacus-network/test", - "version": "0.0.0", - "extraneous": true, - "license": "MIT OR Apache-2.0", - "dependencies": { - "@abacus-network/abacus-deploy": "^0.0.5", - "@abacus-network/sdk": "^0.0.1", - "@abacus-network/ts-interface": "^0.0.1", - "@types/node": "^15.14.7", - "dotenv": "^10.0.0", - "hardhat-gas-reporter": "^1.0.7" - }, - "devDependencies": { - "@nomiclabs/hardhat-ethers": "^2.0.2", - "@nomiclabs/hardhat-waffle": "^2.0.1", - "@typechain/ethers-v5": "^7.0.0", - "@types/chai": "^4.2.18", - "@types/mocha": "^8.2.2", - "chai": "^4.3.4", - "ethereum-waffle": "^3.3.0", - "ethers": "^5.5.3", - "hardhat": "^2.8.3", - "mkdirp": "^1.0.4", - "prettier": "2.3.0", - "ts-node": "^10.0.0", - "typechain": "^5.0.0", - "typescript": "^4.3.2" - } - }, "typescript/contract-metrics": { "name": "@abacus-network/contract-metrics", "version": "0.0.0", "dependencies": { + "@abacus-network/apps": "file:../../solidity/apps", "@abacus-network/sdk": "^0.0.1", - "@abacus-network/ts-interface": "file:../typechain", "@types/bunyan": "^1.8.7", "@types/express": "^4.17.13", "@types/google-spreadsheet": "^3.1.5", @@ -24979,15 +24968,9 @@ "prettier": "^2.4.1" } }, - "typescript/contract-metrics/node_modules/@abacus-network/ts-interface": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@abacus-network/ts-interface/-/ts-interface-1.1.2.tgz", - "integrity": "sha512-ovlzCqBQTU5lGKxJ1iUO3UF0MEds8TkR9fO7DcweWq+mQQoBWU/l8CwnilFimZL5FG2joEMvRgky4iDMK2z9ww==", - "dependencies": { - "@ethersproject/experimental": "^5.5.0", - "@types/node": "^16.11.21", - "typescript": "^4.5.5" - } + "typescript/contract-metrics/node_modules/@abacus-network/apps": { + "resolved": "solidity/apps", + "link": true }, "typescript/contract-metrics/node_modules/@types/node": { "version": "16.11.26", @@ -24998,7 +24981,7 @@ "version": "0.0.5", "license": "MIT OR Apache-2.0", "dependencies": { - "@abacus-network/abacus-sol": "^0.0.0", + "@abacus-network/core": "file:../../solidity/core", "@abacus-network/utils": "^0.0.5", "@nomiclabs/hardhat-ethers": "^2.0.5", "@nomiclabs/hardhat-waffle": "^2.0.2", @@ -25012,22 +24995,9 @@ "typescript": "^4.3.2" } }, - "typescript/typechain": { - "name": "@abacus-network/ts-interface", - "version": "0.0.1", - "license": "MIT OR Apache-2.0", - "dependencies": { - "@ethersproject/experimental": "^5.5.0", - "@types/node": "^16.11.21", - "typescript": "^4.5.5" - }, - "devDependencies": { - "ethers": "^5.5.3" - } - }, - "typescript/typechain/node_modules/@types/node": { - "version": "16.11.26", - "license": "MIT" + "typescript/hardhat/node_modules/@abacus-network/core": { + "resolved": "solidity/core", + "link": true }, "typescript/utils": { "name": "@abacus-network/utils", @@ -25040,37 +25010,10 @@ } }, "dependencies": { - "@abacus-network/abacus-sol": { - "version": "file:solidity/abacus-core", - "requires": { - "@abacus-network/utils": "^0.0.5", - "@nomiclabs/hardhat-ethers": "^2.0.1", - "@nomiclabs/hardhat-waffle": "^2.0.1", - "@openzeppelin/contracts": "^3.4.2", - "@openzeppelin/contracts-upgradeable": "~3.4.2", - "@summa-tx/memview-sol": "^2.0.0", - "@typechain/ethers-v5": "~7.0.0", - "@typechain/hardhat": "^2.0.1", - "chai": "^4.3.0", - "eslint": "^7.20.0", - "ethereum-waffle": "^3.2.2", - "ethers": "^5.4.4", - "hardhat": "^2.8.3", - "hardhat-gas-reporter": "^1.0.7", - "prettier": "^2.2.1", - "prettier-plugin-solidity": "^1.0.0-beta.5", - "solhint": "^3.3.2", - "solhint-plugin-prettier": "^0.0.5", - "solidity-coverage": "^0.7.14", - "ts-generator": "^0.1.1", - "ts-node": "^10.1.0", - "typechain": "^5.0.0" - } - }, - "@abacus-network/abacus-xapps-sol": { + "@abacus-network/apps": { "version": "file:solidity/abacus-xapps", "requires": { - "@abacus-network/abacus-sol": "file:../abacus-core", + "@abacus-network/core": "file:../core", "@abacus-network/hardhat": "^0.0.5", "@abacus-network/utils": "^0.0.5", "@nomiclabs/hardhat-ethers": "^2.0.1", @@ -25094,13 +25037,18 @@ "ts-node": "^10.1.0", "typechain": "^5.0.0", "typescript": "^4.3.5" + }, + "dependencies": { + "@abacus-network/core": { + "version": "file:solidity/core" + } } }, "@abacus-network/contract-metrics": { "version": "file:typescript/contract-metrics", "requires": { + "@abacus-network/apps": "file:../../solidity/apps", "@abacus-network/sdk": "^0.0.1", - "@abacus-network/ts-interface": "file:../typechain", "@types/bunyan": "^1.8.7", "@types/express": "^4.17.13", "@types/google-spreadsheet": "^3.1.5", @@ -25125,25 +25073,47 @@ "typescript": "^4.4.3" }, "dependencies": { - "@abacus-network/ts-interface": { - "version": "https://registry.npmjs.org/@abacus-network/ts-interface/-/ts-interface-1.1.2.tgz", - "integrity": "sha512-ovlzCqBQTU5lGKxJ1iUO3UF0MEds8TkR9fO7DcweWq+mQQoBWU/l8CwnilFimZL5FG2joEMvRgky4iDMK2z9ww==", - "requires": { - "@ethersproject/experimental": "^5.5.0", - "@types/node": "^16.11.21", - "typescript": "^4.5.5" - } + "@abacus-network/apps": { + "version": "file:solidity/apps" }, "@types/node": { "version": "16.11.26" } } }, + "@abacus-network/core": { + "version": "file:solidity/abacus-core", + "requires": { + "@abacus-network/utils": "^0.0.5", + "@nomiclabs/hardhat-ethers": "^2.0.1", + "@nomiclabs/hardhat-waffle": "^2.0.1", + "@openzeppelin/contracts": "^3.4.2", + "@openzeppelin/contracts-upgradeable": "~3.4.2", + "@summa-tx/memview-sol": "^2.0.0", + "@typechain/ethers-v5": "~7.0.0", + "@typechain/hardhat": "^2.0.1", + "chai": "^4.3.0", + "eslint": "^7.20.0", + "ethereum-waffle": "^3.2.2", + "ethers": "^5.4.4", + "hardhat": "^2.8.3", + "hardhat-gas-reporter": "^1.0.7", + "prettier": "^2.2.1", + "prettier-plugin-solidity": "^1.0.0-beta.5", + "solhint": "^3.3.2", + "solhint-plugin-prettier": "^0.0.5", + "solidity-coverage": "^0.7.14", + "ts-generator": "^0.1.1", + "ts-node": "^10.1.0", + "typechain": "^5.0.0" + } + }, "@abacus-network/deploy": { "version": "file:typescript/abacus-deploy", "requires": { + "@abacus-network/apps": "file:../../solidity/apps", + "@abacus-network/core": "file:../../solidity/core", "@abacus-network/sdk": "^0.0.1", - "@abacus-network/ts-interface": "^0.0.1", "@aws-sdk/client-kms": "3.48.0", "@ethersproject/experimental": "^5.3.0", "@nomiclabs/hardhat-ethers": "^2.0.5", @@ -25169,6 +25139,12 @@ "yargs": "^17.3.1" }, "dependencies": { + "@abacus-network/apps": { + "version": "file:solidity/apps" + }, + "@abacus-network/core": { + "version": "file:solidity/core" + }, "@types/node": { "version": "16.11.26" } @@ -25177,7 +25153,7 @@ "@abacus-network/hardhat": { "version": "file:typescript/hardhat", "requires": { - "@abacus-network/abacus-sol": "^0.0.0", + "@abacus-network/core": "file:../../solidity/core", "@abacus-network/utils": "^0.0.5", "@nomiclabs/hardhat-ethers": "^2.0.5", "@nomiclabs/hardhat-waffle": "^2.0.2", @@ -25189,12 +25165,18 @@ "ts-node": "^10.1.0", "typechain": "^5.0.0", "typescript": "^4.3.2" + }, + "dependencies": { + "@abacus-network/core": { + "version": "file:solidity/core" + } } }, "@abacus-network/sdk": { "version": "file:typescript/abacus-sdk", "requires": { - "@abacus-network/ts-interface": "^0.0.1", + "@abacus-network/apps": "file:../../solidity/apps", + "@abacus-network/core": "file:../../solidity/core", "@ethersproject/bignumber": "^5.5.0", "@ethersproject/bytes": "^5.5.0", "@types/node": "^16.9.1", @@ -25210,26 +25192,18 @@ "typescript": "^4.4.3" }, "dependencies": { + "@abacus-network/apps": { + "version": "file:solidity/apps" + }, + "@abacus-network/core": { + "version": "file:solidity/core" + }, "@types/node": { "version": "16.11.26", "dev": true } } }, - "@abacus-network/ts-interface": { - "version": "file:typescript/typechain", - "requires": { - "@ethersproject/experimental": "^5.5.0", - "@types/node": "^16.11.21", - "ethers": "^5.5.3", - "typescript": "^4.5.5" - }, - "dependencies": { - "@types/node": { - "version": "16.11.26" - } - } - }, "@abacus-network/utils": { "version": "file:typescript/utils", "requires": { diff --git a/package.json b/package.json index 3df3c19b9..4d1ce9780 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "solidity/abacus-core", "typescript/hardhat", "solidity/abacus-xapps", - "typescript/typechain", "typescript/abacus-sdk", "typescript/contract-metrics", "typescript/abacus-deploy" diff --git a/solidity/abacus-core/.gitignore b/solidity/abacus-core/.gitignore index eba1c61fd..1dddebd13 100644 --- a/solidity/abacus-core/.gitignore +++ b/solidity/abacus-core/.gitignore @@ -1,7 +1,8 @@ node_modules/ cache/ artifacts/ -typechain/ +types/ +dist/ coverage/ coverage.json .env diff --git a/solidity/abacus-core/hardhat.config.ts b/solidity/abacus-core/hardhat.config.ts index 14b0fd7a0..364b10405 100644 --- a/solidity/abacus-core/hardhat.config.ts +++ b/solidity/abacus-core/hardhat.config.ts @@ -20,7 +20,7 @@ module.exports = { currency: "USD", }, typechain: { - outDir: "./typechain", + outDir: "./types", target: "ethers-v5", alwaysGenerateOverloads: false, // should overloads with full signatures like deposit(uint256) be generated always, even if there are no overloads? }, diff --git a/solidity/abacus-core/package.json b/solidity/abacus-core/package.json index 06758e084..f617a4985 100644 --- a/solidity/abacus-core/package.json +++ b/solidity/abacus-core/package.json @@ -1,5 +1,5 @@ { - "name": "@abacus-network/abacus-sol", + "name": "@abacus-network/core", "devDependencies": { "@nomiclabs/hardhat-ethers": "^2.0.1", "@nomiclabs/hardhat-waffle": "^2.0.1", @@ -19,20 +19,19 @@ "ts-node": "^10.1.0", "typechain": "^5.0.0" }, - "version": "0.0.0", - "description": "Abacus Interchain Communications", - "main": " ", + "version": "0.0.1", + "main": "dist/index.js", + "types": "dist/index.d.ts", "directories": { "test": "test" }, "scripts": { "prettier": "prettier --write ./contracts ./libs ./test", - "build": "hardhat compile && hardhat typechain && npm run prettier && npm run copy-typechain", - "copy-typechain": "mkdir -p ../../typescript/typechain/abacus-core/ && cp -r typechain/* ../../typescript/typechain/abacus-core/", + "build": "hardhat compile && hardhat typechain && npm run prettier && tsc && npm run copy-types", + "copy-types": "cp types/*.d.ts dist/", "test": "hardhat test", "coverage": "hardhat coverage" }, - "author": "James Prestwich", "license": "MIT OR Apache-2.0", "dependencies": { "@abacus-network/utils": "^0.0.5", diff --git a/solidity/abacus-core/test/common.test.ts b/solidity/abacus-core/test/common.test.ts index 70694f161..6fce58681 100644 --- a/solidity/abacus-core/test/common.test.ts +++ b/solidity/abacus-core/test/common.test.ts @@ -2,7 +2,7 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { ethers } from 'hardhat'; import { expect } from 'chai'; -import { TestCommon__factory, TestCommon } from '../typechain'; +import { TestCommon__factory, TestCommon } from '../types'; const localDomain = 1000; const ONLY_OWNER_REVERT_MSG = 'Ownable: caller is not the owner'; diff --git a/solidity/abacus-core/test/inbox.test.ts b/solidity/abacus-core/test/inbox.test.ts index 9886f8b4b..b9aa875c4 100644 --- a/solidity/abacus-core/test/inbox.test.ts +++ b/solidity/abacus-core/test/inbox.test.ts @@ -16,9 +16,8 @@ import { ValidatorManager, ValidatorManager__factory, TestRecipient__factory, -} from '../typechain'; +} from '../types'; -const outboxDomainHashTestCases = require('../../../vectors/outboxDomainHash.json'); const merkleTestCases = require('../../../vectors/merkle.json'); const proveAndProcessTestCases = require('../../../vectors/proveAndProcess.json'); diff --git a/solidity/abacus-core/test/lib/AbacusDeployment.ts b/solidity/abacus-core/test/lib/AbacusDeployment.ts index a6f51caeb..557154ede 100644 --- a/solidity/abacus-core/test/lib/AbacusDeployment.ts +++ b/solidity/abacus-core/test/lib/AbacusDeployment.ts @@ -1,4 +1,3 @@ -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { assert } from 'chai'; import * as ethers from 'ethers'; import { types } from '@abacus-network/utils'; @@ -16,7 +15,7 @@ import { XAppConnectionManager__factory, TestInbox, TestInbox__factory, -} from '../../typechain'; +} from '../../types'; export interface AbacusInstance { domain: types.Domain; diff --git a/solidity/abacus-core/test/lib/upgrade.ts b/solidity/abacus-core/test/lib/upgrade.ts index 7de7b9191..c816ad52b 100644 --- a/solidity/abacus-core/test/lib/upgrade.ts +++ b/solidity/abacus-core/test/lib/upgrade.ts @@ -1,6 +1,5 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { expect } from 'chai'; -import ethers from 'ethers'; import { MysteryMathV1, @@ -10,7 +9,7 @@ import { UpgradeBeacon, UpgradeBeacon__factory, UpgradeBeaconProxy__factory, -} from '../../typechain'; +} from '../../types'; export type MysteryMathUpgrade = { proxy: MysteryMathV1 | MysteryMathV2; diff --git a/solidity/abacus-core/test/merkle.test.ts b/solidity/abacus-core/test/merkle.test.ts index 259775fa1..b8092406c 100644 --- a/solidity/abacus-core/test/merkle.test.ts +++ b/solidity/abacus-core/test/merkle.test.ts @@ -2,7 +2,7 @@ import { ethers } from 'hardhat'; import { expect } from 'chai'; import { types } from '@abacus-network/utils'; -import { TestMerkle, TestMerkle__factory } from '../typechain'; +import { TestMerkle, TestMerkle__factory } from '../types'; const merkleTestCases = require('../../../vectors/merkle.json'); diff --git a/solidity/abacus-core/test/message.test.ts b/solidity/abacus-core/test/message.test.ts index 8cb257406..4c3e94917 100644 --- a/solidity/abacus-core/test/message.test.ts +++ b/solidity/abacus-core/test/message.test.ts @@ -1,7 +1,7 @@ import { ethers } from 'hardhat'; import { expect } from 'chai'; import { utils } from '@abacus-network/utils'; -import { TestMessage, TestMessage__factory } from '../typechain'; +import { TestMessage, TestMessage__factory } from '../types'; const testCases = require('../../../vectors/message.json'); diff --git a/solidity/abacus-core/test/outbox.test.ts b/solidity/abacus-core/test/outbox.test.ts index 1c75624bb..d6c318569 100644 --- a/solidity/abacus-core/test/outbox.test.ts +++ b/solidity/abacus-core/test/outbox.test.ts @@ -2,9 +2,8 @@ import { ethers } from 'hardhat'; import { expect } from 'chai'; import { types, utils } from '@abacus-network/utils'; import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; -import { Validator } from './lib/core'; -import { TestOutbox, TestOutbox__factory } from '../typechain'; +import { TestOutbox, TestOutbox__factory } from '../types'; const destinationNonceTestCases = require('../../../vectors/destinationNonce.json'); diff --git a/solidity/abacus-core/test/upgrade.test.ts b/solidity/abacus-core/test/upgrade.test.ts index 7afaa1fc8..19db251d3 100644 --- a/solidity/abacus-core/test/upgrade.test.ts +++ b/solidity/abacus-core/test/upgrade.test.ts @@ -6,7 +6,7 @@ import { UpgradeBeaconController__factory, UpgradeBeaconController, MysteryMathV2__factory, -} from '../typechain'; +} from '../types'; describe('Upgrade', async () => { const utils = new UpgradeTestHelpers(); diff --git a/solidity/abacus-core/test/validatorManager.test.ts b/solidity/abacus-core/test/validatorManager.test.ts index 91f338313..ba0cf331b 100644 --- a/solidity/abacus-core/test/validatorManager.test.ts +++ b/solidity/abacus-core/test/validatorManager.test.ts @@ -10,7 +10,7 @@ import { Outbox, ValidatorManager__factory, ValidatorManager, -} from '../typechain'; +} from '../types'; const outboxDomainHashCases = require('../../../vectors/outboxDomainHash.json'); const localDomain = 1000; diff --git a/solidity/abacus-core/test/xAppConnectionManager.test.ts b/solidity/abacus-core/test/xAppConnectionManager.test.ts index 1e82ee838..3eac1234b 100644 --- a/solidity/abacus-core/test/xAppConnectionManager.test.ts +++ b/solidity/abacus-core/test/xAppConnectionManager.test.ts @@ -8,10 +8,7 @@ import { XAppConnectionManager, XAppConnectionManager__factory, TestInbox, -} from '../typechain'; -import { Validator } from './lib/core'; - -const signedFailureTestCases = require('../../../vectors/signedFailure.json'); +} from '../types'; const ONLY_OWNER_REVERT_MSG = 'Ownable: caller is not the owner'; const localDomain = 1000; @@ -22,12 +19,10 @@ const reserveGas = 15000; describe('XAppConnectionManager', async () => { let connectionManager: XAppConnectionManager, enrolledInbox: TestInbox, - signer: SignerWithAddress, - validator: Validator; + signer: SignerWithAddress; before(async () => { [signer] = await ethers.getSigners(); - validator = await Validator.fromSigner(signer, localDomain); }); beforeEach(async () => { diff --git a/solidity/abacus-core/tsconfig.json b/solidity/abacus-core/tsconfig.json index 7cebd665e..724b6bd93 100644 --- a/solidity/abacus-core/tsconfig.json +++ b/solidity/abacus-core/tsconfig.json @@ -1,73 +1,16 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "ES2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */, - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, - // "lib": [], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - "resolveJsonModule": true /* Allows for importing, extracting types from and generating . json files.*/, - - /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - - /* Advanced Options */ - "skipLibCheck": true /* Skip type checking of declaration files. */, - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - } + "outDir": "./dist/", + "rootDir": "./types/" + }, + "exclude": [ + "./node_modules/", + "./dist/", + "./types/hardhat.d.ts" + ], + "extends": "../../tsconfig.package.json", + "include": [ + "./types/*.ts", + "./types/factories/*.ts" + ] } diff --git a/solidity/abacus-xapps/.gitignore b/solidity/abacus-xapps/.gitignore index eba1c61fd..1dddebd13 100644 --- a/solidity/abacus-xapps/.gitignore +++ b/solidity/abacus-xapps/.gitignore @@ -1,7 +1,8 @@ node_modules/ cache/ artifacts/ -typechain/ +types/ +dist/ coverage/ coverage.json .env diff --git a/solidity/abacus-xapps/contracts/bridge/BridgeRouter.sol b/solidity/abacus-xapps/contracts/bridge/BridgeRouter.sol index 5e6b4196f..df9ea529e 100644 --- a/solidity/abacus-xapps/contracts/bridge/BridgeRouter.sol +++ b/solidity/abacus-xapps/contracts/bridge/BridgeRouter.sol @@ -6,11 +6,11 @@ import {TokenRegistry} from "./TokenRegistry.sol"; import {BridgeMessage} from "./BridgeMessage.sol"; import {IBridgeToken} from "../../interfaces/bridge/IBridgeToken.sol"; // ============ External Imports ============ -import {Router} from "@abacus-network/abacus-sol/contracts/router/Router.sol"; -import {XAppConnectionClient} from "@abacus-network/abacus-sol/contracts/router/XAppConnectionClient.sol"; -import {Outbox} from "@abacus-network/abacus-sol/contracts/Outbox.sol"; -import {Version0} from "@abacus-network/abacus-sol/contracts/Version0.sol"; -import {TypeCasts} from "@abacus-network/abacus-sol/contracts/XAppConnectionManager.sol"; +import {Router} from "@abacus-network/core/contracts/router/Router.sol"; +import {XAppConnectionClient} from "@abacus-network/core/contracts/router/XAppConnectionClient.sol"; +import {Outbox} from "@abacus-network/core/contracts/Outbox.sol"; +import {Version0} from "@abacus-network/core/contracts/Version0.sol"; +import {TypeCasts} from "@abacus-network/core/contracts/XAppConnectionManager.sol"; import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; diff --git a/solidity/abacus-xapps/contracts/bridge/BridgeToken.sol b/solidity/abacus-xapps/contracts/bridge/BridgeToken.sol index 013bd5c85..055588d3f 100644 --- a/solidity/abacus-xapps/contracts/bridge/BridgeToken.sol +++ b/solidity/abacus-xapps/contracts/bridge/BridgeToken.sol @@ -5,8 +5,8 @@ pragma solidity >=0.6.11; import {IBridgeToken} from "../../interfaces/bridge/IBridgeToken.sol"; import {ERC20} from "./vendored/OZERC20.sol"; // ============ External Imports ============ -import {Version0} from "@abacus-network/abacus-sol/contracts/Version0.sol"; -import {TypeCasts} from "@abacus-network/abacus-sol/contracts/XAppConnectionManager.sol"; +import {Version0} from "@abacus-network/core/contracts/Version0.sol"; +import {TypeCasts} from "@abacus-network/core/contracts/XAppConnectionManager.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract BridgeToken is Version0, IBridgeToken, OwnableUpgradeable, ERC20 { diff --git a/solidity/abacus-xapps/contracts/bridge/ETHHelper.sol b/solidity/abacus-xapps/contracts/bridge/ETHHelper.sol index 0b6671a01..4229af104 100644 --- a/solidity/abacus-xapps/contracts/bridge/ETHHelper.sol +++ b/solidity/abacus-xapps/contracts/bridge/ETHHelper.sol @@ -5,7 +5,7 @@ pragma solidity >=0.6.11; import {BridgeRouter} from "./BridgeRouter.sol"; import {IWeth} from "../../interfaces/bridge/IWeth.sol"; // ============ External Imports ============ -import {TypeCasts} from "@abacus-network/abacus-sol/contracts/XAppConnectionManager.sol"; +import {TypeCasts} from "@abacus-network/core/contracts/XAppConnectionManager.sol"; contract ETHHelper { // ============ Immutables ============ diff --git a/solidity/abacus-xapps/contracts/bridge/TokenRegistry.sol b/solidity/abacus-xapps/contracts/bridge/TokenRegistry.sol index a02908ac8..c0a585b56 100644 --- a/solidity/abacus-xapps/contracts/bridge/TokenRegistry.sol +++ b/solidity/abacus-xapps/contracts/bridge/TokenRegistry.sol @@ -6,9 +6,9 @@ import {BridgeMessage} from "./BridgeMessage.sol"; import {Encoding} from "./Encoding.sol"; import {IBridgeToken} from "../../interfaces/bridge/IBridgeToken.sol"; // ============ External Imports ============ -import {XAppConnectionClient} from "@abacus-network/abacus-sol/contracts/router/XAppConnectionClient.sol"; -import {TypeCasts} from "@abacus-network/abacus-sol/contracts/XAppConnectionManager.sol"; -import {UpgradeBeaconProxy} from "@abacus-network/abacus-sol/contracts/upgrade/UpgradeBeaconProxy.sol"; +import {XAppConnectionClient} from "@abacus-network/core/contracts/router/XAppConnectionClient.sol"; +import {TypeCasts} from "@abacus-network/core/contracts/XAppConnectionManager.sol"; +import {UpgradeBeaconProxy} from "@abacus-network/core/contracts/upgrade/UpgradeBeaconProxy.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; diff --git a/solidity/abacus-xapps/contracts/governance/GovernanceRouter.sol b/solidity/abacus-xapps/contracts/governance/GovernanceRouter.sol index c4b470d1f..a91aa17df 100644 --- a/solidity/abacus-xapps/contracts/governance/GovernanceRouter.sol +++ b/solidity/abacus-xapps/contracts/governance/GovernanceRouter.sol @@ -5,9 +5,9 @@ pragma experimental ABIEncoderV2; // ============ Internal Imports ============ import {GovernanceMessage} from "./GovernanceMessage.sol"; // ============ External Imports ============ -import {Version0} from "@abacus-network/abacus-sol/contracts/Version0.sol"; -import {Router} from "@abacus-network/abacus-sol/contracts/router/Router.sol"; -import {TypeCasts} from "@abacus-network/abacus-sol/contracts/XAppConnectionManager.sol"; +import {Version0} from "@abacus-network/core/contracts/Version0.sol"; +import {Router} from "@abacus-network/core/contracts/router/Router.sol"; +import {TypeCasts} from "@abacus-network/core/contracts/XAppConnectionManager.sol"; import {Initializable} from "@openzeppelin/contracts/proxy/Initializable.sol"; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol"; diff --git a/solidity/abacus-xapps/contracts/ping-pong/PingPongRouter.sol b/solidity/abacus-xapps/contracts/ping-pong/PingPongRouter.sol index da0eb4e80..1da3f5e2a 100644 --- a/solidity/abacus-xapps/contracts/ping-pong/PingPongRouter.sol +++ b/solidity/abacus-xapps/contracts/ping-pong/PingPongRouter.sol @@ -3,8 +3,8 @@ pragma solidity >=0.6.11; // ============ External Imports ============ import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol"; -import {Router} from "@abacus-network/abacus-sol/contracts/router/Router.sol"; -import {XAppConnectionClient} from "@abacus-network/abacus-sol/contracts/router/XAppConnectionClient.sol"; +import {Router} from "@abacus-network/core/contracts/router/Router.sol"; +import {XAppConnectionClient} from "@abacus-network/core/contracts/router/XAppConnectionClient.sol"; // ============ Internal Imports ============ import {PingPongMessage} from "./PingPongMessage.sol"; diff --git a/solidity/abacus-xapps/contracts/xapp-template/RouterTemplate.sol b/solidity/abacus-xapps/contracts/xapp-template/RouterTemplate.sol index f184e4815..f0eb74df1 100644 --- a/solidity/abacus-xapps/contracts/xapp-template/RouterTemplate.sol +++ b/solidity/abacus-xapps/contracts/xapp-template/RouterTemplate.sol @@ -3,8 +3,8 @@ pragma solidity >=0.6.11; // ============ External Imports ============ import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol"; -import {Router} from "@abacus-network/abacus-sol/contracts/router/Router.sol"; -import {XAppConnectionClient} from "@abacus-network/abacus-sol/contracts/router/XAppConnectionClient.sol"; +import {Router} from "@abacus-network/core/contracts/router/Router.sol"; +import {XAppConnectionClient} from "@abacus-network/core/contracts/router/XAppConnectionClient.sol"; // ============ Internal Imports ============ import {Message} from "./MessageTemplate.sol"; diff --git a/solidity/abacus-xapps/hardhat.config.ts b/solidity/abacus-xapps/hardhat.config.ts index 560ffbd6f..4e4a112c3 100644 --- a/solidity/abacus-xapps/hardhat.config.ts +++ b/solidity/abacus-xapps/hardhat.config.ts @@ -21,7 +21,7 @@ module.exports = { currency: 'USD', }, typechain: { - outDir: './typechain', + outDir: './types', target: 'ethers-v5', alwaysGenerateOverloads: false, // should overloads with full signatures like deposit(uint256) be generated always, even if there are no overloads? }, diff --git a/solidity/abacus-xapps/package.json b/solidity/abacus-xapps/package.json index 320ab6212..f6a37724d 100644 --- a/solidity/abacus-xapps/package.json +++ b/solidity/abacus-xapps/package.json @@ -1,5 +1,5 @@ { - "name": "@abacus-network/abacus-xapps-sol", + "name": "@abacus-network/apps", "devDependencies": { "@nomiclabs/hardhat-ethers": "^2.0.1", "@nomiclabs/hardhat-waffle": "^2.0.1", @@ -21,22 +21,21 @@ "typescript": "^4.3.5" }, "version": "0.0.0", - "description": "A bridge using abacus", - "main": " ", + "main": "dist/index.js", + "types": "dist/index.d.ts", "directories": { "test": "test" }, "scripts": { "prettier": "prettier --write ./contracts ./test", - "build": "hardhat compile && hardhat typechain && npm run prettier && npm run copy-typechain", - "copy-typechain": "mkdir -p ../../typescript/typechain/abacus-xapps/ && cp -r typechain/* ../../typescript/typechain/abacus-xapps/", + "build": "hardhat compile && hardhat typechain && npm run prettier && tsc && npm run copy-types", + "copy-types": "cp types/*.d.ts dist/", "coverage": "hardhat coverage", "test": "hardhat test" }, - "author": "James Prestwich", "license": "MIT OR Apache-2.0", "dependencies": { - "@abacus-network/abacus-sol": "file:../abacus-core", + "@abacus-network/core": "file:../core", "@abacus-network/hardhat": "^0.0.5", "@abacus-network/utils": "^0.0.5", "@openzeppelin/contracts": "~3.4.2", diff --git a/solidity/abacus-xapps/recoveryManager.test.ts b/solidity/abacus-xapps/recoveryManager.test.ts deleted file mode 100644 index b72c71a9b..000000000 --- a/solidity/abacus-xapps/recoveryManager.test.ts +++ /dev/null @@ -1,484 +0,0 @@ -import { ethers, abacus } from 'hardhat'; -import { expect } from 'chai'; -import * as types from 'ethers'; - -import { formatCall, sendFromSigner } from './utils'; -import { increaseTimestampBy } from '../utils'; -import { Validator } from '../lib/core'; -import { Signer } from '../lib/types'; -import { - ValidatorManager, - TestGovernanceRouter, - TestOutbox, -} from '../../typechain'; -import { AbacusDeployment } from '../lib/AbacusDeployment'; -import { GovernanceDeployment } from '../lib/GovernanceDeployment'; - -async function expectNotInRecovery( - validatorManager: ValidatorManager, - recoveryManager: types.Signer, - randomSigner: Signer, - governor: Signer, - governanceRouter: TestGovernanceRouter, - outbox: TestOutbox, -) { - expect(await governanceRouter.inRecovery()).to.be.false; - - // Format abacus call message - const call = await formatCall(validatorManager, 'setValidator', [ - 1000, - randomSigner.address, - ]); - - // Expect that Governor *CAN* Call Local & Call Remote - // dispatch call on local governorRouter - await expect( - sendFromSigner(governor, governanceRouter, 'callLocal', [[call]]), - ) - .to.emit(validatorManager, 'NewValidator') - .withArgs(1000, randomSigner.address); - - // dispatch call on local governorRouter - await expect( - sendFromSigner(governor, governanceRouter, 'callRemote', [2000, [call]]), - ).to.emit(outbox, 'Dispatch'); - - // set xApp Connection Manager - const xAppConnectionManager = await governanceRouter.xAppConnectionManager(); - await expect( - sendFromSigner(governor, governanceRouter, 'setXAppConnectionManager', [ - randomSigner.address, - ]), - ).to.not.be.reverted; - // reset xApp Connection Manager to actual contract - await sendFromSigner(governor, governanceRouter, 'setXAppConnectionManager', [ - xAppConnectionManager, - ]); - - // set Router Locally - const otherDomain = 2000; - const previousRouter = await governanceRouter.routers(otherDomain); - await expect( - sendFromSigner(governor, governanceRouter, 'setRouterLocal', [ - 2000, - abacus.ethersAddressToBytes32(randomSigner.address), - ]), - ) - .to.emit(governanceRouter, 'SetRouter') - .withArgs( - otherDomain, - previousRouter, - abacus.ethersAddressToBytes32(randomSigner.address), - ); - - // Expect that Recovery Manager CANNOT Call Local OR Call Remote - // cannot dispatch call on local governorRouter - await expect( - sendFromSigner(recoveryManager, governanceRouter, 'callLocal', [[call]]), - ).to.be.revertedWith('! called by governor'); - - // cannot dispatch call to remote governorRouter - await expect( - sendFromSigner(recoveryManager, governanceRouter, 'callRemote', [ - 2000, - [call], - ]), - ).to.be.revertedWith('! called by governor'); - - // cannot set xAppConnectionManager - await expect( - sendFromSigner( - recoveryManager, - governanceRouter, - 'setXAppConnectionManager', - [randomSigner.address], - ), - ).to.be.revertedWith('! called by governor'); - - // cannot set Router - await expect( - sendFromSigner(recoveryManager, governanceRouter, 'setRouterLocal', [ - 2000, - abacus.ethersAddressToBytes32(randomSigner.address), - ]), - ).to.be.revertedWith('! called by governor'); -} - -async function expectOnlyRecoveryManagerCanTransferRole( - governor: Signer, - governanceRouter: TestGovernanceRouter, - randomSigner: Signer, - recoveryManager: Signer, -) { - await expect( - sendFromSigner(governor, governanceRouter, 'transferRecoveryManager', [ - randomSigner.address, - ]), - ).to.be.revertedWith('! called by recovery manager'); - - await expect( - sendFromSigner(randomSigner, governanceRouter, 'transferRecoveryManager', [ - randomSigner.address, - ]), - ).to.be.revertedWith('! called by recovery manager'); - - await expect( - sendFromSigner( - recoveryManager, - governanceRouter, - 'transferRecoveryManager', - [randomSigner.address], - ), - ) - .to.emit(governanceRouter, 'TransferRecoveryManager') - .withArgs(recoveryManager.address, randomSigner.address); - - await expect( - sendFromSigner(randomSigner, governanceRouter, 'transferRecoveryManager', [ - recoveryManager.address, - ]), - ) - .to.emit(governanceRouter, 'TransferRecoveryManager') - .withArgs(randomSigner.address, recoveryManager.address); -} - -async function expectOnlyRecoveryManagerCanExitRecovery( - governor: Signer, - governanceRouter: TestGovernanceRouter, - randomSigner: Signer, - recoveryManager: Signer, -) { - await expect( - sendFromSigner(governor, governanceRouter, 'exitRecovery', []), - ).to.be.revertedWith('! called by recovery manager'); - - await expect( - sendFromSigner(randomSigner, governanceRouter, 'exitRecovery', []), - ).to.be.revertedWith('! called by recovery manager'); - - await expect( - sendFromSigner(recoveryManager, governanceRouter, 'exitRecovery', []), - ) - .to.emit(governanceRouter, 'ExitRecovery') - .withArgs(recoveryManager.address); -} - -async function expectOnlyRecoveryManagerCanInitiateRecovery( - governor: Signer, - governanceRouter: TestGovernanceRouter, - randomSigner: Signer, - recoveryManager: Signer, -) { - await expect( - sendFromSigner(governor, governanceRouter, 'initiateRecoveryTimelock', []), - ).to.be.revertedWith('! called by recovery manager'); - - await expect( - sendFromSigner( - randomSigner, - governanceRouter, - 'initiateRecoveryTimelock', - [], - ), - ).to.be.revertedWith('! called by recovery manager'); - - expect(await governanceRouter.recoveryActiveAt()).to.equal(0); - - await expect( - sendFromSigner( - recoveryManager, - governanceRouter, - 'initiateRecoveryTimelock', - [], - ), - ).to.emit(governanceRouter, 'InitiateRecovery'); - - expect(await governanceRouter.recoveryActiveAt()).to.not.equal(0); -} - -const localDomain = 1000; -const remoteDomain = 2000; -const domains = [localDomain, remoteDomain]; - -/* - * Deploy the full Abacus suite on two chains - */ -describe('RecoveryManager', async () => { - let abacusDeployment: AbacusDeployment; - let governanceDeployment: GovernanceDeployment; - let governor: Signer, - recoveryManager: Signer, - randomSigner: Signer, - governanceRouter: TestGovernanceRouter, - outbox: TestOutbox, - validatorManager: ValidatorManager; - - before(async () => { - [governor, recoveryManager, randomSigner] = await ethers.getSigners(); - const validator = await Validator.fromSigner(randomSigner, localDomain); - abacusDeployment = await AbacusDeployment.fromDomains( - domains, - randomSigner, - ); - governanceDeployment = await GovernanceDeployment.fromAbacusDeployment( - abacusDeployment, - recoveryManager, - ); - for (const domain of domains) { - await abacusDeployment.transferOwnership( - domain, - governanceDeployment.router(domain).address, - ); - } - - governanceRouter = governanceDeployment.router(localDomain); - outbox = abacusDeployment.outbox(localDomain); - validatorManager = abacusDeployment.validatorManager(localDomain); - - // set governor - await governanceRouter.transferGovernor(localDomain, governor.address); - }); - - it('Before Recovery Initiated: Timelock has not been set', async () => { - expect(await governanceRouter.recoveryActiveAt()).to.equal(0); - }); - - it('Before Recovery Initiated: Cannot Exit Recovery yet', async () => { - await expect( - sendFromSigner(recoveryManager, governanceRouter, 'exitRecovery', []), - ).to.be.revertedWith('recovery not initiated'); - }); - - it('Before Recovery Initiated: Not in Recovery (Governor CAN Call Local & Remote; Recovery Manager CANNOT Call either)', async () => { - await expectNotInRecovery( - validatorManager, - recoveryManager, - randomSigner, - governor, - governanceRouter, - outbox, - ); - }); - - it('Before Recovery Initiated: ONLY RecoveryManager can transfer RecoveryManager role', async () => { - await expectOnlyRecoveryManagerCanTransferRole( - governor, - governanceRouter, - randomSigner, - recoveryManager, - ); - }); - - it('Before Recovery Initiated: ONLY RecoveryManager can Initiate Recovery', async () => { - await expectOnlyRecoveryManagerCanInitiateRecovery( - governor, - governanceRouter, - randomSigner, - recoveryManager, - ); - }); - - it('Before Recovery Active: CANNOT Initiate Recovery Twice', async () => { - await expect( - sendFromSigner( - recoveryManager, - governanceRouter, - 'initiateRecoveryTimelock', - [], - ), - ).to.be.revertedWith('recovery already initiated'); - }); - - it('Before Recovery Active: Not in Recovery (Governor CAN Call Local & Remote; Recovery Manager CANNOT Call either)', async () => { - await expectNotInRecovery( - validatorManager, - recoveryManager, - randomSigner, - governor, - governanceRouter, - outbox, - ); - }); - - it('Before Recovery Active: ONLY RecoveryManager can transfer RecoveryManager role', async () => { - await expectOnlyRecoveryManagerCanTransferRole( - governor, - governanceRouter, - randomSigner, - recoveryManager, - ); - }); - - it('Before Recovery Active: ONLY RecoveryManager can Exit Recovery', async () => { - await expectOnlyRecoveryManagerCanExitRecovery( - governor, - governanceRouter, - randomSigner, - recoveryManager, - ); - }); - - it('Before Recovery Active: ONLY RecoveryManager can Initiate Recovery (CAN initiate a second time)', async () => { - await expectOnlyRecoveryManagerCanInitiateRecovery( - governor, - governanceRouter, - randomSigner, - recoveryManager, - ); - }); - - it('Recovery Active: inRecovery becomes true when timelock expires', async () => { - // increase timestamp on-chain - const timelock = await governanceRouter.recoveryTimelock(); - await increaseTimestampBy(ethers.provider, timelock.toNumber()); - expect(await governanceRouter.inRecovery()).to.be.true; - }); - - it('Recovery Active: RecoveryManager CAN call local', async () => { - // Format abacus call message - const call = await formatCall(validatorManager, 'setValidator', [ - localDomain, - randomSigner.address, - ]); - - // dispatch call on local governorRouter - await expect( - sendFromSigner(recoveryManager, governanceRouter, 'callLocal', [[call]]), - ) - .to.emit(validatorManager, 'NewValidator') - .withArgs(localDomain, randomSigner.address); - }); - - it('Recovery Active: RecoveryManager CANNOT call remote', async () => { - // Format abacus call message - const call = await formatCall(validatorManager, 'setValidator', [ - localDomain, - randomSigner.address, - ]); - - // dispatch call on local governorRouter - await expect( - sendFromSigner(recoveryManager, governanceRouter, 'callRemote', [ - 2000, - [call], - ]), - ).to.be.revertedWith('! called by governor'); - }); - - it('Recovery Active: RecoveryManager CAN set xAppConnectionManager', async () => { - // set xApp Connection Manager - const xAppConnectionManager = - await governanceRouter.xAppConnectionManager(); - await expect( - sendFromSigner( - recoveryManager, - governanceRouter, - 'setXAppConnectionManager', - [randomSigner.address], - ), - ).to.not.be.reverted; - // reset xApp Connection Manager to actual contract - await sendFromSigner( - recoveryManager, - governanceRouter, - 'setXAppConnectionManager', - [xAppConnectionManager], - ); - }); - - it('Recovery Active: RecoveryManager CAN set Router locally', async () => { - const otherDomain = 2000; - const previousRouter = await governanceRouter.routers(otherDomain); - await expect( - sendFromSigner(recoveryManager, governanceRouter, 'setRouterLocal', [ - 2000, - abacus.ethersAddressToBytes32(randomSigner.address), - ]), - ) - .to.emit(governanceRouter, 'SetRouter') - .withArgs( - otherDomain, - previousRouter, - abacus.ethersAddressToBytes32(randomSigner.address), - ); - }); - - it('Recovery Active: Governor CANNOT call local OR remote', async () => { - // Format abacus call message - const call = await formatCall(validatorManager, 'setValidator', [ - localDomain, - randomSigner.address, - ]); - - // dispatch call on local governorRouter - await expect( - sendFromSigner(governor, governanceRouter, 'callLocal', [[call]]), - ).to.be.revertedWith('! called by recovery manager'); - - // dispatch call on local governorRouter - await expect( - sendFromSigner(governor, governanceRouter, 'callRemote', [2000, [call]]), - ).to.be.revertedWith('in recovery'); - }); - - it('Recovery Active: Governor CANNOT set xAppConnectionManager', async () => { - // cannot set xAppConnectionManager - await expect( - sendFromSigner(governor, governanceRouter, 'setXAppConnectionManager', [ - randomSigner.address, - ]), - ).to.be.revertedWith('! called by recovery manager'); - }); - - it('Recovery Active: Governor CANNOT set Router locally', async () => { - // cannot set Router - await expect( - sendFromSigner(governor, governanceRouter, 'setRouterLocal', [ - 2000, - abacus.ethersAddressToBytes32(randomSigner.address), - ]), - ).to.be.revertedWith('! called by recovery manager'); - }); - - it('Recovery Active: ONLY RecoveryManager can transfer RecoveryManager role', async () => { - await expectOnlyRecoveryManagerCanTransferRole( - governor, - governanceRouter, - randomSigner, - recoveryManager, - ); - }); - - it('Recovery Active: ONLY RecoveryManager can Exit Recovery', async () => { - await expectOnlyRecoveryManagerCanExitRecovery( - governor, - governanceRouter, - randomSigner, - recoveryManager, - ); - }); - - it('Exited Recovery: Timelock is deleted', async () => { - expect(await governanceRouter.recoveryActiveAt()).to.equal(0); - }); - - it('Exited Recovery: Not in Recovery (Governor CAN Call Local & Remote; Recovery Manager CANNOT Call either)', async () => { - await expectNotInRecovery( - validatorManager, - recoveryManager, - randomSigner, - governor, - governanceRouter, - outbox, - ); - }); - - it('Exited Recovery: ONLY RecoveryManager can transfer RecoveryManager role', async () => { - await expectOnlyRecoveryManagerCanTransferRole( - governor, - governanceRouter, - randomSigner, - recoveryManager, - ); - }); -}); diff --git a/solidity/abacus-xapps/test/bridge/BridgeToken.test.ts b/solidity/abacus-xapps/test/bridge/BridgeToken.test.ts index a64628e05..0f547af23 100644 --- a/solidity/abacus-xapps/test/bridge/BridgeToken.test.ts +++ b/solidity/abacus-xapps/test/bridge/BridgeToken.test.ts @@ -4,7 +4,7 @@ import { Wallet } from 'ethers'; import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { permitDigest } from './lib/permit'; -import { BridgeToken__factory, BridgeToken } from '../../typechain'; +import { BridgeToken__factory, BridgeToken } from '../../types'; const VALUE = 100; diff --git a/solidity/abacus-xapps/test/bridge/EthHelper.test.ts b/solidity/abacus-xapps/test/bridge/EthHelper.test.ts index 96cd57ca9..53b8e1ab8 100644 --- a/solidity/abacus-xapps/test/bridge/EthHelper.test.ts +++ b/solidity/abacus-xapps/test/bridge/EthHelper.test.ts @@ -1,12 +1,9 @@ import { ethers, abacus } from 'hardhat'; -import { BytesLike } from 'ethers'; import { expect } from 'chai'; import { utils } from '@abacus-network/utils'; import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; -import * as types from './lib/types'; -import { serializeMessage } from './lib/utils'; -import { BridgeConfig, BridgeDeploy } from './lib/BridgeDeploy'; +import { BridgeDeploy } from './lib/BridgeDeploy'; const localDomain = 1000; const remoteDomain = 2000; @@ -16,47 +13,18 @@ describe('EthHelper', async () => { let bridge: BridgeDeploy; let deployer: SignerWithAddress; - let deployerId: string; let recipient: SignerWithAddress; let recipientId: string; - let transferToSelfMessage: BytesLike; - let transferMessage: BytesLike; - const value = 1; before(async () => { [deployer, recipient] = await ethers.getSigners(); - deployerId = utils.addressToBytes32(deployer.address); recipientId = utils.addressToBytes32(recipient.address); await abacus.deploy(domains, deployer); bridge = new BridgeDeploy(deployer); await bridge.deploy(abacus); - - const tokenId: types.TokenIdentifier = { - domain: localDomain, - id: utils.addressToBytes32(bridge.weth(localDomain).address), - }; - const transferToSelfMessageObj: types.Message = { - tokenId, - action: { - type: types.BridgeMessageTypes.TRANSFER, - recipient: deployerId, - amount: value, - }, - }; - transferToSelfMessage = serializeMessage(transferToSelfMessageObj); - - const transferMessageObj: types.Message = { - tokenId, - action: { - type: types.BridgeMessageTypes.TRANSFER, - recipient: recipientId, - amount: value, - }, - }; - transferMessage = serializeMessage(transferMessageObj); }); it('send function', async () => { diff --git a/solidity/abacus-xapps/test/bridge/bridge.test.ts b/solidity/abacus-xapps/test/bridge/bridge.test.ts index 4e4b95e69..d8c40cba0 100644 --- a/solidity/abacus-xapps/test/bridge/bridge.test.ts +++ b/solidity/abacus-xapps/test/bridge/bridge.test.ts @@ -6,8 +6,8 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { utils } from '@abacus-network/utils'; import * as types from './lib/types'; import { serializeMessage } from './lib/utils'; -import { BridgeConfig, BridgeDeploy } from './lib/BridgeDeploy'; -import { BridgeToken, BridgeToken__factory, IERC20 } from '../../typechain'; +import { BridgeDeploy } from './lib/BridgeDeploy'; +import { BridgeToken, BridgeToken__factory, IERC20 } from '../../types'; const localDomain = 1000; const remoteDomain = 2000; @@ -256,7 +256,7 @@ describe('BridgeRouter', async () => { ethers.constants.MaxUint256, ); - const sendTx = await bridge + await bridge .router(localDomain) .send(localToken.address, TOKEN_VALUE, remoteDomain, deployerId); @@ -462,7 +462,6 @@ describe('BridgeRouter', async () => { describe('details message', async () => { let localToken: BridgeToken; let requestMessage: BytesLike; - let outgoingDetails: BytesLike; let incomingDetails: BytesLike; let transferMessage: BytesLike; let repr: BridgeToken; @@ -487,20 +486,6 @@ describe('BridgeRouter', async () => { }; requestMessage = serializeMessage(requestMessageObj); - const outgoingDetailsObj: types.Message = { - tokenId: { - domain: localDomain, - id: utils.addressToBytes32(localToken.address), - }, - action: { - type: types.BridgeMessageTypes.DETAILS, - name: utils.stringToBytes32(TEST_NAME), - symbol: utils.stringToBytes32(TEST_SYMBOL), - decimals: TEST_DECIMALS, - }, - }; - outgoingDetails = serializeMessage(outgoingDetailsObj); - // generate transfer action const transferMessageObj: types.Message = { tokenId: testTokenId, @@ -536,14 +521,6 @@ describe('BridgeRouter', async () => { .router(localDomain) .requestDetails(remoteDomain, testToken); - const requestDetailsObj: types.Message = { - tokenId: testTokenId, - action: { - type: types.BridgeMessageTypes.REQUEST_DETAILS, - }, - }; - const requestDetails = serializeMessage(requestDetailsObj); - await expect(requestTx).to.emit(abacus.outbox(localDomain), 'Dispatch'); }); @@ -721,16 +698,6 @@ describe('BridgeRouter', async () => { describe('when transferring a custom token', () => { it('allows outbound transfers of both assets', async () => { - const smallTransfer: types.Message = { - tokenId: testTokenId, - action: { - type: types.BridgeMessageTypes.TRANSFER, - recipient: deployerId, - amount: TOKEN_VALUE, - }, - }; - const smallTransferMessage = serializeMessage(smallTransfer); - const defaultSendTx = await bridge .router(localDomain) .send(defaultRepr.address, TOKEN_VALUE, remoteDomain, deployerId); diff --git a/solidity/abacus-xapps/test/bridge/bridgeMessage.test.ts b/solidity/abacus-xapps/test/bridge/bridgeMessage.test.ts index e72ff04e3..fa0051632 100644 --- a/solidity/abacus-xapps/test/bridge/bridgeMessage.test.ts +++ b/solidity/abacus-xapps/test/bridge/bridgeMessage.test.ts @@ -18,7 +18,7 @@ import { serializeTransferAction, serializeRequestDetailsAction, } from './lib/utils'; -import { TestBridgeMessage__factory, TestBridgeMessage } from '../../typechain'; +import { TestBridgeMessage__factory, TestBridgeMessage } from '../../types'; const stringToBytes32 = (s: string): string => { const str = Buffer.from(s.slice(0, 32), 'utf-8'); diff --git a/solidity/abacus-xapps/test/bridge/encoding.test.ts b/solidity/abacus-xapps/test/bridge/encoding.test.ts index 409e355cf..71982cbd9 100644 --- a/solidity/abacus-xapps/test/bridge/encoding.test.ts +++ b/solidity/abacus-xapps/test/bridge/encoding.test.ts @@ -1,5 +1,5 @@ import { ethers } from 'hardhat'; -import { TestEncoding__factory } from '../../typechain'; +import { TestEncoding__factory } from '../../types'; describe('Encoding', async () => { it('encodes', async () => { diff --git a/solidity/abacus-xapps/test/bridge/lib/BridgeDeploy.ts b/solidity/abacus-xapps/test/bridge/lib/BridgeDeploy.ts index b18fa45dc..c10861771 100644 --- a/solidity/abacus-xapps/test/bridge/lib/BridgeDeploy.ts +++ b/solidity/abacus-xapps/test/bridge/lib/BridgeDeploy.ts @@ -12,11 +12,8 @@ import { BridgeRouter__factory, ETHHelper, ETHHelper__factory, -} from '../../../typechain'; -import { - UpgradeBeacon__factory, - UpgradeBeacon, -} from '@abacus-network/abacus-sol/typechain'; +} from '../../../types'; +import { UpgradeBeacon__factory, UpgradeBeacon } from '@abacus-network/core'; export type BridgeConfig = SignerWithAddress; diff --git a/solidity/abacus-xapps/test/bridge/lib/BridgeDeployment.ts b/solidity/abacus-xapps/test/bridge/lib/BridgeDeployment.ts deleted file mode 100644 index a52efb7f4..000000000 --- a/solidity/abacus-xapps/test/bridge/lib/BridgeDeployment.ts +++ /dev/null @@ -1,130 +0,0 @@ -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; -import { assert } from 'chai'; -import * as ethers from 'ethers'; - -import { AbacusDeployment } from '@abacus-network/abacus-sol/test/lib/AbacusDeployment'; -import { utils, types } from '@abacus-network/utils'; - -import { - MockWeth__factory, - MockWeth, - BridgeToken, - BridgeToken__factory, - BridgeRouter, - BridgeRouter__factory, - ETHHelper, - ETHHelper__factory, -} from '../../../typechain'; -import { - UpgradeBeacon__factory, - UpgradeBeacon, -} from '@abacus-network/abacus-sol/typechain'; - -export interface BridgeInstance { - domain: types.Domain; - router: BridgeRouter; - helper: ETHHelper; - beacon: UpgradeBeacon; - token: BridgeToken; - weth: MockWeth; - signer: ethers.Signer; -} - -export class BridgeDeployment { - constructor( - public readonly domains: types.Domain[], - public readonly instances: Record, - ) {} - - static async fromAbacusDeployment( - abacus: AbacusDeployment, - signer: ethers.Signer, - ) { - const instances: Record = {}; - for (const domain of abacus.domains) { - const instance = await BridgeDeployment.deployInstance( - domain, - signer, - abacus.instances[domain].connectionManager.address, - ); - instances[domain] = instance; - } - - for (const local of abacus.domains) { - for (const remote of abacus.domains) { - if (local !== remote) { - await instances[local].router.enrollRemoteRouter( - remote, - utils.addressToBytes32(instances[remote].router.address), - ); - } - } - } - return new BridgeDeployment(abacus.domains, instances); - } - - static async deployInstance( - domain: types.Domain, - signer: ethers.Signer, - connectionManagerAddress: types.Address, - ): Promise { - const wethFactory = new MockWeth__factory(signer); - const weth = await wethFactory.deploy(); - await weth.initialize(); - - const tokenFactory = new BridgeToken__factory(signer); - const token = await tokenFactory.deploy(); - await token.initialize(); - - const beaconFactory = new UpgradeBeacon__factory(signer); - const beacon = await beaconFactory.deploy( - token.address, - await signer.getAddress(), - ); - - const routerFactory = new BridgeRouter__factory(signer); - const router = await routerFactory.deploy(); - await router.initialize(beacon.address, connectionManagerAddress); - - const helperFactory = new ETHHelper__factory(signer); - const helper = await helperFactory.deploy(weth.address, router.address); - return { - domain, - beacon, - router, - helper, - token, - weth, - signer, - }; - } - - router(domain: types.Domain): BridgeRouter { - return this.instances[domain].router; - } - - signer(domain: types.Domain): ethers.Signer { - return this.instances[domain].signer; - } - - weth(domain: types.Domain): MockWeth { - return this.instances[domain].weth; - } - - helper(domain: types.Domain): ETHHelper { - return this.instances[domain].helper; - } - - async bridgeToken( - local: types.Domain, - remote: types.Domain, - address: ethers.BytesLike, - ): Promise { - const router = this.router(local); - const reprAddr = await router['getLocalAddress(uint32,bytes32)']( - remote, - address, - ); - return BridgeToken__factory.connect(reprAddr, this.signer(local)); - } -} diff --git a/solidity/abacus-xapps/test/bridge/lib/permit.ts b/solidity/abacus-xapps/test/bridge/lib/permit.ts index 2a28f3e9c..b978924ee 100644 --- a/solidity/abacus-xapps/test/bridge/lib/permit.ts +++ b/solidity/abacus-xapps/test/bridge/lib/permit.ts @@ -1,5 +1,5 @@ import { BigNumber, BigNumberish, ethers } from 'ethers'; -import { BridgeToken } from '../../../typechain'; +import { BridgeToken } from '../../../types'; const PERMIT_TYPEHASH = ethers.utils.keccak256( ethers.utils.toUtf8Bytes( diff --git a/solidity/abacus-xapps/test/bridge/lib/utils.ts b/solidity/abacus-xapps/test/bridge/lib/utils.ts index 0b183c328..59643c71e 100644 --- a/solidity/abacus-xapps/test/bridge/lib/utils.ts +++ b/solidity/abacus-xapps/test/bridge/lib/utils.ts @@ -3,16 +3,6 @@ import { ethers } from 'ethers'; import * as types from './types'; -const typeToByte = (type: number): string => `0x0${type}`; - -const MESSAGE_LEN = { - identifier: 1, - tokenId: 36, - transfer: 65, - details: 66, - requestDetails: 1, -}; - // Formats Transfer Message export function formatTransfer( to: ethers.BytesLike, diff --git a/solidity/abacus-xapps/test/governance/governanceRouter.test.ts b/solidity/abacus-xapps/test/governance/governanceRouter.test.ts index 93c536d98..22b0c4419 100644 --- a/solidity/abacus-xapps/test/governance/governanceRouter.test.ts +++ b/solidity/abacus-xapps/test/governance/governanceRouter.test.ts @@ -9,12 +9,7 @@ import { increaseTimestampBy, } from './lib/utils'; import { GovernanceConfig, GovernanceDeploy } from './lib/GovernanceDeploy'; -import { - TestSet, - TestSet__factory, - GovernanceRouter, - GovernanceRouter__factory, -} from '../../typechain'; +import { TestSet, TestSet__factory, GovernanceRouter } from '../../types'; const recoveryTimelock = 60 * 60 * 24 * 7; const localDomain = 1000; diff --git a/solidity/abacus-xapps/test/governance/lib/GovernanceDeploy.ts b/solidity/abacus-xapps/test/governance/lib/GovernanceDeploy.ts index 6927af08c..c6613ea3f 100644 --- a/solidity/abacus-xapps/test/governance/lib/GovernanceDeploy.ts +++ b/solidity/abacus-xapps/test/governance/lib/GovernanceDeploy.ts @@ -1,11 +1,8 @@ import { ethers } from 'ethers'; -import { types, utils } from '@abacus-network/utils'; +import { types } from '@abacus-network/utils'; import { TestAbacusDeploy, TestRouterDeploy } from '@abacus-network/hardhat'; -import { - GovernanceRouter__factory, - GovernanceRouter, -} from '../../../typechain'; +import { GovernanceRouter__factory, GovernanceRouter } from '../../../types'; export type Governor = { domain: types.Domain; diff --git a/solidity/abacus-xapps/test/governance/lib/GovernanceDeployment.ts b/solidity/abacus-xapps/test/governance/lib/GovernanceDeployment.ts deleted file mode 100644 index 4edfc5640..000000000 --- a/solidity/abacus-xapps/test/governance/lib/GovernanceDeployment.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { ethers } from 'ethers'; -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; -import { utils, types } from '@abacus-network/utils'; -import { AbacusDeployment } from '@abacus-network/abacus-sol/test'; - -import { - GovernanceRouter__factory, - GovernanceRouter, -} from '../../../typechain'; - -export interface GovernanceInstance { - domain: types.Domain; - router: GovernanceRouter; -} - -const recoveryTimelock = 60 * 60 * 24 * 7; - -export class GovernanceDeployment { - constructor( - public readonly domains: types.Domain[], - public readonly instances: Record, - ) {} - - static async fromAbacusDeployment( - abacus: AbacusDeployment, - governor: SignerWithAddress, - recoveryManager: SignerWithAddress, - ) { - // Deploy routers. - const instances: Record = {}; - for (const domain of abacus.domains) { - const instance = await GovernanceDeployment.deployInstance( - domain, - governor, - recoveryManager, - abacus.connectionManager(domain).address, - ); - instances[domain] = instance; - } - - // Make all routers aware of eachother. - for (const local of abacus.domains) { - for (const remote of abacus.domains) { - await instances[local].router.enrollRemoteRouter( - remote, - utils.addressToBytes32(instances[remote].router.address), - ); - } - } - - // Set the governor on one router, clear it on all other routers. - for (let i = 0; i < abacus.domains.length; i++) { - const addr = i === 0 ? governor.address : ethers.constants.AddressZero; - await instances[abacus.domains[i]].router.setGovernor(addr); - } - - return new GovernanceDeployment(abacus.domains, instances); - } - - static async deployInstance( - domain: types.Domain, - governor: SignerWithAddress, - recoveryManager: SignerWithAddress, - connectionManagerAddress: types.Address, - ): Promise { - const routerFactory = new GovernanceRouter__factory(governor); - const router = await routerFactory.deploy(recoveryTimelock); - await router.initialize(connectionManagerAddress); - await router.transferOwnership(recoveryManager.address); - return { - domain, - router, - }; - } - - router(domain: types.Domain): GovernanceRouter { - return this.instances[domain].router; - } -} diff --git a/solidity/abacus-xapps/tsconfig.json b/solidity/abacus-xapps/tsconfig.json index 7cebd665e..724b6bd93 100644 --- a/solidity/abacus-xapps/tsconfig.json +++ b/solidity/abacus-xapps/tsconfig.json @@ -1,73 +1,16 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "ES2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */, - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, - // "lib": [], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - "resolveJsonModule": true /* Allows for importing, extracting types from and generating . json files.*/, - - /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - - /* Advanced Options */ - "skipLibCheck": true /* Skip type checking of declaration files. */, - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - } + "outDir": "./dist/", + "rootDir": "./types/" + }, + "exclude": [ + "./node_modules/", + "./dist/", + "./types/hardhat.d.ts" + ], + "extends": "../../tsconfig.package.json", + "include": [ + "./types/*.ts", + "./types/factories/*.ts" + ] } diff --git a/typescript/tsconfig.package.json b/tsconfig.package.json similarity index 95% rename from typescript/tsconfig.package.json rename to tsconfig.package.json index d58d66ace..8298a47e8 100644 --- a/typescript/tsconfig.package.json +++ b/tsconfig.package.json @@ -1,10 +1,10 @@ { "compilerOptions": { - "composite": true, "declaration": true, "declarationMap": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "incremental": false, "lib": ["es2015", "es5", "dom"], "module": "commonjs", "moduleResolution": "node", diff --git a/typescript/abacus-deploy/package.json b/typescript/abacus-deploy/package.json index 921592e80..c31258ab1 100644 --- a/typescript/abacus-deploy/package.json +++ b/typescript/abacus-deploy/package.json @@ -28,11 +28,11 @@ "kathy": "hardhat kathy --environment local", "prettier": "prettier --write *.ts ./src ./config ./scripts ./test" }, - "author": "Celo Labs Inc.", "license": "MIT OR Apache-2.0", "dependencies": { + "@abacus-network/apps": "file:../../solidity/apps", + "@abacus-network/core": "file:../../solidity/core", "@abacus-network/sdk": "^0.0.1", - "@abacus-network/ts-interface": "^0.0.1", "@aws-sdk/client-kms": "3.48.0", "@ethersproject/experimental": "^5.3.0", "@nomiclabs/hardhat-etherscan": "^3.0.3", diff --git a/typescript/abacus-deploy/src/bridge/BridgeContracts.ts b/typescript/abacus-deploy/src/bridge/BridgeContracts.ts index c413a28b3..da36fb7a3 100644 --- a/typescript/abacus-deploy/src/bridge/BridgeContracts.ts +++ b/typescript/abacus-deploy/src/bridge/BridgeContracts.ts @@ -1,14 +1,21 @@ import fs from 'fs'; -import { xapps } from '@abacus-network/ts-interface'; +import { + ETHHelper, + ETHHelper__factory, + BridgeRouter, + BridgeRouter__factory, + BridgeToken, + BridgeToken__factory, +} from '@abacus-network/apps'; import { ethers } from 'ethers'; import { CommonContracts, BeaconProxy } from '../common'; import { BridgeContractAddresses } from './types'; export class BridgeContracts extends CommonContracts { constructor( - public readonly router: BeaconProxy, - public readonly token: BeaconProxy, - public readonly helper?: xapps.ETHHelper, + public readonly router: BeaconProxy, + public readonly token: BeaconProxy, + public readonly helper?: ETHHelper, ) { super(); } @@ -31,20 +38,20 @@ export class BridgeContracts extends CommonContracts { addresses: BridgeContractAddresses, signer: ethers.Signer, ): BridgeContracts { - const router: BeaconProxy = BeaconProxy.fromObject( + const router: BeaconProxy = BeaconProxy.fromObject( addresses.router, - xapps.BridgeRouter__factory.abi, + BridgeRouter__factory.abi, signer, ); - const token: BeaconProxy = BeaconProxy.fromObject( + const token: BeaconProxy = BeaconProxy.fromObject( addresses.token, - xapps.BridgeToken__factory.abi, + BridgeToken__factory.abi, signer, ); if (addresses.helper) { - const helper = xapps.ETHHelper__factory.connect(addresses.helper, signer); + const helper = ETHHelper__factory.connect(addresses.helper, signer); return new BridgeContracts(router, token, helper); } return new BridgeContracts(router, token); diff --git a/typescript/abacus-deploy/src/bridge/BridgeDeploy.ts b/typescript/abacus-deploy/src/bridge/BridgeDeploy.ts index 0c81bea62..b29d348d9 100644 --- a/typescript/abacus-deploy/src/bridge/BridgeDeploy.ts +++ b/typescript/abacus-deploy/src/bridge/BridgeDeploy.ts @@ -1,4 +1,4 @@ -import { xapps } from '@abacus-network/ts-interface'; +import { BridgeToken, BridgeRouter, ETHHelper } from '@abacus-network/apps'; import { types } from '@abacus-network/utils'; import { BridgeConfig } from './types'; import { BridgeInstance } from './BridgeInstance'; @@ -30,15 +30,15 @@ export class BridgeDeploy extends RouterDeploy { ); } - token(domain: types.Domain): xapps.BridgeToken { + token(domain: types.Domain): BridgeToken { return this.instances[domain].token; } - router(domain: types.Domain): xapps.BridgeRouter { + router(domain: types.Domain): BridgeRouter { return this.instances[domain].router; } - helper(domain: types.Domain): xapps.ETHHelper | undefined { + helper(domain: types.Domain): ETHHelper | undefined { return this.instances[domain].helper; } } diff --git a/typescript/abacus-deploy/src/bridge/BridgeInstance.ts b/typescript/abacus-deploy/src/bridge/BridgeInstance.ts index e2d097e3c..a2ab32f1e 100644 --- a/typescript/abacus-deploy/src/bridge/BridgeInstance.ts +++ b/typescript/abacus-deploy/src/bridge/BridgeInstance.ts @@ -1,4 +1,11 @@ -import { xapps } from '@abacus-network/ts-interface'; +import { + ETHHelper, + ETHHelper__factory, + BridgeRouter, + BridgeRouter__factory, + BridgeToken, + BridgeToken__factory, +} from '@abacus-network/apps'; import { types } from '@abacus-network/utils'; import { ChainConfig } from '../config'; import { ContractDeployer, BeaconProxy } from '../common'; @@ -26,17 +33,17 @@ export class BridgeInstance extends RouterInstance { const core = config.core[chain.name]; if (core === undefined) throw new Error('could not find core'); - const token: BeaconProxy = await BeaconProxy.deploy( + const token: BeaconProxy = await BeaconProxy.deploy( chain, - new xapps.BridgeToken__factory(chain.signer), + new BridgeToken__factory(chain.signer), core.upgradeBeaconController, [], [], ); - const router: BeaconProxy = await BeaconProxy.deploy( + const router: BeaconProxy = await BeaconProxy.deploy( chain, - new xapps.BridgeRouter__factory(chain.signer), + new BridgeRouter__factory(chain.signer), core.upgradeBeaconController, [], [token.beacon.address, core.xAppConnectionManager], @@ -45,8 +52,8 @@ export class BridgeInstance extends RouterInstance { const weth = config.weth[chain.name]; if (weth) { const deployer = new ContractDeployer(chain); - const helper: xapps.ETHHelper = await deployer.deploy( - new xapps.ETHHelper__factory(chain.signer), + const helper: ETHHelper = await deployer.deploy( + new ETHHelper__factory(chain.signer), weth, router.address, ); @@ -57,15 +64,15 @@ export class BridgeInstance extends RouterInstance { return new BridgeInstance(chain, contracts); } - get token(): xapps.BridgeToken { + get token(): BridgeToken { return this.contracts.token.contract; } - get router(): xapps.BridgeRouter { + get router(): BridgeRouter { return this.contracts.router.contract; } - get helper(): xapps.ETHHelper | undefined { + get helper(): ETHHelper | undefined { return this.contracts.helper; } @@ -75,14 +82,14 @@ export class BridgeInstance extends RouterInstance { getBeaconProxyVerificationInput( 'BridgeToken', this.contracts.token, - xapps.BridgeToken__factory.bytecode, + BridgeToken__factory.bytecode, ), ); input = input.concat( getBeaconProxyVerificationInput( 'BridgeRouter', this.contracts.router, - xapps.BridgeRouter__factory.bytecode, + BridgeRouter__factory.bytecode, ), ); if (this.helper) { @@ -90,7 +97,7 @@ export class BridgeInstance extends RouterInstance { getContractVerificationInput( 'ETH Helper', this.helper, - xapps.ETHHelper__factory.bytecode, + ETHHelper__factory.bytecode, ), ); } diff --git a/typescript/abacus-deploy/src/common/BeaconProxy.ts b/typescript/abacus-deploy/src/common/BeaconProxy.ts index e737a38a8..4ce68a809 100644 --- a/typescript/abacus-deploy/src/common/BeaconProxy.ts +++ b/typescript/abacus-deploy/src/common/BeaconProxy.ts @@ -1,5 +1,10 @@ import { ethers } from 'ethers'; -import { core } from '@abacus-network/ts-interface'; +import { + UpgradeBeacon, + UpgradeBeacon__factory, + UpgradeBeaconProxy, + UpgradeBeaconProxy__factory, +} from '@abacus-network/core'; import { types } from '@abacus-network/utils'; import { ChainConfig } from '../config'; @@ -14,8 +19,8 @@ export type ProxiedAddress = { export class BeaconProxy { constructor( public readonly implementation: T, - public readonly proxy: core.UpgradeBeaconProxy, - public readonly beacon: core.UpgradeBeacon, + public readonly proxy: UpgradeBeaconProxy, + public readonly beacon: UpgradeBeacon, public readonly contract: T, ) {} @@ -33,8 +38,8 @@ export class BeaconProxy { ): Promise> { const deployer = new ContractDeployer(chain, false); const implementation: T = await deployer.deploy(factory, ...deployArgs); - const beacon: core.UpgradeBeacon = await deployer.deploy( - new core.UpgradeBeacon__factory(chain.signer), + const beacon: UpgradeBeacon = await deployer.deploy( + new UpgradeBeacon__factory(chain.signer), implementation.address, ubcAddress, ); @@ -43,8 +48,8 @@ export class BeaconProxy { 'initialize', initArgs, ); - const proxy: core.UpgradeBeaconProxy = await deployer.deploy( - new core.UpgradeBeaconProxy__factory(chain.signer), + const proxy: UpgradeBeaconProxy = await deployer.deploy( + new UpgradeBeaconProxy__factory(chain.signer), beacon.address, initData, ); @@ -69,14 +74,8 @@ export class BeaconProxy { abi, signer, ) as T; - const proxy = core.UpgradeBeaconProxy__factory.connect( - addresses.proxy, - signer, - ); - const beacon = core.UpgradeBeacon__factory.connect( - addresses.beacon, - signer, - ); + const proxy = UpgradeBeaconProxy__factory.connect(addresses.proxy, signer); + const beacon = UpgradeBeacon__factory.connect(addresses.beacon, signer); const contract = new ethers.Contract(addresses.proxy, abi, signer) as T; return new BeaconProxy(implementation, proxy, beacon, contract); } @@ -95,8 +94,8 @@ export class BeaconProxy { 'initialize', initArgs, ); - const proxy: core.UpgradeBeaconProxy = await deployer.deploy( - new core.UpgradeBeaconProxy__factory(chain.signer), + const proxy: UpgradeBeaconProxy = await deployer.deploy( + new UpgradeBeaconProxy__factory(chain.signer), this.beacon.address, initData, ); diff --git a/typescript/abacus-deploy/src/core/CoreContracts.ts b/typescript/abacus-deploy/src/core/CoreContracts.ts index be91be73b..cb75a9fc6 100644 --- a/typescript/abacus-deploy/src/core/CoreContracts.ts +++ b/typescript/abacus-deploy/src/core/CoreContracts.ts @@ -1,6 +1,17 @@ import fs from 'fs'; import { ethers } from 'ethers'; -import { core } from '@abacus-network/ts-interface'; +import { + UpgradeBeaconController, + UpgradeBeaconController__factory, + XAppConnectionManager, + XAppConnectionManager__factory, + ValidatorManager, + ValidatorManager__factory, + Outbox, + Outbox__factory, + Inbox, + Inbox__factory, +} from '@abacus-network/core'; import { types } from '@abacus-network/utils'; import { BeaconProxy, CommonContracts, ProxiedAddress } from '../common'; @@ -8,11 +19,11 @@ import { CoreContractAddresses } from './types'; export class CoreContracts extends CommonContracts { constructor( - public readonly upgradeBeaconController: core.UpgradeBeaconController, - public readonly xAppConnectionManager: core.XAppConnectionManager, - public readonly validatorManager: core.ValidatorManager, - public readonly outbox: BeaconProxy, - public readonly inboxes: Record>, + public readonly upgradeBeaconController: UpgradeBeaconController, + public readonly xAppConnectionManager: XAppConnectionManager, + public readonly validatorManager: ValidatorManager, + public readonly outbox: BeaconProxy, + public readonly inboxes: Record>, ) { super(); } @@ -44,33 +55,32 @@ export class CoreContracts extends CommonContracts { addresses: CoreContractAddresses, signer: ethers.Signer, ): CoreContracts { - const upgradeBeaconController = - core.UpgradeBeaconController__factory.connect( - addresses.upgradeBeaconController, - signer, - ); - const xAppConnectionManager = core.XAppConnectionManager__factory.connect( + const upgradeBeaconController = UpgradeBeaconController__factory.connect( + addresses.upgradeBeaconController, + signer, + ); + const xAppConnectionManager = XAppConnectionManager__factory.connect( addresses.xAppConnectionManager, signer, ); - const validatorManager = core.ValidatorManager__factory.connect( + const validatorManager = ValidatorManager__factory.connect( addresses.validatorManager, signer, ); - const outbox: BeaconProxy = BeaconProxy.fromObject( + const outbox: BeaconProxy = BeaconProxy.fromObject( addresses.outbox, - core.Outbox__factory.abi, + Outbox__factory.abi, signer, ); - const inboxes: Record> = {}; + const inboxes: Record> = {}; Object.keys(addresses.inboxes) .map((d) => parseInt(d)) .map((domain: types.Domain) => { inboxes[domain] = BeaconProxy.fromObject( addresses.inboxes[domain], - core.Inbox__factory.abi, + Inbox__factory.abi, signer, ); }); diff --git a/typescript/abacus-deploy/src/core/CoreDeploy.ts b/typescript/abacus-deploy/src/core/CoreDeploy.ts index 025b07d09..534eaf28f 100644 --- a/typescript/abacus-deploy/src/core/CoreDeploy.ts +++ b/typescript/abacus-deploy/src/core/CoreDeploy.ts @@ -1,6 +1,12 @@ import path from 'path'; import { types } from '@abacus-network/utils'; -import { core } from '@abacus-network/ts-interface'; +import { + UpgradeBeaconController, + XAppConnectionManager, + ValidatorManager, + Outbox, + Inbox, +} from '@abacus-network/core'; import { CoreInstance } from './CoreInstance'; import { CoreContracts } from './CoreContracts'; import { CoreConfig } from './types'; @@ -17,23 +23,23 @@ export class CoreDeploy extends CommonDeploy { return CoreInstance.deploy(domain, this.chains, config); } - upgradeBeaconController(domain: types.Domain): core.UpgradeBeaconController { + upgradeBeaconController(domain: types.Domain): UpgradeBeaconController { return this.instances[domain].upgradeBeaconController; } - validatorManager(domain: types.Domain): core.ValidatorManager { + validatorManager(domain: types.Domain): ValidatorManager { return this.instances[domain].validatorManager; } - outbox(domain: types.Domain): core.Outbox { + outbox(domain: types.Domain): Outbox { return this.instances[domain].outbox; } - inbox(local: types.Domain, remote: types.Domain): core.Inbox { + inbox(local: types.Domain, remote: types.Domain): Inbox { return this.instances[local].inbox(remote); } - xAppConnectionManager(domain: types.Domain): core.XAppConnectionManager { + xAppConnectionManager(domain: types.Domain): XAppConnectionManager { return this.instances[domain].xAppConnectionManager; } diff --git a/typescript/abacus-deploy/src/core/CoreInstance.ts b/typescript/abacus-deploy/src/core/CoreInstance.ts index dbd1b422e..fe809b10f 100644 --- a/typescript/abacus-deploy/src/core/CoreInstance.ts +++ b/typescript/abacus-deploy/src/core/CoreInstance.ts @@ -1,6 +1,18 @@ import { ethers } from 'ethers'; import { types } from '@abacus-network/utils'; -import { core } from '@abacus-network/ts-interface'; +import { + UpgradeBeaconController, + UpgradeBeaconController__factory, + XAppConnectionManager, + XAppConnectionManager__factory, + ValidatorManager, + ValidatorManager__factory, + Outbox, + Outbox__factory, + Inbox, + Inbox__factory, + UpgradeBeaconProxy__factory, +} from '@abacus-network/core'; import { ChainConfig } from '../config'; import { BeaconProxy, ContractDeployer, CommonInstance } from '../common'; import { @@ -20,13 +32,11 @@ export class CoreInstance extends CommonInstance { const chain = chains[domain]; const deployer = new ContractDeployer(chain); - const upgradeBeaconController: core.UpgradeBeaconController = - await deployer.deploy( - new core.UpgradeBeaconController__factory(chain.signer), - ); + const upgradeBeaconController: UpgradeBeaconController = + await deployer.deploy(new UpgradeBeaconController__factory(chain.signer)); - const validatorManager: core.ValidatorManager = await deployer.deploy( - new core.ValidatorManager__factory(chain.signer), + const validatorManager: ValidatorManager = await deployer.deploy( + new ValidatorManager__factory(chain.signer), ); await validatorManager.enrollValidator( domain, @@ -34,21 +44,20 @@ export class CoreInstance extends CommonInstance { chain.overrides, ); - const outbox: BeaconProxy = await BeaconProxy.deploy( + const outbox: BeaconProxy = await BeaconProxy.deploy( chain, - new core.Outbox__factory(chain.signer), + new Outbox__factory(chain.signer), upgradeBeaconController.address, [domain], [validatorManager.address], ); - const xAppConnectionManager: core.XAppConnectionManager = - await deployer.deploy( - new core.XAppConnectionManager__factory(chain.signer), - ); + const xAppConnectionManager: XAppConnectionManager = await deployer.deploy( + new XAppConnectionManager__factory(chain.signer), + ); await xAppConnectionManager.setOutbox(outbox.address, chain.overrides); - const inboxes: Record> = {}; + const inboxes: Record> = {}; const domains = Object.keys(chains).map((d) => parseInt(d)); const remotes = domains.filter((d) => d !== domain); for (let i = 0; i < remotes.length; i++) { @@ -62,7 +71,7 @@ export class CoreInstance extends CommonInstance { if (i === 0) { inboxes[remote] = await BeaconProxy.deploy( chain, - new core.Inbox__factory(chain.signer), + new Inbox__factory(chain.signer), upgradeBeaconController.address, [domain, config.processGas, config.reserveGas], initArgs, @@ -113,23 +122,23 @@ export class CoreInstance extends CommonInstance { return Object.keys(this.contracts.inboxes).map((d) => parseInt(d)); } - get upgradeBeaconController(): core.UpgradeBeaconController { + get upgradeBeaconController(): UpgradeBeaconController { return this.contracts.upgradeBeaconController; } - get validatorManager(): core.ValidatorManager { + get validatorManager(): ValidatorManager { return this.contracts.validatorManager; } - get outbox(): core.Outbox { + get outbox(): Outbox { return this.contracts.outbox.contract; } - inbox(domain: types.Domain): core.Inbox { + inbox(domain: types.Domain): Inbox { return this.contracts.inboxes[domain].contract; } - get xAppConnectionManager(): core.XAppConnectionManager { + get xAppConnectionManager(): XAppConnectionManager { return this.contracts.xAppConnectionManager; } get verificationInput(): VerificationInput { @@ -138,28 +147,28 @@ export class CoreInstance extends CommonInstance { getContractVerificationInput( 'XAppConnectionManager', this.xAppConnectionManager, - core.XAppConnectionManager__factory.bytecode, + XAppConnectionManager__factory.bytecode, ), ); input.push( getContractVerificationInput( 'ValidatorManager', this.validatorManager, - core.ValidatorManager__factory.bytecode, + ValidatorManager__factory.bytecode, ), ); input.push( getContractVerificationInput( 'UpgradeBeaconController', this.upgradeBeaconController, - core.UpgradeBeaconController__factory.bytecode, + UpgradeBeaconController__factory.bytecode, ), ); input = input.concat( getBeaconProxyVerificationInput( 'Outbox', this.contracts.outbox, - core.Outbox__factory.bytecode, + Outbox__factory.bytecode, ), ); // All Inboxes share the same implementation and upgrade beacon. @@ -170,7 +179,7 @@ export class CoreInstance extends CommonInstance { getBeaconProxyVerificationInput( 'Inbox', inbox, - core.Inbox__factory.bytecode, + Inbox__factory.bytecode, ), ); } else { @@ -178,7 +187,7 @@ export class CoreInstance extends CommonInstance { getContractVerificationInput( 'Inbox Proxy', inbox.proxy, - core.UpgradeBeaconProxy__factory.bytecode, + UpgradeBeaconProxy__factory.bytecode, true, ), ); diff --git a/typescript/abacus-deploy/src/core/implementation.ts b/typescript/abacus-deploy/src/core/implementation.ts index b9d0c4461..5bd246cd9 100644 --- a/typescript/abacus-deploy/src/core/implementation.ts +++ b/typescript/abacus-deploy/src/core/implementation.ts @@ -1,4 +1,4 @@ -import { core } from '@abacus-network/ts-interface'; +import { Inbox__factory, Outbox__factory } from '@abacus-network/core'; import { types } from '@abacus-network/utils'; import { CoreDeploy } from './CoreDeploy'; import { CoreInstance } from './CoreInstance'; @@ -30,7 +30,7 @@ export class ImplementationDeployer { */ private async _deployOutboxImplementation(domain: types.Domain) { const signer = this.deploy.signer(domain); - const factory = new core.Outbox__factory(signer); + const factory = new Outbox__factory(signer); const implementation = await factory.deploy( domain, this.deploy.chains[domain].overrides, @@ -50,7 +50,7 @@ export class ImplementationDeployer { */ private async _deployInboxImplementation(domain: types.Domain) { const signer = this.deploy.signer(domain); - const factory = new core.Inbox__factory(signer); + const factory = new Inbox__factory(signer); const implementation = await factory.deploy( domain, this.config.processGas, diff --git a/typescript/abacus-deploy/src/governance/GovernanceContracts.ts b/typescript/abacus-deploy/src/governance/GovernanceContracts.ts index a936aff90..f2e9278dc 100644 --- a/typescript/abacus-deploy/src/governance/GovernanceContracts.ts +++ b/typescript/abacus-deploy/src/governance/GovernanceContracts.ts @@ -1,11 +1,14 @@ import fs from 'fs'; -import { xapps } from '@abacus-network/ts-interface'; +import { + GovernanceRouter, + GovernanceRouter__factory, +} from '@abacus-network/apps'; import { ethers } from 'ethers'; import { CommonContracts, BeaconProxy } from '../common'; import { GovernanceContractAddresses } from './types'; export class GovernanceContracts extends CommonContracts { - constructor(public readonly router: BeaconProxy) { + constructor(public readonly router: BeaconProxy) { super(); } @@ -28,9 +31,9 @@ export class GovernanceContracts extends CommonContracts = BeaconProxy.fromObject( + const router: BeaconProxy = BeaconProxy.fromObject( addresses.router, - xapps.GovernanceRouter__factory.abi, + GovernanceRouter__factory.abi, signer, ); return new GovernanceContracts(router); diff --git a/typescript/abacus-deploy/src/governance/GovernanceDeploy.ts b/typescript/abacus-deploy/src/governance/GovernanceDeploy.ts index ba755c176..abd0e7361 100644 --- a/typescript/abacus-deploy/src/governance/GovernanceDeploy.ts +++ b/typescript/abacus-deploy/src/governance/GovernanceDeploy.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers'; import { types } from '@abacus-network/utils'; -import { xapps } from '@abacus-network/ts-interface'; +import { GovernanceRouter } from '@abacus-network/apps'; import { CommonDeploy, DeployType } from '../common'; import { ChainConfig } from '../config'; import { RouterDeploy } from '../router'; @@ -47,7 +47,7 @@ export class GovernanceDeploy extends RouterDeploy< ); } - router(domain: types.Domain): xapps.GovernanceRouter { + router(domain: types.Domain): GovernanceRouter { return this.instances[domain].router; } } diff --git a/typescript/abacus-deploy/src/governance/GovernanceInstance.ts b/typescript/abacus-deploy/src/governance/GovernanceInstance.ts index 8eb9b1ea5..8840b90c9 100644 --- a/typescript/abacus-deploy/src/governance/GovernanceInstance.ts +++ b/typescript/abacus-deploy/src/governance/GovernanceInstance.ts @@ -1,4 +1,7 @@ -import { xapps } from '@abacus-network/ts-interface'; +import { + GovernanceRouter, + GovernanceRouter__factory, +} from '@abacus-network/apps'; import { types } from '@abacus-network/utils'; import { ChainConfig } from '../config'; import { BeaconProxy } from '../common'; @@ -22,14 +25,13 @@ export class GovernanceInstance extends RouterInstance { const core = config.core[chain.name]; if (core === undefined) throw new Error('could not find core'); - const router: BeaconProxy = - await BeaconProxy.deploy( - chain, - new xapps.GovernanceRouter__factory(chain.signer), - core.upgradeBeaconController, - [config.recoveryTimelock], - [core.xAppConnectionManager], - ); + const router: BeaconProxy = await BeaconProxy.deploy( + chain, + new GovernanceRouter__factory(chain.signer), + core.upgradeBeaconController, + [config.recoveryTimelock], + [core.xAppConnectionManager], + ); const addresses = config.addresses[chain.name]; if (addresses === undefined) throw new Error('could not find addresses'); @@ -39,7 +41,7 @@ export class GovernanceInstance extends RouterInstance { return new GovernanceInstance(chain, contracts); } - get router(): xapps.GovernanceRouter { + get router(): GovernanceRouter { return this.contracts.router.contract; } @@ -47,7 +49,7 @@ export class GovernanceInstance extends RouterInstance { return getBeaconProxyVerificationInput( 'GovernanceRouter', this.contracts.router, - xapps.GovernanceRouter__factory.bytecode, + GovernanceRouter__factory.bytecode, ); } } diff --git a/typescript/abacus-deploy/src/verification/utils.ts b/typescript/abacus-deploy/src/verification/utils.ts index b2dc10992..42ecd36fe 100644 --- a/typescript/abacus-deploy/src/verification/utils.ts +++ b/typescript/abacus-deploy/src/verification/utils.ts @@ -1,5 +1,8 @@ import { ethers } from 'ethers'; -import { core } from '@abacus-network/ts-interface'; +import { + UpgradeBeacon__factory, + UpgradeBeaconProxy__factory, +} from '@abacus-network/core'; import { BeaconProxy } from '../common'; import { @@ -60,7 +63,7 @@ export function getBeaconProxyVerificationInput( address: contract.beacon.address, constructorArguments: getConstructorArguments( contract.beacon, - core.UpgradeBeacon__factory.bytecode, + UpgradeBeacon__factory.bytecode, ), }; const proxy: ContractVerificationInput = { @@ -68,7 +71,7 @@ export function getBeaconProxyVerificationInput( address: contract.proxy.address, constructorArguments: getConstructorArguments( contract.proxy, - core.UpgradeBeaconProxy__factory.bytecode, + UpgradeBeaconProxy__factory.bytecode, ), isProxy: true, }; diff --git a/typescript/abacus-deploy/tsconfig.json b/typescript/abacus-deploy/tsconfig.json index aa8385ab6..bd5960865 100644 --- a/typescript/abacus-deploy/tsconfig.json +++ b/typescript/abacus-deploy/tsconfig.json @@ -4,7 +4,7 @@ "rootDir": "./" }, "exclude": ["./node_modules/", "./dist/", "./tmp.ts"], - "extends": "../tsconfig.package.json", + "extends": "../../tsconfig.package.json", "include": [ "./*.ts", "./config/**/*.ts", diff --git a/typescript/abacus-sdk/.gitignore b/typescript/abacus-sdk/.gitignore index 941bc4ed8..5bfcd1f8b 100644 --- a/typescript/abacus-sdk/.gitignore +++ b/typescript/abacus-sdk/.gitignore @@ -1,3 +1,2 @@ .env dist -tsconfig.tsbuildinfo diff --git a/typescript/abacus-sdk/package.json b/typescript/abacus-sdk/package.json index 07c77b2d9..eea2101fd 100644 --- a/typescript/abacus-sdk/package.json +++ b/typescript/abacus-sdk/package.json @@ -5,14 +5,11 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "build": "rm -rf ./dist/ && rm tsconfig.tsbuildinfo & tsc", - "check": "rm tsconfig.tsbuildinfo & tsc --noEmit", + "build": "tsc", + "check": "tsc --noEmit", "prettier": "prettier --write ./src", - "lint": "npm run prettier && eslint ./src", - "lint:fix": "npm run prettier && eslint --fix ./src", "prepublishOnly": "npm run build" }, - "author": "Celo Labs Inc.", "license": "MIT OR Apache-2.0", "devDependencies": { "@types/node": "^16.9.1", @@ -26,10 +23,11 @@ "typescript": "^4.4.3" }, "dependencies": { + "@abacus-network/apps": "file:../../solidity/apps", + "@abacus-network/core": "file:../../solidity/core", "@ethersproject/bignumber": "^5.5.0", "@ethersproject/bytes": "^5.5.0", "celo-ethers-provider": "0.0.0", - "ethers": "^5.4.7", - "@abacus-network/ts-interface": "^0.0.1" + "ethers": "^5.4.7" } } diff --git a/typescript/abacus-sdk/src/abacus/AbacusContext.ts b/typescript/abacus-sdk/src/abacus/AbacusContext.ts index 3fc3a6d0d..2a1ccec14 100644 --- a/typescript/abacus-sdk/src/abacus/AbacusContext.ts +++ b/typescript/abacus-sdk/src/abacus/AbacusContext.ts @@ -1,6 +1,7 @@ import { BigNumberish, ethers } from 'ethers'; import { MultiProvider } from '..'; -import { xapps, core } from '@abacus-network/ts-interface'; +import { Inbox } from '@abacus-network/core'; +import { BridgeToken, BridgeToken__factory } from '@abacus-network/apps'; import { BridgeContracts } from './contracts/BridgeContracts'; import { Governor, CoreContracts } from './contracts/CoreContracts'; import { ResolvedTokenInfo, TokenIdentifier } from './tokens'; @@ -198,7 +199,7 @@ export class AbacusContext extends MultiProvider { getInboxFor( outbox: string | number, remote: string | number, - ): core.Inbox | undefined { + ): Inbox | undefined { return this.getCore(remote)?.getInbox(this.resolveDomain(outbox)); } @@ -213,10 +214,7 @@ export class AbacusContext extends MultiProvider { * @returns An interface for the Inbox * @throws If no inbox is found. */ - mustGetInboxFor( - outbox: string | number, - remote: string | number, - ): core.Inbox { + mustGetInboxFor(outbox: string | number, remote: string | number): Inbox { const inbox = this.getInboxFor(outbox, remote); if (!inbox) { throw new Error(`Missing inbox for outbox ${outbox} & remote ${remote}`); @@ -277,7 +275,7 @@ export class AbacusContext extends MultiProvider { async resolveRepresentation( nameOrDomain: string | number, token: TokenIdentifier, - ): Promise { + ): Promise { const domain = this.resolveDomain(nameOrDomain); const bridge = this.getBridge(domain); @@ -292,7 +290,7 @@ export class AbacusContext extends MultiProvider { return; } - let contract = new xapps.BridgeToken__factory().attach(evmId(address)); + let contract = new BridgeToken__factory().attach(evmId(address)); const connection = this.getConnection(domain); if (connection) { @@ -315,7 +313,7 @@ export class AbacusContext extends MultiProvider { async resolveRepresentations( token: TokenIdentifier, ): Promise { - const tokens: Map = new Map(); + const tokens: Map = new Map(); await Promise.all( this.domainNumbers.map(async (domain) => { @@ -389,7 +387,7 @@ export class AbacusContext extends MultiProvider { async resolveCanonicalToken( nameOrDomain: string | number, representation: Address, - ): Promise { + ): Promise { const canonicalId = await this.resolveCanonicalIdentifier( nameOrDomain, representation, diff --git a/typescript/abacus-sdk/src/abacus/contracts/BridgeContracts.ts b/typescript/abacus-sdk/src/abacus/contracts/BridgeContracts.ts index 0fad79877..4a50ff97f 100644 --- a/typescript/abacus-sdk/src/abacus/contracts/BridgeContracts.ts +++ b/typescript/abacus-sdk/src/abacus/contracts/BridgeContracts.ts @@ -1,5 +1,10 @@ import { ethers } from 'ethers'; -import { xapps } from '@abacus-network/ts-interface'; +import { + BridgeRouter, + BridgeRouter__factory, + ETHHelper, + ETHHelper__factory, +} from '@abacus-network/apps'; import { Contracts } from '../../contracts'; type Address = string; @@ -16,8 +21,8 @@ interface BridgeInfo { export class BridgeContracts extends Contracts { domain: number; - bridgeRouter: xapps.BridgeRouter; - ethHelper?: xapps.ETHHelper; + bridgeRouter: BridgeRouter; + ethHelper?: ETHHelper; constructor( domain: number, @@ -27,11 +32,9 @@ export class BridgeContracts extends Contracts { ) { super(domain, bridgeRouter, ethHelper, signer); this.domain = domain; - this.bridgeRouter = new xapps.BridgeRouter__factory(signer).attach( - bridgeRouter, - ); + this.bridgeRouter = new BridgeRouter__factory(signer).attach(bridgeRouter); if (ethHelper) { - this.ethHelper = new xapps.ETHHelper__factory(signer).attach(ethHelper); + this.ethHelper = new ETHHelper__factory(signer).attach(ethHelper); } } diff --git a/typescript/abacus-sdk/src/abacus/contracts/CoreContracts.ts b/typescript/abacus-sdk/src/abacus/contracts/CoreContracts.ts index 75085655b..c8a250be3 100644 --- a/typescript/abacus-sdk/src/abacus/contracts/CoreContracts.ts +++ b/typescript/abacus-sdk/src/abacus/contracts/CoreContracts.ts @@ -1,5 +1,16 @@ import { ethers } from 'ethers'; -import { core, xapps } from '@abacus-network/ts-interface'; +import { + Inbox, + Outbox, + Inbox__factory, + Outbox__factory, + XAppConnectionManager, + XAppConnectionManager__factory, +} from '@abacus-network/core'; +import { + GovernanceRouter, + GovernanceRouter__factory, +} from '@abacus-network/apps'; import { Contracts } from '../../contracts'; import { InboxInfo } from '../domains/domain'; import { CallBatch } from '../govern'; @@ -52,37 +63,37 @@ export class CoreContracts extends Contracts { }); } - getInbox(domain: number): core.Inbox | undefined { + getInbox(domain: number): Inbox | undefined { if (!this.providerOrSigner) { throw new Error('No provider or signer. Call `connect` first.'); } const inbox = this._inboxes.get(domain); if (!inbox) return; - return core.Inbox__factory.connect(inbox.address, this.providerOrSigner); + return Inbox__factory.connect(inbox.address, this.providerOrSigner); } - get outbox(): core.Outbox { + get outbox(): Outbox { if (!this.providerOrSigner) { throw new Error('No provider or signer. Call `connect` first.'); } - return core.Outbox__factory.connect(this._outbox, this.providerOrSigner); + return Outbox__factory.connect(this._outbox, this.providerOrSigner); } - get governanceRouter(): xapps.GovernanceRouter { + get governanceRouter(): GovernanceRouter { if (!this.providerOrSigner) { throw new Error('No provider or signer. Call `connect` first.'); } - return xapps.GovernanceRouter__factory.connect( + return GovernanceRouter__factory.connect( this._governanceRouter, this.providerOrSigner, ); } - get xAppConnectionManager(): core.XAppConnectionManager { + get xAppConnectionManager(): XAppConnectionManager { if (!this.providerOrSigner) { throw new Error('No provider or signer. Call `connect` first.'); } - return core.XAppConnectionManager__factory.connect( + return XAppConnectionManager__factory.connect( this._xAppConnectionManager, this.providerOrSigner, ); diff --git a/typescript/abacus-sdk/src/abacus/events/abacusEvents.ts b/typescript/abacus-sdk/src/abacus/events/abacusEvents.ts index 319a4b349..3a93d95ca 100644 --- a/typescript/abacus-sdk/src/abacus/events/abacusEvents.ts +++ b/typescript/abacus-sdk/src/abacus/events/abacusEvents.ts @@ -2,7 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber'; import { Result } from '@ethersproject/abi'; import { TransactionReceipt } from '@ethersproject/abstract-provider'; -import { TypedEvent } from '@abacus-network/ts-interface/dist/abacus-core/commons'; +import { TypedEvent } from '@abacus-network/core/dist/commons'; // copied from the Outbox.d.ts export type DispatchTypes = [string, BigNumber, BigNumber, string, string]; diff --git a/typescript/abacus-sdk/src/abacus/events/bridgeEvents.ts b/typescript/abacus-sdk/src/abacus/events/bridgeEvents.ts index 7627aba57..712deec8f 100644 --- a/typescript/abacus-sdk/src/abacus/events/bridgeEvents.ts +++ b/typescript/abacus-sdk/src/abacus/events/bridgeEvents.ts @@ -1,4 +1,4 @@ -import { TypedEvent } from '@abacus-network/ts-interface/dist/abacus-core/commons'; +import { TypedEvent } from '@abacus-network/core/dist/commons'; import { BigNumber } from 'ethers'; import { Annotated } from '.'; diff --git a/typescript/abacus-sdk/src/abacus/events/fetch.ts b/typescript/abacus-sdk/src/abacus/events/fetch.ts index 69e4b3071..c8ce6c3fd 100644 --- a/typescript/abacus-sdk/src/abacus/events/fetch.ts +++ b/typescript/abacus-sdk/src/abacus/events/fetch.ts @@ -5,7 +5,7 @@ import { Result } from '@ethersproject/abi'; import { TypedEvent, TypedEventFilter, -} from '@abacus-network/ts-interface/dist/abacus-core/commons'; +} from '@abacus-network/core/dist/commons'; // specifies an interface shared by the TS generated contracts export interface TSContract { diff --git a/typescript/abacus-sdk/src/abacus/messages/AbacusMessage.ts b/typescript/abacus-sdk/src/abacus/messages/AbacusMessage.ts index 8f285734b..b3eaed6a9 100644 --- a/typescript/abacus-sdk/src/abacus/messages/AbacusMessage.ts +++ b/typescript/abacus-sdk/src/abacus/messages/AbacusMessage.ts @@ -1,7 +1,7 @@ import { BigNumber } from '@ethersproject/bignumber'; import { arrayify, hexlify } from '@ethersproject/bytes'; import { TransactionReceipt } from '@ethersproject/abstract-provider'; -import { core } from '@abacus-network/ts-interface'; +import { Inbox, Outbox, Outbox__factory } from '@abacus-network/core'; import { AbacusContext } from '..'; import { delay } from '../../utils'; import { @@ -77,8 +77,8 @@ export function parseMessage(message: string): ParsedMessage { export class AbacusMessage { readonly dispatch: AnnotatedDispatch; readonly message: ParsedMessage; - readonly outbox: core.Outbox; - readonly inbox: core.Inbox; + readonly outbox: Outbox; + readonly inbox: Inbox; readonly context: AbacusContext; protected cache: EventCache; @@ -116,7 +116,7 @@ export class AbacusMessage { receipt: TransactionReceipt, ): AbacusMessage[] { const messages: AbacusMessage[] = []; - const outbox = new core.Outbox__factory().interface; + const outbox = new Outbox__factory().interface; for (const log of receipt.logs) { try { diff --git a/typescript/abacus-sdk/src/abacus/messages/BridgeMessage.ts b/typescript/abacus-sdk/src/abacus/messages/BridgeMessage.ts index 510f8ea7d..c80bdfc17 100644 --- a/typescript/abacus-sdk/src/abacus/messages/BridgeMessage.ts +++ b/typescript/abacus-sdk/src/abacus/messages/BridgeMessage.ts @@ -2,7 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber'; import { arrayify, hexlify } from '@ethersproject/bytes'; import { TransactionReceipt } from '@ethersproject/abstract-provider'; import { ethers } from 'ethers'; -import { xapps } from '@abacus-network/ts-interface'; +import { ERC20 } from '@abacus-network/apps'; import { BridgeContracts, AbacusContext } from '..'; import { ResolvedTokenInfo, TokenIdentifier } from '../tokens'; import { AbacusMessage } from './AbacusMessage'; @@ -301,7 +301,7 @@ class BridgeMessage extends AbacusMessage { * * @returns The resolved token interface. */ - async assetAtOrigin(): Promise { + async assetAtOrigin(): Promise { return (await this.asset()).tokens.get(this.origin); } @@ -314,7 +314,7 @@ class BridgeMessage extends AbacusMessage { * * @returns The resolved token interface. */ - async assetAtDestination(): Promise { + async assetAtDestination(): Promise { return (await this.asset()).tokens.get(this.destination); } } diff --git a/typescript/abacus-sdk/src/abacus/tokens/index.ts b/typescript/abacus-sdk/src/abacus/tokens/index.ts index 48e94946e..c9658dec6 100644 --- a/typescript/abacus-sdk/src/abacus/tokens/index.ts +++ b/typescript/abacus-sdk/src/abacus/tokens/index.ts @@ -1,5 +1,5 @@ import { BytesLike } from 'ethers'; -import { xapps } from '@abacus-network/ts-interface'; +import { BridgeToken } from '@abacus-network/apps'; import wellKnown from './wellKnown'; import testnetWellKnown from './testnetWellKnown'; @@ -14,7 +14,7 @@ export type ResolvedTokenInfo = { // The canonical identifier id: BytesLike; // The contract on each chain - tokens: Map; + tokens: Map; }; export const tokens = wellKnown; diff --git a/typescript/abacus-sdk/tsconfig.json b/typescript/abacus-sdk/tsconfig.json index bad5a90f5..4e9200023 100644 --- a/typescript/abacus-sdk/tsconfig.json +++ b/typescript/abacus-sdk/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../tsconfig.package.json", + "extends": "../../tsconfig.package.json", "compilerOptions": { "outDir": "./dist/", "rootDir": "./src/" diff --git a/typescript/contract-metrics/.gitignore b/typescript/contract-metrics/.gitignore index 538f22695..a94aee37d 100644 --- a/typescript/contract-metrics/.gitignore +++ b/typescript/contract-metrics/.gitignore @@ -1,4 +1,3 @@ dist/ unprocessed/ -tsconfig.tsbuildinfo credentials.json diff --git a/typescript/contract-metrics/package.json b/typescript/contract-metrics/package.json index 5e41d6df8..2658a38cd 100644 --- a/typescript/contract-metrics/package.json +++ b/typescript/contract-metrics/package.json @@ -7,13 +7,13 @@ "value": "ts-node src/value.ts | ./node_modules/.bin/bunyan", "trace": "ts-node src/trace.ts", "gas": "ts-node src/gas.ts", - "build": "rm tsconfig.tsbuildinfo & tsc", - "check": "rm tsconfig.tsbuildinfo & tsc --noEmit", + "build": "tsc", + "check": "tsc --noEmit", "prettier": "prettier --write ." }, "dependencies": { + "@abacus-network/apps": "file:../../solidity/apps", "@abacus-network/sdk": "^0.0.1", - "@abacus-network/ts-interface": "file:../typechain", "@types/bunyan": "^1.8.7", "@types/express": "^4.17.13", "@types/google-spreadsheet": "^3.1.5", diff --git a/typescript/contract-metrics/src/monitor/governance.ts b/typescript/contract-metrics/src/monitor/governance.ts index 195f0c2f0..a3d0a9209 100644 --- a/typescript/contract-metrics/src/monitor/governance.ts +++ b/typescript/contract-metrics/src/monitor/governance.ts @@ -1,5 +1,5 @@ import { AbacusContext } from '@abacus-network/sdk'; -import { xapps } from '@abacus-network/ts-interface'; +import { GovernanceRouter } from '@abacus-network/apps'; import config from '../config'; export async function monitorGovernance( @@ -16,7 +16,7 @@ export async function monitorGovernance( async function monitorRecoveryActiveAt( network: string, - router: xapps.GovernanceRouter, + router: GovernanceRouter, ) { const logger = config.baseLogger.child({ network, diff --git a/typescript/contract-metrics/tsconfig.json b/typescript/contract-metrics/tsconfig.json index ff4499866..c50f71520 100644 --- a/typescript/contract-metrics/tsconfig.json +++ b/typescript/contract-metrics/tsconfig.json @@ -4,6 +4,6 @@ "rootDir": "./src/" }, "exclude": ["./node_modules/", "./dist/", "./tmp.ts"], - "extends": "../tsconfig.package.json", + "extends": "../../tsconfig.package.json", "include": ["./src/*.ts", "./src/**/*.ts"] } diff --git a/typescript/hardhat/package.json b/typescript/hardhat/package.json index 649b2536e..fd64a05fe 100644 --- a/typescript/hardhat/package.json +++ b/typescript/hardhat/package.json @@ -3,17 +3,16 @@ "name": "@abacus-network/hardhat", "version": "0.0.5", "description": "Abacus hardhat tools", - "main": "dist/src/index.js", - "types": "dist/src/index.d.ts", + "main": "dist/index.js", + "types": "dist/index.d.ts", "scripts": { "build": "tsc", "check": "tsc --noEmit", "prettier": "prettier --write ./src" }, - "author": "Celo Labs Inc.", "license": "MIT OR Apache-2.0", "dependencies": { - "@abacus-network/abacus-sol": "^0.0.0", + "@abacus-network/core": "file:../../solidity/core", "@abacus-network/utils": "^0.0.5", "@nomiclabs/hardhat-ethers": "^2.0.5", "@nomiclabs/hardhat-waffle": "^2.0.2", diff --git a/typescript/hardhat/src/TestAbacusDeploy.ts b/typescript/hardhat/src/TestAbacusDeploy.ts index 30b2f4faf..3fb0d2f2c 100644 --- a/typescript/hardhat/src/TestAbacusDeploy.ts +++ b/typescript/hardhat/src/TestAbacusDeploy.ts @@ -11,8 +11,8 @@ import { XAppConnectionManager__factory, TestInbox, TestInbox__factory, -} from "@abacus-network/abacus-sol/typechain"; -import { Validator } from "@abacus-network/abacus-sol/test/lib/core"; +} from "@abacus-network/core"; +import { Validator } from "@abacus-network/core/test/lib/core"; import { TestDeploy } from "./TestDeploy"; export type TestAbacusConfig = { diff --git a/typescript/hardhat/tsconfig.json b/typescript/hardhat/tsconfig.json index 5227abd3e..02a6d71dd 100644 --- a/typescript/hardhat/tsconfig.json +++ b/typescript/hardhat/tsconfig.json @@ -4,7 +4,7 @@ "rootDir": "./" }, "exclude": ["./node_modules/", "./dist/", "./tmp.ts"], - "extends": "../tsconfig.package.json", + "extends": "../../tsconfig.package.json", "include": [ "./index.ts", "./src/*.ts" diff --git a/typescript/typechain/.gitignore b/typescript/typechain/.gitignore deleted file mode 100644 index 5ce95972a..000000000 --- a/typescript/typechain/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.env -dist -abacus-core/* -abacus-xapps/* diff --git a/typescript/typechain/.npmignore b/typescript/typechain/.npmignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/typescript/typechain/index.ts b/typescript/typechain/index.ts deleted file mode 100644 index 734ea77e6..000000000 --- a/typescript/typechain/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * as core from "./abacus-core"; -export * as xapps from "./abacus-xapps"; diff --git a/typescript/typechain/package.json b/typescript/typechain/package.json deleted file mode 100644 index ea2038735..000000000 --- a/typescript/typechain/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "scripts": { - "build": "tsc && npm run copy-files", - "check": "tsc --noEmit", - "copy-files": "cp abacus-core/*.d.ts dist/abacus-core && cp abacus-xapps/*.d.ts dist/abacus-xapps" - }, - "devDependencies": { - "ethers": "^5.5.3" - }, - "name": "@abacus-network/ts-interface", - "version": "0.0.1", - "description": "Abacus contract typechain gens", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "author": "Celo Labs Inc.", - "license": "MIT OR Apache-2.0", - "prepublish": "npm run build", - "dependencies": { - "@ethersproject/experimental": "^5.5.0", - "@types/node": "^16.11.21", - "typescript": "^4.5.5" - } -} diff --git a/typescript/typechain/tsconfig.json b/typescript/typechain/tsconfig.json deleted file mode 100644 index 86cfa245a..000000000 --- a/typescript/typechain/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "outDir": "./dist/", - "rootDir": "./" - }, - "exclude": [ - "./node_modules/", - "./dist/", - "./abacus-core/hardhat.d.ts", - "./abacus-xapps/hardhat.d.ts" - ], - "extends": "../tsconfig.package.json", - "include": [ - "./index.ts", - "./abacus-core/*.ts", - "./abacus-xapps/*.ts", - "./abacus-core/factories/*.ts", - "./abacus-xapps/factories/*.ts" - ] -} diff --git a/typescript/utils/package.json b/typescript/utils/package.json index f86d8808c..8a4b08622 100644 --- a/typescript/utils/package.json +++ b/typescript/utils/package.json @@ -3,8 +3,8 @@ "name": "@abacus-network/utils", "version": "0.0.5", "description": "Abacus utilities", - "main": "dist/src/index.js", - "types": "dist/src/index.d.ts", + "main": "dist/index.js", + "types": "dist/index.d.ts", "scripts": { "build": "tsc", "check": "tsc --noEmit", diff --git a/typescript/utils/tsconfig.json b/typescript/utils/tsconfig.json index 5227abd3e..02a6d71dd 100644 --- a/typescript/utils/tsconfig.json +++ b/typescript/utils/tsconfig.json @@ -4,7 +4,7 @@ "rootDir": "./" }, "exclude": ["./node_modules/", "./dist/", "./tmp.ts"], - "extends": "../tsconfig.package.json", + "extends": "../../tsconfig.package.json", "include": [ "./index.ts", "./src/*.ts"