From 86f280e826f73f656c383f1dce0c44f34fc99dbd Mon Sep 17 00:00:00 2001 From: J M Rossy Date: Tue, 5 Jul 2022 14:59:44 -0400 Subject: [PATCH] Merge SDK + Hardhat + Deploy packages (#643) - Merge hardhat package into SDK - Merge deploy package into SDK - Reorganize SDK consts and utils - Rename TestCoreDeploy -> TestCoreDeployer - Rename some file names to their class names - Remove runtime dependencies on Chai and Yargs - Replace Axios dep with cross-fetch - Setup type shorthand for Address type in SDK - Update infra package - Fix deploy's hardhat tests - Fix incorrect test in AbacusCoreChecker - Colocate tests into SDK src - Add instructions for publishing - Bump version to 0.3.1 and publish --- .github/workflows/node.yml | 2 - Dockerfile | 2 - README.md | 34 ++++- package.json | 7 +- solidity/app/package.json | 8 +- solidity/core/package.json | 6 +- typescript/deploy/.gitignore | 3 - typescript/deploy/.prettierignore | 2 - typescript/deploy/package.json | 42 ------ typescript/deploy/src/index.ts | 21 --- typescript/deploy/src/router/index.ts | 3 - typescript/deploy/src/utils.ts | 42 ------ typescript/deploy/src/verify/index.ts | 3 - typescript/deploy/tsconfig.json | 15 -- typescript/hardhat/.gitignore | 2 - typescript/hardhat/.prettierrc | 5 - typescript/hardhat/index.ts | 40 ----- typescript/hardhat/package.json | 45 ------ typescript/hardhat/tsconfig.json | 9 -- .../infra/config/environments/dev/core.ts | 3 +- .../infra/config/environments/mainnet/core.ts | 3 +- .../infra/config/environments/test/core.ts | 3 +- .../infra/config/environments/test/index.ts | 4 +- .../infra/config/environments/testnet/core.ts | 3 +- .../config/environments/testnet2/core.ts | 3 +- typescript/infra/hardhat.config.ts | 4 +- typescript/infra/package.json | 9 +- typescript/infra/scripts/check-deploy.ts | 3 +- .../funding/fund-relayers-from-deployer.ts | 6 +- typescript/infra/scripts/helloworld/deploy.ts | 4 +- typescript/infra/scripts/helloworld/utils.ts | 9 +- typescript/infra/scripts/utils.ts | 21 ++- typescript/infra/src/config/environment.ts | 9 +- typescript/infra/src/core/deploy.ts | 8 +- typescript/infra/src/verify.ts | 7 +- typescript/infra/test/core.test.ts | 8 +- typescript/{hardhat => sdk}/hardhat.config.ts | 0 typescript/sdk/package.json | 34 +++-- typescript/sdk/src/{app.ts => AbacusApp.ts} | 2 +- .../chainConnectionConfigs.ts} | 16 +- .../chainMetadata.ts} | 24 ++- typescript/sdk/src/consts/chains.ts | 26 ++++ .../{core => consts}/environments/dev.json | 0 .../{core => consts}/environments/index.ts | 0 .../environments/mainnet.json | 0 .../{core => consts}/environments/test.json | 0 .../environments/testnet.json | 0 .../environments/testnet2.json | 0 typescript/sdk/src/{ => consts}/metamask.ts | 0 typescript/sdk/src/contracts.ts | 2 +- .../sdk/src/core/{app.ts => AbacusCore.ts} | 6 +- .../src => sdk/src/core}/TestCoreApp.ts | 29 ++-- .../src/core/TestCoreDeployer.ts} | 31 ++-- typescript/sdk/src/core/index.ts | 21 --- typescript/sdk/src/core/message.ts | 24 ++- .../core/testAbacusDeploy.hardhat-test.ts} | 37 +++-- typescript/{ => sdk/src}/deploy/.eslintrc | 0 .../src/deploy/AbacusAppChecker.ts} | 35 ++--- .../src/deploy/AbacusDeployer.ts} | 22 ++- .../src/deploy/core/AbacusCoreChecker.ts} | 83 ++++------ .../src/deploy/core/AbacusCoreDeployer.ts} | 44 +++--- typescript/sdk/src/deploy/core/types.ts | 35 +++++ .../{deploy/src => sdk/src/deploy}/proxy.ts | 8 +- .../src/deploy/router/AbacusRouterChecker.ts} | 21 +-- .../deploy/router/AbacusRouterDeployer.ts} | 33 ++-- .../src => sdk/src/deploy}/router/types.ts | 5 +- .../src/config.ts => sdk/src/deploy/types.ts} | 2 +- typescript/sdk/src/deploy/utils.ts | 20 +++ .../src/deploy}/verify/ContractVerifier.ts | 37 +++-- .../src => sdk/src/deploy}/verify/types.ts | 0 .../src => sdk/src/deploy}/verify/utils.ts | 8 +- typescript/sdk/src/domains.ts | 11 ++ typescript/sdk/src/ethers/index.ts | 1 - typescript/sdk/src/events.ts | 10 +- .../sdk/{test => src}/gas/calculator.test.ts | 18 +-- typescript/sdk/src/gas/calculator.ts | 6 +- typescript/sdk/src/gas/index.ts | 2 - typescript/sdk/src/index.ts | 129 ++++++++++------ .../ChainConnection.ts} | 31 +--- typescript/sdk/src/providers/MultiProvider.ts | 24 +++ .../RetryProvider.ts} | 17 +-- typescript/sdk/src/proxy.ts | 2 +- typescript/sdk/src/router.ts | 4 +- typescript/sdk/src/test/.eslintrc | 5 + .../{test/utils.ts => src/test/testUtils.ts} | 2 +- typescript/sdk/src/types.ts | 62 ++------ typescript/sdk/src/utils.ts | 142 ------------------ typescript/sdk/src/utils/.eslintrc | 5 + typescript/sdk/src/utils/MultiGeneric.ts | 44 ++++++ typescript/sdk/src/utils/ids.ts | 41 +++++ typescript/sdk/src/utils/index.ts | 6 + .../sdk/src/{gas/utils.ts => utils/number.ts} | 0 typescript/sdk/src/utils/objects.ts | 29 ++++ typescript/sdk/src/utils/sets.ts | 11 ++ typescript/sdk/src/utils/time.ts | 11 ++ .../sdk/{test => src/utils}/utils.test.ts | 2 +- typescript/sdk/tsconfig.json | 3 +- typescript/utils/package.json | 5 +- typescript/utils/src/utils.ts | 26 ++-- yarn.lock | 106 +++++-------- 100 files changed, 802 insertions(+), 956 deletions(-) delete mode 100644 typescript/deploy/.gitignore delete mode 100644 typescript/deploy/.prettierignore delete mode 100644 typescript/deploy/package.json delete mode 100644 typescript/deploy/src/index.ts delete mode 100644 typescript/deploy/src/router/index.ts delete mode 100644 typescript/deploy/src/utils.ts delete mode 100644 typescript/deploy/src/verify/index.ts delete mode 100644 typescript/deploy/tsconfig.json delete mode 100644 typescript/hardhat/.gitignore delete mode 100644 typescript/hardhat/.prettierrc delete mode 100644 typescript/hardhat/index.ts delete mode 100644 typescript/hardhat/package.json delete mode 100644 typescript/hardhat/tsconfig.json rename typescript/{hardhat => sdk}/hardhat.config.ts (100%) rename typescript/sdk/src/{app.ts => AbacusApp.ts} (94%) rename typescript/sdk/src/{chains.ts => consts/chainConnectionConfigs.ts} (91%) rename typescript/sdk/src/{chain-metadata.ts => consts/chainMetadata.ts} (87%) create mode 100644 typescript/sdk/src/consts/chains.ts rename typescript/sdk/src/{core => consts}/environments/dev.json (100%) rename typescript/sdk/src/{core => consts}/environments/index.ts (100%) rename typescript/sdk/src/{core => consts}/environments/mainnet.json (100%) rename typescript/sdk/src/{core => consts}/environments/test.json (100%) rename typescript/sdk/src/{core => consts}/environments/testnet.json (100%) rename typescript/sdk/src/{core => consts}/environments/testnet2.json (100%) rename typescript/sdk/src/{ => consts}/metamask.ts (100%) rename typescript/sdk/src/core/{app.ts => AbacusCore.ts} (94%) rename typescript/{hardhat/src => sdk/src/core}/TestCoreApp.ts (84%) rename typescript/{hardhat/src/TestCoreDeploy.ts => sdk/src/core/TestCoreDeployer.ts} (83%) delete mode 100644 typescript/sdk/src/core/index.ts rename typescript/{hardhat/test/testAbacusDeploy.test.ts => sdk/src/core/testAbacusDeploy.hardhat-test.ts} (72%) rename typescript/{ => sdk/src}/deploy/.eslintrc (100%) rename typescript/{deploy/src/check.ts => sdk/src/deploy/AbacusAppChecker.ts} (73%) rename typescript/{deploy/src/deploy.ts => sdk/src/deploy/AbacusDeployer.ts} (94%) rename typescript/{deploy/src/core/check.ts => sdk/src/deploy/core/AbacusCoreChecker.ts} (81%) rename typescript/{deploy/src/core/deploy.ts => sdk/src/deploy/core/AbacusCoreDeployer.ts} (90%) create mode 100644 typescript/sdk/src/deploy/core/types.ts rename typescript/{deploy/src => sdk/src/deploy}/proxy.ts (83%) rename typescript/{deploy/src/router/check.ts => sdk/src/deploy/router/AbacusRouterChecker.ts} (70%) rename typescript/{deploy/src/router/deploy.ts => sdk/src/deploy/router/AbacusRouterDeployer.ts} (81%) rename typescript/{deploy/src => sdk/src/deploy}/router/types.ts (52%) rename typescript/{deploy/src/config.ts => sdk/src/deploy/types.ts} (74%) create mode 100644 typescript/sdk/src/deploy/utils.ts rename typescript/{deploy/src => sdk/src/deploy}/verify/ContractVerifier.ts (78%) rename typescript/{deploy/src => sdk/src/deploy}/verify/types.ts (100%) rename typescript/{deploy/src => sdk/src/deploy}/verify/utils.ts (87%) create mode 100644 typescript/sdk/src/domains.ts delete mode 100644 typescript/sdk/src/ethers/index.ts rename typescript/sdk/{test => src}/gas/calculator.test.ts (95%) delete mode 100644 typescript/sdk/src/gas/index.ts rename typescript/sdk/src/{provider.ts => providers/ChainConnection.ts} (61%) create mode 100644 typescript/sdk/src/providers/MultiProvider.ts rename typescript/sdk/src/{ethers/retry-provider.ts => providers/RetryProvider.ts} (74%) create mode 100644 typescript/sdk/src/test/.eslintrc rename typescript/sdk/{test/utils.ts => src/test/testUtils.ts} (97%) delete mode 100644 typescript/sdk/src/utils.ts create mode 100644 typescript/sdk/src/utils/.eslintrc create mode 100644 typescript/sdk/src/utils/MultiGeneric.ts create mode 100644 typescript/sdk/src/utils/ids.ts create mode 100644 typescript/sdk/src/utils/index.ts rename typescript/sdk/src/{gas/utils.ts => utils/number.ts} (100%) create mode 100644 typescript/sdk/src/utils/objects.ts create mode 100644 typescript/sdk/src/utils/sets.ts create mode 100644 typescript/sdk/src/utils/time.ts rename typescript/sdk/{test => src/utils}/utils.test.ts (94%) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index e8b2f4c4d..02d7126ef 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -90,8 +90,6 @@ jobs: run: yarn workspace @abacus-network/sdk run test - name: infra run: yarn workspace @abacus-network/infra run test - - name: hardhat - run: yarn workspace @abacus-network/hardhat run test test-sol: env: diff --git a/Dockerfile b/Dockerfile index ca3f1bc93..41b6e04bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,9 +12,7 @@ COPY package.json yarn.lock .yarnrc.yml ./ COPY .yarn/plugins ./.yarn/plugins COPY .yarn/releases ./.yarn/releases COPY typescript/utils/package.json ./typescript/utils/ -COPY typescript/hardhat/package.json ./typescript/hardhat/ COPY typescript/sdk/package.json ./typescript/sdk/ -COPY typescript/deploy/package.json ./typescript/deploy/ COPY typescript/infra/package.json ./typescript/infra/ COPY solidity/core/package.json ./solidity/core/ COPY solidity/app/package.json ./solidity/app/ diff --git a/README.md b/README.md index 816c8aa39..7e2800748 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,6 @@ This monorepo uses [Yarn Workspaces](https://yarnpkg.com/features/workspaces). I yarn build ``` -- Running prettier - - ```bash - yarn prettier - ``` - If you are using [VSCode](https://code.visualstudio.com/), you can launch the [multi-root workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces) with `code mono.code-workspace`, install the recommended workspace extensions, and use the editor settings. ### Rust @@ -53,7 +47,7 @@ cd rust ./release.sh ``` -## Deploy Procedure +#### Deploy Procedure The contract addresses of each deploy can be found in `rust/config`. The latest deploy will be at `rust/config/[latest timestamp]` with bridge contracts within @@ -68,3 +62,29 @@ messages will not be relayed between chains). Off-chain agents are **not** automatically re-deployed when new contract deploys are merged. Auto-redeploys will be implemented at some future date. + +### Publishing Packages + +Packages can be versioned and published all at once with commands from the root. + +First, increment the version to the desired value: + +```bash +# An example of a prerelease version +yarn version:prepare 0.5.0-beta0 +# Or for a release which increments the minor version +yarn version:prepare minor +``` + +Next, ensure packages are cleaned and rebuilt: + +```bash +yarn clean && yarn build +``` + +Finally, publish the packages to NPM + +```bash +# Note: If you have not yet logged in, first run yarn npm login +yarn publish:all --otp YOUR_OTP_HERE +``` diff --git a/package.json b/package.json index 6830347ea..80948c0d2 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,14 @@ "private": true, "scripts": { "build": "yarn workspaces foreach --verbose --parallel --topological run build", - "publish": "yarn workspaces foreach --no-private --verbose --topological npm publish --access public", + "clean": "yarn workspaces foreach --verbose --parallel run clean", "postinstall": "husky install", "prettier": "yarn workspaces foreach --verbose --parallel run prettier", "lint-ts": "eslint . --ext .ts", - "test": "yarn workspaces foreach --verbose --parallel run test" + "test": "yarn workspaces foreach --verbose --parallel run test", + "version:check": "yarn version check --interactive", + "version:prepare": "yarn workspaces foreach --no-private --verbose --topological version --immediate", + "publish:all": "yarn workspaces foreach --no-private --verbose --topological npm publish --access public" }, "workspaces": [ "solidity/*", diff --git a/solidity/app/package.json b/solidity/app/package.json index 48bcabac7..16e5862db 100644 --- a/solidity/app/package.json +++ b/solidity/app/package.json @@ -1,10 +1,10 @@ { "name": "@abacus-network/app", "description": "Solidity contracts for Abacus apps", - "version": "0.2.3", + "version": "0.3.1", "dependencies": { - "@abacus-network/core": "^0.2.3", - "@abacus-network/utils": "^0.2.3", + "@abacus-network/core": "0.3.1", + "@abacus-network/utils": "0.3.1", "@openzeppelin/contracts-upgradeable": "^4.5.0" }, "devDependencies": { @@ -45,7 +45,7 @@ "repository": "https://github.com/abacus-network/abacus-monorepo", "scripts": { "build": "hardhat compile && tsc", - "clean": "hardhat clean", + "clean": "hardhat clean && rm -rf ./dist ./cache", "coverage": "hardhat coverage", "prettier": "prettier --write ./contracts ./test", "test": "hardhat test" diff --git a/solidity/core/package.json b/solidity/core/package.json index c7006d79f..041b0e759 100644 --- a/solidity/core/package.json +++ b/solidity/core/package.json @@ -1,9 +1,9 @@ { "name": "@abacus-network/core", "description": "Core solidity contracts for Abacus", - "version": "0.2.3", + "version": "0.3.1", "dependencies": { - "@abacus-network/utils": "^0.2.3", + "@abacus-network/utils": "0.3.1", "@openzeppelin/contracts": "^4.6.0", "@openzeppelin/contracts-upgradeable": "^4.6.0", "@summa-tx/memview-sol": "^2.0.0" @@ -45,7 +45,7 @@ "repository": "https://github.com/abacus-network/abacus-monorepo", "scripts": { "build": "hardhat compile && tsc", - "clean": "hardhat clean", + "clean": "hardhat clean && rm -rf ./dist ./cache", "coverage": "hardhat coverage", "prettier": "prettier --write ./contracts ./interfaces ./test", "test": "hardhat test" diff --git a/typescript/deploy/.gitignore b/typescript/deploy/.gitignore deleted file mode 100644 index bfefb47d1..000000000 --- a/typescript/deploy/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules/ -dist/ -*.swo diff --git a/typescript/deploy/.prettierignore b/typescript/deploy/.prettierignore deleted file mode 100644 index 0a7f2e4e6..000000000 --- a/typescript/deploy/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -**/helm - diff --git a/typescript/deploy/package.json b/typescript/deploy/package.json deleted file mode 100644 index c61bd598c..000000000 --- a/typescript/deploy/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "@abacus-network/deploy", - "description": "Deploy tools for the Abacus network", - "version": "0.2.3", - "dependencies": { - "@abacus-network/app": "^0.2.3", - "@abacus-network/core": "^0.2.3", - "@abacus-network/sdk": "^0.2.3", - "@abacus-network/utils": "^0.2.3", - "@types/debug": "^4.1.7", - "@types/yargs": "^17.0.10", - "axios": "^0.21.3", - "debug": "^4.3.4", - "yargs": "^17.4.1" - }, - "devDependencies": { - "@types/node": "^16.9.1", - "ethers": "^5.6.8", - "prettier": "^2.4.1", - "ts-node": "^10.8.0", - "typescript": "^4.7.2" - }, - "homepage": "https://www.useabacus.network", - "keywords": [ - "Abacus", - "Typescript", - "Deployment" - ], - "license": "Apache-2.0", - "main": "dist/src/index.js", - "prepublish": "yarn build", - "repository": "https://github.com/abacus-network/abacus-monorepo", - "scripts": { - "build": "tsc", - "check": "tsc --noEmit", - "prettier": "prettier --write ./src" - }, - "types": "dist/src/index.d.ts", - "files": [ - "/dist" - ] -} diff --git a/typescript/deploy/src/index.ts b/typescript/deploy/src/index.ts deleted file mode 100644 index 269d7c005..000000000 --- a/typescript/deploy/src/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -export { AbacusAppChecker, Ownable } from './check'; -export { CheckerViolation, EnvironmentConfig } from './config'; -export { - AbacusCoreDeployer, - CoreConfig, - ValidatorManagerConfig, -} from './core/deploy'; -export { AbacusCoreChecker } from './core/check'; -export { AbacusDeployer } from './deploy'; -export { UpgradeBeaconViolation } from './proxy'; -export { - AbacusRouterChecker, - AbacusRouterDeployer, - RouterConfig, -} from './router'; -export * as utils from './utils'; -export { - ContractVerifier, - getConstructorArguments, - VerificationInput, -} from './verify'; diff --git a/typescript/deploy/src/router/index.ts b/typescript/deploy/src/router/index.ts deleted file mode 100644 index c4109a2ca..000000000 --- a/typescript/deploy/src/router/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { AbacusRouterChecker } from './check'; -export { AbacusRouterDeployer } from './deploy'; -export { RouterConfig } from './types'; diff --git a/typescript/deploy/src/utils.ts b/typescript/deploy/src/utils.ts deleted file mode 100644 index 2c853bacb..000000000 --- a/typescript/deploy/src/utils.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { ethers } from 'ethers'; -import yargs from 'yargs'; - -import { ChainName, MultiProvider, objMap } from '@abacus-network/sdk'; - -import { EnvironmentConfig } from './config'; - -export function getArgs() { - return yargs(process.argv.slice(2)) - .alias('e', 'env') - .describe('e', 'deploy environment') - .string('e') - .help('h') - .alias('h', 'help'); -} - -export async function getEnvironment(): Promise { - return (await getArgs().argv).e as string; -} - -export const getMultiProviderFromConfigAndSigner = ( - environmentConfig: EnvironmentConfig, - signer: ethers.Signer, -): MultiProvider => { - const chainProviders = objMap(environmentConfig, (_, config) => ({ - provider: signer.provider!, - signer, - confirmations: config.confirmations, - overrides: config.overrides, - })); - return new MultiProvider(chainProviders); -}; - -// Returns a \ b -// Taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#implementing_basic_set_operations -export function setDifference(a: Set, b: Set) { - const diff = new Set(a); - for (const element of b) { - diff.delete(element); - } - return diff; -} diff --git a/typescript/deploy/src/verify/index.ts b/typescript/deploy/src/verify/index.ts deleted file mode 100644 index 55d843efd..000000000 --- a/typescript/deploy/src/verify/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { ContractVerifier } from './ContractVerifier'; -export { ContractVerificationInput, VerificationInput } from './types'; -export { getConstructorArguments, getContractVerificationInput } from './utils'; diff --git a/typescript/deploy/tsconfig.json b/typescript/deploy/tsconfig.json deleted file mode 100644 index 4f2e2f5a5..000000000 --- a/typescript/deploy/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "outDir": "./dist/", - "rootDir": "./" - }, - "exclude": ["./node_modules/", "./dist/", "./tmp.ts"], - "extends": "../../tsconfig.json", - "include": [ - "./*.ts", - "./config/**/*.ts", - "./scripts/**/*.ts", - "./src/**/*.ts", - "./test/**/*.ts" - ] -} diff --git a/typescript/hardhat/.gitignore b/typescript/hardhat/.gitignore deleted file mode 100644 index 518e15986..000000000 --- a/typescript/hardhat/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -dist/ -cache/ diff --git a/typescript/hardhat/.prettierrc b/typescript/hardhat/.prettierrc deleted file mode 100644 index 8d6ce6a7e..000000000 --- a/typescript/hardhat/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "tabWidth": 2, - "singleQuote": true, - "trailingComma": "all" -} diff --git a/typescript/hardhat/index.ts b/typescript/hardhat/index.ts deleted file mode 100644 index 4f8e17471..000000000 --- a/typescript/hardhat/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { MultiProvider, TestChainNames } from '@abacus-network/sdk'; -import '@nomiclabs/hardhat-waffle'; -import { ethers } from 'ethers'; -import { extendEnvironment } from 'hardhat/config'; -import { lazyObject } from "hardhat/plugins"; -import 'hardhat/types/runtime'; -import { TestCoreDeploy } from './src/TestCoreDeploy'; - -declare module 'hardhat/types/runtime' { - interface HardhatRuntimeEnvironment { - abacus: TestCoreDeploy; - } -} - -export function hardhatMultiProvider( - provider: ethers.providers.Provider, - signer?: ethers.Signer, -): MultiProvider { - return new MultiProvider({ - test1: { - provider, - signer, - }, - test2: { - provider, - signer, - }, - test3: { - provider, - signer, - }, - }); -} - -// HardhatRuntimeEnvironment -extendEnvironment((hre) => { - hre.abacus = lazyObject( - () => new TestCoreDeploy(hardhatMultiProvider(hre.ethers.provider)), - ); -}); diff --git a/typescript/hardhat/package.json b/typescript/hardhat/package.json deleted file mode 100644 index 0a1758c73..000000000 --- a/typescript/hardhat/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "@abacus-network/hardhat", - "description": "Hardhat related tools for the Abacus network", - "version": "0.2.3", - "dependencies": { - "@abacus-network/core": "^0.2.3", - "@abacus-network/deploy": "^0.2.3", - "@abacus-network/sdk": "^0.2.3", - "@abacus-network/utils": "^0.2.3", - "@nomiclabs/hardhat-ethers": "^2.0.5", - "@nomiclabs/hardhat-waffle": "^2.0.2", - "ethereum-waffle": "^3.2.2", - "ethers": "^5.6.8", - "hardhat": "^2.8.4" - }, - "devDependencies": { - "prettier": "^2.4.1", - "ts-node": "^10.8.0", - "typescript": "^4.7.2" - }, - "directories": { - "src": "src", - "test": "test" - }, - "homepage": "https://www.useabacus.network", - "keywords": [ - "Abacus", - "Typescript", - "Hardhat" - ], - "license": "Apache-2.0", - "main": "dist/index.js", - "prepublish": "yarn build", - "repository": "https://github.com/abacus-network/abacus-monorepo", - "scripts": { - "build": "tsc", - "check": "tsc --noEmit", - "prettier": "prettier --write ./src ./test", - "test": "hardhat test" - }, - "types": "dist/index.d.ts", - "files": [ - "/dist" - ] -} diff --git a/typescript/hardhat/tsconfig.json b/typescript/hardhat/tsconfig.json deleted file mode 100644 index 821816744..000000000 --- a/typescript/hardhat/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "outDir": "./dist/", - "rootDir": "./" - }, - "exclude": ["./node_modules/", "./dist/", "./tmp.ts"], - "extends": "../../tsconfig.json", - "include": ["./index.ts", "./src/*.ts"] -} diff --git a/typescript/infra/config/environments/dev/core.ts b/typescript/infra/config/environments/dev/core.ts index d424fd181..6b6bb917e 100644 --- a/typescript/infra/config/environments/dev/core.ts +++ b/typescript/infra/config/environments/dev/core.ts @@ -1,5 +1,4 @@ -import { CoreConfig } from '@abacus-network/deploy'; -import { ChainMap } from '@abacus-network/sdk'; +import { ChainMap, CoreConfig } from '@abacus-network/sdk'; import { DevChains } from './chains'; diff --git a/typescript/infra/config/environments/mainnet/core.ts b/typescript/infra/config/environments/mainnet/core.ts index 389ce74f5..120c26aeb 100644 --- a/typescript/infra/config/environments/mainnet/core.ts +++ b/typescript/infra/config/environments/mainnet/core.ts @@ -1,5 +1,4 @@ -import { CoreConfig } from '@abacus-network/deploy'; -import { ChainMap } from '@abacus-network/sdk'; +import { ChainMap, CoreConfig } from '@abacus-network/sdk'; import { MainnetChains } from './chains'; diff --git a/typescript/infra/config/environments/test/core.ts b/typescript/infra/config/environments/test/core.ts index 91e5f8eba..931cd4749 100644 --- a/typescript/infra/config/environments/test/core.ts +++ b/typescript/infra/config/environments/test/core.ts @@ -1,5 +1,4 @@ -import { CoreConfig } from '@abacus-network/deploy'; -import { ChainMap } from '@abacus-network/sdk'; +import { ChainMap, CoreConfig } from '@abacus-network/sdk'; import { TestChains } from './chains'; diff --git a/typescript/infra/config/environments/test/index.ts b/typescript/infra/config/environments/test/index.ts index 6ac499405..2a63ab433 100644 --- a/typescript/infra/config/environments/test/index.ts +++ b/typescript/infra/config/environments/test/index.ts @@ -1,6 +1,6 @@ import { JsonRpcProvider } from '@ethersproject/providers'; -import { utils } from '@abacus-network/deploy'; +import { getMultiProviderFromConfigAndSigner } from '@abacus-network/sdk'; import { CoreEnvironmentConfig } from '../../../src/config'; @@ -19,6 +19,6 @@ export const environment: CoreEnvironmentConfig = { getMultiProvider: async () => { const provider = testConfigs.test1.provider! as JsonRpcProvider; const signer = provider.getSigner(0); - return utils.getMultiProviderFromConfigAndSigner(testConfigs, signer); + return getMultiProviderFromConfigAndSigner(testConfigs, signer); }, }; diff --git a/typescript/infra/config/environments/testnet/core.ts b/typescript/infra/config/environments/testnet/core.ts index f39f0ce7e..c14585963 100644 --- a/typescript/infra/config/environments/testnet/core.ts +++ b/typescript/infra/config/environments/testnet/core.ts @@ -1,5 +1,4 @@ -import { CoreConfig } from '@abacus-network/deploy'; -import { ChainMap } from '@abacus-network/sdk'; +import { ChainMap, CoreConfig } from '@abacus-network/sdk'; import { TestnetChains } from './chains'; diff --git a/typescript/infra/config/environments/testnet2/core.ts b/typescript/infra/config/environments/testnet2/core.ts index d8f8f35e4..11a838345 100644 --- a/typescript/infra/config/environments/testnet2/core.ts +++ b/typescript/infra/config/environments/testnet2/core.ts @@ -1,5 +1,4 @@ -import { CoreConfig } from '@abacus-network/deploy'; -import { ChainMap } from '@abacus-network/sdk'; +import { ChainMap, CoreConfig } from '@abacus-network/sdk'; import { TestnetChains } from './chains'; diff --git a/typescript/infra/hardhat.config.ts b/typescript/infra/hardhat.config.ts index e83c4d894..587906c94 100644 --- a/typescript/infra/hardhat.config.ts +++ b/typescript/infra/hardhat.config.ts @@ -4,11 +4,11 @@ import { task } from 'hardhat/config'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { TestSendReceiver__factory } from '@abacus-network/core'; -import { utils as deployUtils } from '@abacus-network/deploy'; import { AbacusCore, ChainName, ChainNameToDomainId, + getMultiProviderFromConfigAndSigner, } from '@abacus-network/sdk'; import { getCoreEnvironmentConfig } from './scripts/utils'; @@ -64,7 +64,7 @@ task('kathy', 'Dispatches random abacus messages') const interchainGasPayment = hre.ethers.utils.parseUnits('100', 'gwei'); const config = getCoreEnvironmentConfig(environment); const [signer] = await hre.ethers.getSigners(); - const multiProvider = deployUtils.getMultiProviderFromConfigAndSigner( + const multiProvider = getMultiProviderFromConfigAndSigner( config.transactionConfigs, signer, ); diff --git a/typescript/infra/package.json b/typescript/infra/package.json index 155ced302..3caf03674 100644 --- a/typescript/infra/package.json +++ b/typescript/infra/package.json @@ -1,13 +1,11 @@ { "name": "@abacus-network/infra", "description": "Infrastructure utilities for the Abacus Network", - "version": "0.2.3", + "version": "0.3.1", "dependencies": { "@abacus-network/celo-ethers-provider": "^0.1.0", - "@abacus-network/core": "^0.2.3", - "@abacus-network/deploy": "^0.2.3", - "@abacus-network/helloworld": "0.2.4", - "@abacus-network/sdk": "^0.2.3", + "@abacus-network/helloworld": "0.3.1-beta0", + "@abacus-network/sdk": "0.3.1", "@aws-sdk/client-iam": "^3.74.0", "@aws-sdk/client-kms": "3.48.0", "@aws-sdk/client-s3": "^3.74.0", @@ -45,6 +43,7 @@ "scripts": { "abacus": "ts-node scripts/core.ts -e test", "build": "tsc", + "clean": "rm -rf ./dist ./cache", "check": "tsc --noEmit", "kathy": "hardhat kathy --network localhost", "node": "hardhat node", diff --git a/typescript/infra/scripts/check-deploy.ts b/typescript/infra/scripts/check-deploy.ts index 7fb5eca1e..5709ba6c1 100644 --- a/typescript/infra/scripts/check-deploy.ts +++ b/typescript/infra/scripts/check-deploy.ts @@ -1,5 +1,4 @@ -import { AbacusCoreChecker } from '@abacus-network/deploy'; -import { AbacusCore } from '@abacus-network/sdk'; +import { AbacusCore, AbacusCoreChecker } from '@abacus-network/sdk'; import { getCoreEnvironmentConfig, getEnvironment } from './utils'; diff --git a/typescript/infra/scripts/funding/fund-relayers-from-deployer.ts b/typescript/infra/scripts/funding/fund-relayers-from-deployer.ts index c1ee2ce0a..be6cc35bf 100644 --- a/typescript/infra/scripts/funding/fund-relayers-from-deployer.ts +++ b/typescript/infra/scripts/funding/fund-relayers-from-deployer.ts @@ -1,14 +1,13 @@ import { Console } from 'console'; import { ethers } from 'ethers'; -import { utils } from '@abacus-network/deploy'; import { ChainConnection, CompleteChainMap } from '@abacus-network/sdk'; import { AgentKey, ReadOnlyAgentKey } from '../../src/agents/agent'; import { getRelayerKeys } from '../../src/agents/key-utils'; import { KEY_ROLE_ENUM } from '../../src/agents/roles'; import { readJSONAtPath } from '../../src/utils/utils'; -import { assertEnvironment, getCoreEnvironmentConfig } from '../utils'; +import { assertEnvironment, getArgs, getCoreEnvironmentConfig } from '../utils'; // Min delta is 1/10 of the desired balance const MIN_DELTA_NUMERATOR = ethers.BigNumber.from(1); @@ -97,8 +96,7 @@ async function fundRelayer( } async function main() { - const argv = await utils - .getArgs() + const argv = await getArgs() .alias('f', 'addresses-file') .describe( 'f', diff --git a/typescript/infra/scripts/helloworld/deploy.ts b/typescript/infra/scripts/helloworld/deploy.ts index f22cb0ea3..c99066d8e 100644 --- a/typescript/infra/scripts/helloworld/deploy.ts +++ b/typescript/infra/scripts/helloworld/deploy.ts @@ -1,10 +1,10 @@ import path from 'path'; -import { HelloWorldDeployer } from '@abacus-network/helloworld'; import { HelloWorldContracts, + HelloWorldDeployer, helloWorldFactories, -} from '@abacus-network/helloworld/dist/sdk/contracts'; +} from '@abacus-network/helloworld'; import { AbacusCore, ChainMap, diff --git a/typescript/infra/scripts/helloworld/utils.ts b/typescript/infra/scripts/helloworld/utils.ts index d6db43a4f..984f5767f 100644 --- a/typescript/infra/scripts/helloworld/utils.ts +++ b/typescript/infra/scripts/helloworld/utils.ts @@ -1,11 +1,14 @@ -import { RouterConfig } from '@abacus-network/deploy'; -import { HelloWorldApp, HelloWorldContracts } from '@abacus-network/helloworld'; -import { helloWorldFactories } from '@abacus-network/helloworld/dist/sdk/contracts'; +import { + HelloWorldApp, + HelloWorldContracts, + helloWorldFactories, +} from '@abacus-network/helloworld'; import { AbacusCore, ChainMap, ChainName, MultiProvider, + RouterConfig, buildContracts, objMap, promiseObjAll, diff --git a/typescript/infra/scripts/utils.ts b/typescript/infra/scripts/utils.ts index 7f4d53aae..d8c495c23 100644 --- a/typescript/infra/scripts/utils.ts +++ b/typescript/infra/scripts/utils.ts @@ -1,6 +1,6 @@ import path from 'path'; +import yargs from 'yargs'; -import { utils } from '@abacus-network/deploy'; import { AllChains, ChainMap, @@ -18,6 +18,20 @@ import { CoreEnvironmentConfig } from '../src/config'; import { fetchProvider, fetchSigner } from '../src/config/chain'; import { EnvironmentNames } from '../src/config/environment'; +export function getArgs() { + return yargs(process.argv.slice(2)) + .alias('e', 'env') + .describe('e', 'deploy environment') + .string('e') + .help('h') + .alias('h', 'help'); +} + +export async function getEnvironmentFromArgs(): Promise { + const argv = await getArgs().argv; + return argv.e!; +} + export function assertEnvironment(env: string): DeployEnvironment { if (EnvironmentNames.includes(env)) { return env as DeployEnvironment; @@ -34,7 +48,7 @@ export function getCoreEnvironmentConfig( } export async function getEnvironment() { - return assertEnvironment(await utils.getEnvironment()); + return assertEnvironment(await getEnvironmentFromArgs()); } export async function getEnvironmentConfig() { @@ -84,8 +98,7 @@ export function getCoreRustDirectory(environment: DeployEnvironment) { } export function getKeyRoleAndChainArgs() { - return utils - .getArgs() + return getArgs() .alias('r', 'role') .describe('r', 'key role') .choices('r', Object.values(KEY_ROLE_ENUM)) diff --git a/typescript/infra/src/config/environment.ts b/typescript/infra/src/config/environment.ts index 385b89b2c..a466098cc 100644 --- a/typescript/infra/src/config/environment.ts +++ b/typescript/infra/src/config/environment.ts @@ -1,5 +1,10 @@ -import { CoreConfig, EnvironmentConfig } from '@abacus-network/deploy'; -import { ChainMap, ChainName, MultiProvider } from '@abacus-network/sdk'; +import { + ChainMap, + ChainName, + CoreConfig, + EnvironmentConfig, + MultiProvider, +} from '@abacus-network/sdk'; import { environments } from '../../config/environments'; diff --git a/typescript/infra/src/core/deploy.ts b/typescript/infra/src/core/deploy.ts index a43eba050..f778ea652 100644 --- a/typescript/infra/src/core/deploy.ts +++ b/typescript/infra/src/core/deploy.ts @@ -1,5 +1,9 @@ -import { AbacusCoreDeployer } from '@abacus-network/deploy'; -import { ChainName, chainMetadata, objMap } from '@abacus-network/sdk'; +import { + AbacusCoreDeployer, + ChainName, + chainMetadata, + objMap, +} from '@abacus-network/sdk'; import { DeployEnvironment, RustConfig } from '../config'; import { writeJSON } from '../utils/utils'; diff --git a/typescript/infra/src/verify.ts b/typescript/infra/src/verify.ts index 881b08130..97e1f2bd6 100644 --- a/typescript/infra/src/verify.ts +++ b/typescript/infra/src/verify.ts @@ -1,8 +1,11 @@ import fs from 'fs'; import path from 'path'; -import { ContractVerifier, VerificationInput } from '@abacus-network/deploy'; -import { ChainName } from '@abacus-network/sdk'; +import { + ChainName, + ContractVerifier, + VerificationInput, +} from '@abacus-network/sdk'; import { DeployEnvironment } from './config'; diff --git a/typescript/infra/test/core.test.ts b/typescript/infra/test/core.test.ts index 73d814c49..9754583ea 100644 --- a/typescript/infra/test/core.test.ts +++ b/typescript/infra/test/core.test.ts @@ -5,16 +5,14 @@ import path from 'path'; import sinon from 'sinon'; import { + AbacusCore, AbacusCoreChecker, AbacusCoreDeployer, - CoreConfig, -} from '@abacus-network/deploy'; -import { getMultiProviderFromConfigAndSigner } from '@abacus-network/deploy/dist/src/utils'; -import { - AbacusCore, ChainMap, + CoreConfig, CoreContractsMap, MultiProvider, + getMultiProviderFromConfigAndSigner, objMap, serializeContracts, } from '@abacus-network/sdk'; diff --git a/typescript/hardhat/hardhat.config.ts b/typescript/sdk/hardhat.config.ts similarity index 100% rename from typescript/hardhat/hardhat.config.ts rename to typescript/sdk/hardhat.config.ts diff --git a/typescript/sdk/package.json b/typescript/sdk/package.json index f8bc166a8..9fba136f4 100644 --- a/typescript/sdk/package.json +++ b/typescript/sdk/package.json @@ -1,29 +1,39 @@ { "name": "@abacus-network/sdk", "description": "The official SDK for the Abacus Network", - "version": "0.2.3", + "version": "0.3.1", "dependencies": { - "@abacus-network/app": "^0.2.3", + "@abacus-network/app": "0.3.1", "@abacus-network/celo-ethers-provider": "^0.1.0", - "@abacus-network/core": "^0.2.3", - "@abacus-network/utils": "^0.2.3", + "@abacus-network/core": "0.3.1", + "@abacus-network/utils": "0.3.1", + "@types/debug": "^4.1.7", + "cross-fetch": "^3.1.5", + "debug": "^4.3.4", "ethers": "^5.6.8" }, "devDependencies": { + "@nomiclabs/hardhat-ethers": "^2.0.5", + "@nomiclabs/hardhat-waffle": "^2.0.2", "@types/node": "^16.9.1", "chai": "^4.3.6", "dotenv": "^10.0.0", + "ethereum-waffle": "^3.2.2", "fs": "0.0.1-security", + "hardhat": "^2.8.4", "mocha": "^9.2.2", "prettier": "^2.4.1", "sinon": "^13.0.2", "typescript": "^4.7.2" }, + "files": [ + "/dist" + ], "homepage": "https://www.useabacus.network", "keywords": [ "Abacus", - "Typescript", - "SDK" + "SDK", + "Typescript" ], "license": "Apache-2.0", "main": "dist/index.js", @@ -31,12 +41,12 @@ "scripts": { "build": "tsc", "check": "tsc --noEmit", + "clean": "rm -rf ./dist ./cache", "prepublishOnly": "yarn build", - "prettier": "prettier --write ./src ./test", - "test": "mocha --config .mocharc.json './test/**/*.test.ts'" + "prettier": "prettier --write ./src", + "test": "yarn test:unit && yarn test:hardhat", + "test:unit": "mocha --config .mocharc.json './src/**/*.test.ts'", + "test:hardhat": "hardhat test ./src/**/*.hardhat-test.ts" }, - "types": "dist/index.d.ts", - "files": [ - "/dist" - ] + "types": "dist/index.d.ts" } diff --git a/typescript/sdk/src/app.ts b/typescript/sdk/src/AbacusApp.ts similarity index 94% rename from typescript/sdk/src/app.ts rename to typescript/sdk/src/AbacusApp.ts index 82ab7be7b..de88457ee 100644 --- a/typescript/sdk/src/app.ts +++ b/typescript/sdk/src/AbacusApp.ts @@ -4,7 +4,7 @@ import { connectContracts, serializeContracts, } from './contracts'; -import { MultiProvider } from './provider'; +import { MultiProvider } from './providers/MultiProvider'; import { ChainMap, ChainName, Connection } from './types'; import { MultiGeneric, objMap } from './utils'; diff --git a/typescript/sdk/src/chains.ts b/typescript/sdk/src/consts/chainConnectionConfigs.ts similarity index 91% rename from typescript/sdk/src/chains.ts rename to typescript/sdk/src/consts/chainConnectionConfigs.ts index e14994ab5..b27d126b4 100644 --- a/typescript/sdk/src/chains.ts +++ b/typescript/sdk/src/consts/chainConnectionConfigs.ts @@ -2,8 +2,7 @@ import { ethers } from 'ethers'; import { StaticCeloJsonRpcProvider } from '@abacus-network/celo-ethers-provider'; -import { IChainConnection } from './provider'; -import { ChainMap, ChainName } from './types'; +import { ChainMap, ChainName, IChainConnection } from '../types'; export const ethereum: IChainConnection = { provider: new ethers.providers.JsonRpcProvider( @@ -168,7 +167,7 @@ export const test3: IChainConnection = { confirmations: 1, }; -const _configs = { +export const chainConnectionConfigs: ChainMap = { arbitrum, auroratestnet, bsc, @@ -189,14 +188,3 @@ const _configs = { test2, test3, }; - -export const addSignerToConnection = - (signer: ethers.Signer) => - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - (_chain: Chain, connection: IChainConnection) => ({ - ...connection, - signer, - }); - -export const chainConnectionConfigs: ChainMap = - _configs; diff --git a/typescript/sdk/src/chain-metadata.ts b/typescript/sdk/src/consts/chainMetadata.ts similarity index 87% rename from typescript/sdk/src/chain-metadata.ts rename to typescript/sdk/src/consts/chainMetadata.ts index af75abd9d..d6f07cf03 100644 --- a/typescript/sdk/src/chain-metadata.ts +++ b/typescript/sdk/src/consts/chainMetadata.ts @@ -1,4 +1,22 @@ -import { ChainMetadata, CompleteChainMap } from './types'; +import { ChainName } from '../types'; + +/** + * A Chain and its characteristics + */ +export type ChainMetadata = { + id: number; + finalityBlocks: number; + nativeTokenDecimals?: number; + paginate?: RpcPagination; +}; + +/** + * RPC Pagination information + */ +export interface RpcPagination { + blocks: number; + from: number; +} // IDs can be generated in many ways-- for example, in JS: // > Array.from('celo').map((c, i) => c.charCodeAt(0).toString(16).padStart(2, '0')).join('') @@ -120,7 +138,7 @@ export const auroratestnet: ChainMetadata = { finalityBlocks: 1, }; -export const chainMetadata: CompleteChainMap = { +export const chainMetadata = { arbitrum, bsc, celo, @@ -138,4 +156,4 @@ export const chainMetadata: CompleteChainMap = { optimismkovan, auroratestnet, ...testChains, -}; +} as Record; diff --git a/typescript/sdk/src/consts/chains.ts b/typescript/sdk/src/consts/chains.ts new file mode 100644 index 000000000..38288674c --- /dev/null +++ b/typescript/sdk/src/consts/chains.ts @@ -0,0 +1,26 @@ +/** + * Enumeration of Abacus supported chains + */ +export enum Chains { // must be string type to be used with Object.keys + arbitrum = 'arbitrum', + alfajores = 'alfajores', + bsc = 'bsc', + mumbai = 'mumbai', + kovan = 'kovan', + goerli = 'goerli', + fuji = 'fuji', + celo = 'celo', + ethereum = 'ethereum', + avalanche = 'avalanche', + optimism = 'optimism', + polygon = 'polygon', + bsctestnet = 'bsctestnet', + arbitrumrinkeby = 'arbitrumrinkeby', + optimismkovan = 'optimismkovan', + auroratestnet = 'auroratestnet', + test1 = 'test1', + test2 = 'test2', + test3 = 'test3', +} + +export const AllChains = Object.keys(Chains) as Array; diff --git a/typescript/sdk/src/core/environments/dev.json b/typescript/sdk/src/consts/environments/dev.json similarity index 100% rename from typescript/sdk/src/core/environments/dev.json rename to typescript/sdk/src/consts/environments/dev.json diff --git a/typescript/sdk/src/core/environments/index.ts b/typescript/sdk/src/consts/environments/index.ts similarity index 100% rename from typescript/sdk/src/core/environments/index.ts rename to typescript/sdk/src/consts/environments/index.ts diff --git a/typescript/sdk/src/core/environments/mainnet.json b/typescript/sdk/src/consts/environments/mainnet.json similarity index 100% rename from typescript/sdk/src/core/environments/mainnet.json rename to typescript/sdk/src/consts/environments/mainnet.json diff --git a/typescript/sdk/src/core/environments/test.json b/typescript/sdk/src/consts/environments/test.json similarity index 100% rename from typescript/sdk/src/core/environments/test.json rename to typescript/sdk/src/consts/environments/test.json diff --git a/typescript/sdk/src/core/environments/testnet.json b/typescript/sdk/src/consts/environments/testnet.json similarity index 100% rename from typescript/sdk/src/core/environments/testnet.json rename to typescript/sdk/src/consts/environments/testnet.json diff --git a/typescript/sdk/src/core/environments/testnet2.json b/typescript/sdk/src/consts/environments/testnet2.json similarity index 100% rename from typescript/sdk/src/core/environments/testnet2.json rename to typescript/sdk/src/consts/environments/testnet2.json diff --git a/typescript/sdk/src/metamask.ts b/typescript/sdk/src/consts/metamask.ts similarity index 100% rename from typescript/sdk/src/metamask.ts rename to typescript/sdk/src/consts/metamask.ts diff --git a/typescript/sdk/src/contracts.ts b/typescript/sdk/src/contracts.ts index 8cb38e1c5..49dff7670 100644 --- a/typescript/sdk/src/contracts.ts +++ b/typescript/sdk/src/contracts.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers'; -import { types } from '@abacus-network/utils'; +import type { types } from '@abacus-network/utils'; import { ProxiedContract, ProxyAddresses, isProxyAddresses } from './proxy'; import { Connection } from './types'; diff --git a/typescript/sdk/src/core/app.ts b/typescript/sdk/src/core/AbacusCore.ts similarity index 94% rename from typescript/sdk/src/core/app.ts rename to typescript/sdk/src/core/AbacusCore.ts index d30e4144c..9e539a129 100644 --- a/typescript/sdk/src/core/app.ts +++ b/typescript/sdk/src/core/AbacusCore.ts @@ -1,14 +1,14 @@ import { Inbox, Outbox } from '@abacus-network/core'; -import { AbacusApp } from '../app'; +import { AbacusApp } from '../AbacusApp'; +import { environments } from '../consts/environments'; import { buildContracts } from '../contracts'; -import { MultiProvider } from '../provider'; +import { MultiProvider } from '../providers/MultiProvider'; import { ConnectionClientConfig } from '../router'; import { ChainMap, ChainName, Remotes } from '../types'; import { objMap } from '../utils'; import { CoreContracts, coreFactories } from './contracts'; -import { environments } from './environments'; export type CoreEnvironment = keyof typeof environments; export type CoreEnvironmentChain = Extract< diff --git a/typescript/hardhat/src/TestCoreApp.ts b/typescript/sdk/src/core/TestCoreApp.ts similarity index 84% rename from typescript/hardhat/src/TestCoreApp.ts rename to typescript/sdk/src/core/TestCoreApp.ts index 12a3994fe..3ae3ca71c 100644 --- a/typescript/hardhat/src/TestCoreApp.ts +++ b/typescript/sdk/src/core/TestCoreApp.ts @@ -1,18 +1,15 @@ +import { ethers } from 'ethers'; + import { TestInbox, TestOutbox } from '@abacus-network/core'; -import { - AbacusCore, - ChainMap, - CoreContracts, - DomainIdToChainName, - InboxContracts, - OutboxContracts, - ProxiedContract, - Remotes, - TestChainNames, - chainMetadata, -} from '@abacus-network/sdk'; import { types, utils } from '@abacus-network/utils'; -import { ethers } from 'ethers'; + +import { chainMetadata } from '../consts/chainMetadata'; +import { DomainIdToChainName } from '../domains'; +import { ProxiedContract } from '../proxy'; +import { ChainMap, ChainName, Remotes, TestChainNames } from '../types'; + +import { AbacusCore } from './AbacusCore'; +import { CoreContracts, InboxContracts, OutboxContracts } from './contracts'; type MockProxyAddresses = { kind: 'MOCK'; @@ -60,8 +57,10 @@ export class TestCoreApp extends AbacusCore { return responses; } - async processOutboundMessages(origin: Local) { - const responses = new Map(); + async processOutboundMessages( + origin: Local, + ): Promise> { + const responses = new Map(); const contracts = this.getContracts(origin); const outbox: TestOutbox = contracts.outbox.contract; diff --git a/typescript/hardhat/src/TestCoreDeploy.ts b/typescript/sdk/src/core/TestCoreDeployer.ts similarity index 83% rename from typescript/hardhat/src/TestCoreDeploy.ts rename to typescript/sdk/src/core/TestCoreDeployer.ts index 5aa18e5bc..73d33a9d9 100644 --- a/typescript/hardhat/src/TestCoreDeploy.ts +++ b/typescript/sdk/src/core/TestCoreDeployer.ts @@ -1,23 +1,20 @@ +import { ethers } from 'ethers'; + +import { TestInbox__factory, TestOutbox__factory } from '@abacus-network/core'; + +import { chainMetadata } from '../consts/chainMetadata'; +import { AbacusCoreDeployer } from '../deploy/core/AbacusCoreDeployer'; +import { CoreConfig, ValidatorManagerConfig } from '../deploy/core/types'; +import { MultiProvider } from '../providers/MultiProvider'; +import { ProxiedContract } from '../proxy'; +import { Remotes, TestChainNames } from '../types'; + import { TestCoreApp, TestInboxContracts, TestOutboxContracts, } from './TestCoreApp'; -import { TestInbox__factory, TestOutbox__factory } from '@abacus-network/core'; -import { - AbacusCoreDeployer, - CoreConfig, - ValidatorManagerConfig, -} from '@abacus-network/deploy'; -import { - chainMetadata, - coreFactories, - MultiProvider, - ProxiedContract, - Remotes, - TestChainNames, -} from '@abacus-network/sdk'; -import { ethers } from 'ethers'; +import { coreFactories } from './contracts'; // dummy config as TestInbox and TestOutbox do not use deployed ValidatorManager const testValidatorManagerConfig: CoreConfig = { @@ -41,7 +38,7 @@ function mockProxy(contract: ethers.Contract) { }); } -export class TestCoreDeploy extends AbacusCoreDeployer { +export class TestCoreDeployer extends AbacusCoreDeployer { constructor(public readonly multiProvider: MultiProvider) { super( multiProvider, @@ -99,7 +96,7 @@ export class TestCoreDeploy extends AbacusCoreDeployer { } as TestInboxContracts; } - async deployCore() { + async deployApp(): Promise { return new TestCoreApp(await this.deploy(), this.multiProvider); } } diff --git a/typescript/sdk/src/core/index.ts b/typescript/sdk/src/core/index.ts deleted file mode 100644 index 46c72c0e5..000000000 --- a/typescript/sdk/src/core/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -export { AbacusCore, CoreContractsMap } from './app'; -export { - CoreContracts, - coreFactories, - InboxContracts, - OutboxContracts, -} from './contracts'; -export { environments as coreEnvironments } from './environments'; -export { - AbacusLifecyleEvent, - AnnotatedDispatch, - AnnotatedLifecycleEvent, -} from './events'; -export { - AbacusMessage, - AbacusStatus, - MessageStatus, - resolveDomain, - resolveId, - resolveNetworks, -} from './message'; diff --git a/typescript/sdk/src/core/message.ts b/typescript/sdk/src/core/message.ts index cc8d0ab1a..43dd37ca5 100644 --- a/typescript/sdk/src/core/message.ts +++ b/typescript/sdk/src/core/message.ts @@ -1,21 +1,15 @@ -import { AbacusCore } from '.'; -import { TransactionReceipt } from '@ethersproject/abstract-provider'; -import { BigNumber } from '@ethersproject/bignumber'; -import { keccak256 } from 'ethers/lib/utils'; +import { BigNumber, utils as ethersUtils, providers } from 'ethers'; import { Inbox, Outbox, Outbox__factory } from '@abacus-network/core'; import { types, utils } from '@abacus-network/utils'; +import { ChainNameToDomainId, DomainIdToChainName } from '../domains'; import { Annotated, findAnnotatedSingleEvent } from '../events'; -import { MultiProvider } from '../provider'; -import { - ChainName, - ChainNameToDomainId, - DomainIdToChainName, - NameOrDomain, -} from '../types'; +import { MultiProvider } from '../providers/MultiProvider'; +import { ChainName, NameOrDomain } from '../types'; import { delay } from '../utils'; +import { AbacusCore } from './AbacusCore'; import { AnnotatedDispatch, AnnotatedLifecycleEvent, @@ -104,7 +98,7 @@ export class AbacusMessage { /** * The receipt of the TX that dispatched this message */ - get receipt(): TransactionReceipt { + get receipt(): providers.TransactionReceipt { return this.dispatch.receipt; } @@ -120,7 +114,7 @@ export class AbacusMessage { multiProvider: MultiProvider, core: AbacusCore, nameOrDomain: NameOrDomain, - receipt: TransactionReceipt, + receipt: providers.TransactionReceipt, ): AbacusMessage[] { const messages: AbacusMessage[] = []; const outbox = new Outbox__factory().interface; @@ -169,7 +163,7 @@ export class AbacusMessage { multiProvider: MultiProvider, core: AbacusCore, nameOrDomain: NameOrDomain, - receipt: TransactionReceipt, + receipt: providers.TransactionReceipt, ): AbacusMessage { const messages: AbacusMessage[] = AbacusMessage.fromReceipt( multiProvider, @@ -384,7 +378,7 @@ export class AbacusMessage { * The keccak256 hash of the message body */ get bodyHash(): string { - return keccak256(this.body); + return ethersUtils.keccak256(this.body); } /** diff --git a/typescript/hardhat/test/testAbacusDeploy.test.ts b/typescript/sdk/src/core/testAbacusDeploy.hardhat-test.ts similarity index 72% rename from typescript/hardhat/test/testAbacusDeploy.test.ts rename to typescript/sdk/src/core/testAbacusDeploy.hardhat-test.ts index 416d2c141..b670025bb 100644 --- a/typescript/hardhat/test/testAbacusDeploy.test.ts +++ b/typescript/sdk/src/core/testAbacusDeploy.hardhat-test.ts @@ -1,26 +1,43 @@ -import { hardhatMultiProvider } from '../index'; -import { TestCoreApp } from '../src/TestCoreApp'; -import { TestCoreDeploy } from '../src/TestCoreDeploy'; -import { TestOutbox, TestRecipient__factory } from '@abacus-network/core'; -import { chainMetadata } from '@abacus-network/sdk'; -import { utils } from '@abacus-network/utils'; +import '@nomiclabs/hardhat-ethers'; +import '@nomiclabs/hardhat-waffle'; import { expect } from 'chai'; import { ethers } from 'hardhat'; +import { TestOutbox, TestRecipient__factory } from '@abacus-network/core'; +import { utils } from '@abacus-network/utils'; + +import { chainMetadata } from '../consts/chainMetadata'; +import { getMultiProviderFromConfigAndSigner } from '../deploy/utils'; + +import { TestCoreApp } from './TestCoreApp'; +import { TestCoreDeployer } from './TestCoreDeployer'; + const localChain = 'test1'; const localDomain = chainMetadata[localChain].id; const remoteChain = 'test2'; const remoteDomain = chainMetadata[remoteChain].id; const message = '0xdeadbeef'; -describe('TestCoreDeploy', async () => { +describe('TestCoreDeployer', async () => { let abacus: TestCoreApp, localOutbox: TestOutbox, remoteOutbox: TestOutbox; beforeEach(async () => { const [signer] = await ethers.getSigners(); - const multiProvider = hardhatMultiProvider(ethers.provider, signer); - const deployer = new TestCoreDeploy(multiProvider); - abacus = await deployer.deployCore(); + + const config = { + test1: { + provider: ethers.provider, + }, + test2: { + provider: ethers.provider, + }, + test3: { + provider: ethers.provider, + }, + }; + const multiProvider = getMultiProviderFromConfigAndSigner(config, signer); + const deployer = new TestCoreDeployer(multiProvider); + abacus = await deployer.deployApp(); const recipient = await new TestRecipient__factory(signer).deploy(); localOutbox = abacus.getContracts(localChain).outbox.contract; diff --git a/typescript/deploy/.eslintrc b/typescript/sdk/src/deploy/.eslintrc similarity index 100% rename from typescript/deploy/.eslintrc rename to typescript/sdk/src/deploy/.eslintrc diff --git a/typescript/deploy/src/check.ts b/typescript/sdk/src/deploy/AbacusAppChecker.ts similarity index 73% rename from typescript/deploy/src/check.ts rename to typescript/sdk/src/deploy/AbacusAppChecker.ts index 2c9d32dc0..e4f0816ab 100644 --- a/typescript/deploy/src/check.ts +++ b/typescript/sdk/src/deploy/AbacusAppChecker.ts @@ -1,16 +1,13 @@ -import { expect } from 'chai'; +import { utils } from '@abacus-network/utils'; +import type { types } from '@abacus-network/utils'; -import { - AbacusApp, - BeaconProxyAddresses, - ChainMap, - ChainName, - MultiProvider, -} from '@abacus-network/sdk'; -import { types } from '@abacus-network/utils'; +import { AbacusApp } from '../AbacusApp'; +import { MultiProvider } from '../providers/MultiProvider'; +import { BeaconProxyAddresses } from '../proxy'; +import { ChainMap, ChainName } from '../types'; -import { CheckerViolation } from './config'; import { upgradeBeaconImplementation, upgradeBeaconViolation } from './proxy'; +import { CheckerViolation } from './types'; export interface Ownable { owner(): Promise; @@ -39,13 +36,13 @@ export abstract class AbacusAppChecker< abstract checkChain(chain: Chain): Promise; - async check() { + async check(): Promise { return Promise.all( this.app.chains().map((chain) => this.checkChain(chain)), ); } - addViolation(violation: CheckerViolation) { + addViolation(violation: CheckerViolation): void { if (!this.isDuplicateViolation(violation)) { this.violations.push(violation); } @@ -55,7 +52,7 @@ export abstract class AbacusAppChecker< chain: Chain, name: string, proxiedAddress: BeaconProxyAddresses, - ) { + ): Promise { const dc = this.multiProvider.getChainConnection(chain); const implementation = await upgradeBeaconImplementation( dc.provider, @@ -73,10 +70,10 @@ export abstract class AbacusAppChecker< ownables: Ownable[], ): Promise { const owners = await Promise.all(ownables.map((o) => o.owner())); - owners.map((_) => expect(_).to.equal(owner)); + owners.map((_) => utils.assert(_ == owner)); } - isDuplicateViolation(violation: CheckerViolation) { + isDuplicateViolation(violation: CheckerViolation): boolean { const duplicates = this.violations.filter( (v) => violation.type === v.type && @@ -87,20 +84,20 @@ export abstract class AbacusAppChecker< return duplicates.length > 0; } - expectViolations(types: string[], expectedMatches: number[]) { + expectViolations(types: string[], expectedMatches: number[]): void { // Every type should have exactly the number of expected matches. const actualMatches = types.map( (t) => this.violations.map((v) => v.type === t).filter(Boolean).length, ); - expect(actualMatches).to.deep.equal(expectedMatches); + utils.assert(utils.deepEquals(actualMatches, expectedMatches)); // Every violation should be matched by at least one partial. const unmatched = this.violations.map( (v) => types.map((t) => v.type === t).filter(Boolean).length, ); - expect(unmatched).to.not.include(0); + utils.assert(!unmatched.includes(0)); } expectEmpty(): void { - expect(this.violations).to.be.empty; + utils.assert(this.violations.length === 0); } } diff --git a/typescript/deploy/src/deploy.ts b/typescript/sdk/src/deploy/AbacusDeployer.ts similarity index 94% rename from typescript/deploy/src/deploy.ts rename to typescript/sdk/src/deploy/AbacusDeployer.ts index 4bb6c9671..22eb8571c 100644 --- a/typescript/deploy/src/deploy.ts +++ b/typescript/sdk/src/deploy/AbacusDeployer.ts @@ -5,25 +5,21 @@ import { UpgradeBeaconProxy__factory, UpgradeBeacon__factory, } from '@abacus-network/core'; +import type { types } from '@abacus-network/utils'; + import { AbacusContracts, AbacusFactories, - BeaconProxyAddresses, - ChainMap, - ChainName, - MultiProvider, - ProxiedContract, connectContracts, - objMap, serializeContracts, -} from '@abacus-network/sdk'; -import { ProxyKind } from '@abacus-network/sdk/dist/proxy'; -import { types } from '@abacus-network/utils'; +} from '../contracts'; +import { MultiProvider } from '../providers/MultiProvider'; +import { BeaconProxyAddresses, ProxiedContract, ProxyKind } from '../proxy'; +import { ChainMap, ChainName } from '../types'; +import { objMap } from '../utils/objects'; -import { - ContractVerificationInput, - getContractVerificationInput, -} from './verify'; +import { ContractVerificationInput } from './verify/types'; +import { getContractVerificationInput } from './verify/utils'; export interface DeployerOptions { logger?: Debugger; diff --git a/typescript/deploy/src/core/check.ts b/typescript/sdk/src/deploy/core/AbacusCoreChecker.ts similarity index 81% rename from typescript/deploy/src/core/check.ts rename to typescript/sdk/src/deploy/core/AbacusCoreChecker.ts index 713d07c76..ee4366c15 100644 --- a/typescript/deploy/src/core/check.ts +++ b/typescript/sdk/src/deploy/core/AbacusCoreChecker.ts @@ -1,44 +1,22 @@ -import { expect } from 'chai'; - import { MultisigValidatorManager } from '@abacus-network/core'; -import { - AbacusCore, - BeaconProxyAddresses, - ChainName, - ChainNameToDomainId, - chainMetadata, - objMap, - promiseObjAll, -} from '@abacus-network/sdk'; - -import { AbacusAppChecker } from '../check'; -import { CheckerViolation } from '../config'; -import { setDifference } from '../utils'; - -import { CoreConfig } from './deploy'; - -export enum CoreViolationType { - ValidatorManager = 'ValidatorManager', - Validator = 'Validator', -} +import { utils } from '@abacus-network/utils'; -export enum ValidatorViolationType { - EnrollValidator = 'EnrollValidator', - UnenrollValidator = 'UnenrollValidator', - Threshold = 'Threshold', -} - -export interface ValidatorManagerViolation extends CheckerViolation { - type: CoreViolationType.ValidatorManager; -} +import { chainMetadata } from '../../consts/chainMetadata'; +import { AbacusCore } from '../../core/AbacusCore'; +import { ChainNameToDomainId } from '../../domains'; +import { BeaconProxyAddresses } from '../../proxy'; +import { ChainName } from '../../types'; +import { objMap, promiseObjAll } from '../../utils/objects'; +import { setDifference } from '../../utils/sets'; +import { AbacusAppChecker } from '../AbacusAppChecker'; -export interface ValidatorViolation extends CheckerViolation { - type: CoreViolationType.Validator; - data: { - type: ValidatorViolationType; - validatorManagerAddress: string; - }; -} +import { + CoreConfig, + CoreViolationType, + ValidatorManagerViolation, + ValidatorViolation, + ValidatorViolationType, +} from './types'; export class AbacusCoreChecker< Chain extends ChainName, @@ -72,7 +50,7 @@ export class AbacusCoreChecker< const contracts = this.app.getContracts(chain); const outbox = contracts.outbox.contract; const localDomain = await outbox.localDomain(); - expect(localDomain).to.equal(ChainNameToDomainId[chain]); + utils.assert(localDomain === ChainNameToDomainId[chain]); const actualManager = await contracts.outbox.contract.validatorManager(); const expectedManager = contracts.outboxValidatorManager.address; @@ -89,14 +67,14 @@ export class AbacusCoreChecker< // Checks validator sets of the OutboxValidatorManager and all // InboxValidatorManagers on the chain. - async checkValidatorManagers(chain: Chain) { + async checkValidatorManagers(chain: Chain): Promise { const coreContracts = this.app.getContracts(chain); await this.checkValidatorManager( chain, chain, coreContracts.outboxValidatorManager, ); - return promiseObjAll( + await promiseObjAll( objMap(coreContracts.inboxes, (remote, inbox) => this.checkValidatorManager(chain, remote, inbox.inboxValidatorManager), ), @@ -158,7 +136,7 @@ export class AbacusCoreChecker< } const expectedThreshold = validatorManagerConfig.threshold; - expect(expectedThreshold).to.not.be.undefined; + utils.assert(expectedThreshold !== undefined); const actualThreshold = await validatorManager.threshold(); @@ -186,7 +164,7 @@ export class AbacusCoreChecker< objMap(coreContracts.inboxes, async (_, inbox) => { const expected = inbox.inboxValidatorManager.address; const actual = await inbox.inbox.contract.validatorManager(); - expect(actual).to.equal(expected); + utils.assert(actual === expected); }), ); @@ -194,10 +172,10 @@ export class AbacusCoreChecker< objMap(coreContracts.inboxes, async (remoteChain, inbox) => { // check that the inbox has the right local domain const actualLocalDomain = await inbox.inbox.contract.localDomain(); - expect(actualLocalDomain).to.equal(ChainNameToDomainId[chain]); + utils.assert(actualLocalDomain === ChainNameToDomainId[chain]); const actualRemoteDomain = await inbox.inbox.contract.remoteDomain(); - expect(actualRemoteDomain).to.equal(ChainNameToDomainId[remoteChain]); + utils.assert(actualRemoteDomain === ChainNameToDomainId[remoteChain]); }), ); @@ -208,10 +186,15 @@ export class AbacusCoreChecker< coreAddresses.inboxes, ); const implementations = inboxes.map((r) => r.implementation); - const identical = (a: any, b: any) => (a === b ? a : false); const upgradeBeacons = inboxes.map((r) => r.beacon); - expect(implementations.reduce(identical)).to.not.be.false; - expect(upgradeBeacons.reduce(identical)).to.not.be.false; + utils.assert( + implementations.every( + (implementation) => implementation === implementations[0], + ), + ); + utils.assert( + upgradeBeacons.every((beacon) => beacon === upgradeBeacons[0]), + ); } async checkAbacusConnectionManager(chain: Chain): Promise { @@ -222,13 +205,13 @@ export class AbacusCoreChecker< // inbox is enrolled in abacusConnectionManager const enrolledInboxes = await coreContracts.abacusConnectionManager.getInboxes(remoteDomain); - expect(enrolledInboxes).to.deep.equal([inbox.inbox.address]); + utils.assert(utils.deepEquals(enrolledInboxes, [inbox.inbox.address])); }), ); // Outbox is set on abacusConnectionManager const outbox = await coreContracts.abacusConnectionManager.outbox(); - expect(outbox).to.equal(coreContracts.outbox.address); + utils.assert(outbox === coreContracts.outbox.address); } async checkProxiedContracts(chain: Chain): Promise { diff --git a/typescript/deploy/src/core/deploy.ts b/typescript/sdk/src/deploy/core/AbacusCoreDeployer.ts similarity index 90% rename from typescript/deploy/src/core/deploy.ts rename to typescript/sdk/src/deploy/core/AbacusCoreDeployer.ts index 216346257..be5511b61 100644 --- a/typescript/deploy/src/core/deploy.ts +++ b/typescript/sdk/src/deploy/core/AbacusCoreDeployer.ts @@ -2,37 +2,29 @@ import debug from 'debug'; import { ethers } from 'ethers'; import { Inbox, Ownable } from '@abacus-network/core'; +import type { types } from '@abacus-network/utils'; + +import { chainMetadata } from '../../consts/chainMetadata'; +import { AbacusCore, CoreContractsMap } from '../../core/AbacusCore'; import { - AbacusCore, - BeaconProxyAddresses, - ChainConnection, - ChainMap, - ChainName, CoreContracts, - CoreContractsMap, InboxContracts, - MultiProvider, OutboxContracts, - ProxiedContract, + coreFactories, +} from '../../core/contracts'; +import { MultiProvider } from '../../providers/MultiProvider'; +import { BeaconProxyAddresses, ProxiedContract } from '../../proxy'; +import { + ChainMap, + ChainName, + IChainConnection, RemoteChainMap, Remotes, - chainMetadata, - coreFactories, - objMap, - promiseObjAll, -} from '@abacus-network/sdk'; -import { types } from '@abacus-network/utils'; - -import { AbacusDeployer } from '../deploy'; +} from '../../types'; +import { objMap, promiseObjAll } from '../../utils/objects'; +import { AbacusDeployer } from '../AbacusDeployer'; -export type ValidatorManagerConfig = { - validators: Array; - threshold: number; -}; - -export type CoreConfig = { - validatorManager: ValidatorManagerConfig; -}; +import { CoreConfig, ValidatorManagerConfig } from './types'; export class AbacusCoreDeployer extends AbacusDeployer< Chain, @@ -203,7 +195,7 @@ export class AbacusCoreDeployer extends AbacusDeployer< core: AbacusCore, owners: ChainMap, multiProvider: MultiProvider, - ) { + ): Promise> { return promiseObjAll( objMap(core.contractsMap, async (chain, coreContracts) => { const owner = owners[chain]; @@ -223,7 +215,7 @@ export class AbacusCoreDeployer extends AbacusDeployer< >( coreContracts: CoreContracts, owner: types.Address, - chainConnection: ChainConnection, + chainConnection: IChainConnection, ): Promise { const ownables: Ownable[] = [ coreContracts.outbox.contract, diff --git a/typescript/sdk/src/deploy/core/types.ts b/typescript/sdk/src/deploy/core/types.ts new file mode 100644 index 000000000..6b15eee91 --- /dev/null +++ b/typescript/sdk/src/deploy/core/types.ts @@ -0,0 +1,35 @@ +import type { types } from '@abacus-network/utils'; + +import type { CheckerViolation } from '../types'; + +export type ValidatorManagerConfig = { + validators: Array; + threshold: number; +}; + +export type CoreConfig = { + validatorManager: ValidatorManagerConfig; +}; + +export enum CoreViolationType { + ValidatorManager = 'ValidatorManager', + Validator = 'Validator', +} + +export enum ValidatorViolationType { + EnrollValidator = 'EnrollValidator', + UnenrollValidator = 'UnenrollValidator', + Threshold = 'Threshold', +} + +export interface ValidatorManagerViolation extends CheckerViolation { + type: CoreViolationType.ValidatorManager; +} + +export interface ValidatorViolation extends CheckerViolation { + type: CoreViolationType.Validator; + data: { + type: ValidatorViolationType; + validatorManagerAddress: string; + }; +} diff --git a/typescript/deploy/src/proxy.ts b/typescript/sdk/src/deploy/proxy.ts similarity index 83% rename from typescript/deploy/src/proxy.ts rename to typescript/sdk/src/deploy/proxy.ts index 8fd78b23e..e9687e381 100644 --- a/typescript/deploy/src/proxy.ts +++ b/typescript/sdk/src/deploy/proxy.ts @@ -1,9 +1,11 @@ import { ethers } from 'ethers'; -import { BeaconProxyAddresses, ChainName } from '@abacus-network/sdk'; -import { types } from '@abacus-network/utils'; +import type { types } from '@abacus-network/utils'; -import { CheckerViolation } from './config'; +import { BeaconProxyAddresses } from '../proxy'; +import { ChainName } from '../types'; + +import { CheckerViolation } from './types'; export interface UpgradeBeaconViolation extends CheckerViolation { type: BeaconProxyAddresses['kind']; diff --git a/typescript/deploy/src/router/check.ts b/typescript/sdk/src/deploy/router/AbacusRouterChecker.ts similarity index 70% rename from typescript/deploy/src/router/check.ts rename to typescript/sdk/src/deploy/router/AbacusRouterChecker.ts index c180ae9f9..d67c24785 100644 --- a/typescript/deploy/src/router/check.ts +++ b/typescript/sdk/src/deploy/router/AbacusRouterChecker.ts @@ -1,14 +1,10 @@ -import { expect } from 'chai'; - -import { - AbacusApp, - ChainName, - RouterContracts, - chainMetadata, -} from '@abacus-network/sdk'; import { utils } from '@abacus-network/utils'; -import { AbacusAppChecker, Ownable } from '../check'; +import { AbacusApp } from '../../AbacusApp'; +import { chainMetadata } from '../../consts/chainMetadata'; +import { RouterContracts } from '../../router'; +import { ChainName } from '../../types'; +import { AbacusAppChecker, Ownable } from '../AbacusAppChecker'; import { RouterConfig } from './types'; @@ -18,7 +14,7 @@ export class AbacusRouterChecker< App extends AbacusApp, Config extends RouterConfig, > extends AbacusAppChecker { - checkOwnership(chain: Chain) { + checkOwnership(chain: Chain): Promise { const owner = this.configMap[chain].owner; const ownables = this.ownables(chain); return AbacusAppChecker.checkOwnership(owner, ownables); @@ -36,9 +32,8 @@ export class AbacusRouterChecker< this.app.remoteChains(chain).map(async (remoteNetwork) => { const remoteRouter = this.app.getContracts(remoteNetwork).router; const remoteChainId = chainMetadata[remoteNetwork].id; - expect(await router.routers(remoteChainId)).to.equal( - utils.addressToBytes32(remoteRouter.address), - ); + const address = await router.routers(remoteChainId); + utils.assert(address === utils.addressToBytes32(remoteRouter.address)); }), ); } diff --git a/typescript/deploy/src/router/deploy.ts b/typescript/sdk/src/deploy/router/AbacusRouterDeployer.ts similarity index 81% rename from typescript/deploy/src/router/deploy.ts rename to typescript/sdk/src/deploy/router/AbacusRouterDeployer.ts index c2342dcd9..532a17fd0 100644 --- a/typescript/deploy/src/router/deploy.ts +++ b/typescript/sdk/src/deploy/router/AbacusRouterDeployer.ts @@ -1,19 +1,14 @@ import { debug } from 'debug'; import { ethers } from 'ethers'; -import { - ChainMap, - ChainName, - MultiProvider, - RouterContracts, - RouterFactories, - chainMetadata, - objMap, - promiseObjAll, -} from '@abacus-network/sdk'; import { utils } from '@abacus-network/utils'; -import { AbacusDeployer, DeployerOptions } from '../deploy'; +import { chainMetadata } from '../../consts/chainMetadata'; +import { MultiProvider } from '../../providers/MultiProvider'; +import { RouterContracts, RouterFactories } from '../../router'; +import { ChainMap, ChainName } from '../../types'; +import { objMap, promiseObjAll } from '../../utils/objects'; +import { AbacusDeployer, DeployerOptions } from '../AbacusDeployer'; import { RouterConfig } from './types'; @@ -35,7 +30,9 @@ export abstract class AbacusRouterDeployer< }); } - async initConnectionClient(contractsMap: ChainMap) { + async initConnectionClient( + contractsMap: ChainMap, + ): Promise { this.logger(`Initializing connection clients (if not already)...`); await promiseObjAll( objMap(contractsMap, async (local, contracts) => { @@ -69,7 +66,9 @@ export abstract class AbacusRouterDeployer< ); } - async enrollRemoteRouters(contractsMap: ChainMap) { + async enrollRemoteRouters( + contractsMap: ChainMap, + ): Promise { this.logger(`Enrolling deployed routers with each other...`); // Make all routers aware of eachother. await promiseObjAll( @@ -89,7 +88,9 @@ export abstract class AbacusRouterDeployer< ); } - async transferOwnership(contractsMap: ChainMap) { + async transferOwnership( + contractsMap: ChainMap, + ): Promise { this.logger(`Transferring ownership of routers...`); await promiseObjAll( objMap(contractsMap, async (chain, contracts) => { @@ -103,7 +104,9 @@ export abstract class AbacusRouterDeployer< ); } - async deploy(partialDeployment?: Partial>) { + async deploy( + partialDeployment?: Partial>, + ): Promise> { const contractsMap = await super.deploy(partialDeployment); await this.enrollRemoteRouters(contractsMap); diff --git a/typescript/deploy/src/router/types.ts b/typescript/sdk/src/deploy/router/types.ts similarity index 52% rename from typescript/deploy/src/router/types.ts rename to typescript/sdk/src/deploy/router/types.ts index c45b15e08..1c300325e 100644 --- a/typescript/deploy/src/router/types.ts +++ b/typescript/sdk/src/deploy/router/types.ts @@ -1,5 +1,6 @@ -import { ConnectionClientConfig } from '@abacus-network/sdk'; -import { types } from '@abacus-network/utils'; +import type { types } from '@abacus-network/utils'; + +import type { ConnectionClientConfig } from '../../router'; export type OwnableConfig = { owner: types.Address; diff --git a/typescript/deploy/src/config.ts b/typescript/sdk/src/deploy/types.ts similarity index 74% rename from typescript/deploy/src/config.ts rename to typescript/sdk/src/deploy/types.ts index 4516e754c..b221d8941 100644 --- a/typescript/deploy/src/config.ts +++ b/typescript/sdk/src/deploy/types.ts @@ -1,4 +1,4 @@ -import { ChainMap, ChainName, IChainConnection } from '@abacus-network/sdk'; +import type { ChainMap, ChainName, IChainConnection } from '../types'; export interface CheckerViolation { chain: ChainName; diff --git a/typescript/sdk/src/deploy/utils.ts b/typescript/sdk/src/deploy/utils.ts new file mode 100644 index 000000000..e590273fb --- /dev/null +++ b/typescript/sdk/src/deploy/utils.ts @@ -0,0 +1,20 @@ +import { ethers } from 'ethers'; + +import { MultiProvider } from '../providers/MultiProvider'; +import { ChainName } from '../types'; +import { objMap } from '../utils'; + +import { EnvironmentConfig } from './types'; + +export function getMultiProviderFromConfigAndSigner( + environmentConfig: EnvironmentConfig, + signer: ethers.Signer, +): MultiProvider { + const chainProviders = objMap(environmentConfig, (_, config) => ({ + provider: signer.provider!, + signer, + confirmations: config.confirmations, + overrides: config.overrides, + })); + return new MultiProvider(chainProviders); +} diff --git a/typescript/deploy/src/verify/ContractVerifier.ts b/typescript/sdk/src/deploy/verify/ContractVerifier.ts similarity index 78% rename from typescript/deploy/src/verify/ContractVerifier.ts rename to typescript/sdk/src/deploy/verify/ContractVerifier.ts index 863cbaf39..09a9e6b69 100644 --- a/typescript/deploy/src/verify/ContractVerifier.ts +++ b/typescript/sdk/src/deploy/verify/ContractVerifier.ts @@ -1,7 +1,8 @@ -import axios from 'axios'; +import fetch from 'cross-fetch'; -import { ChainName } from '@abacus-network/sdk'; -import { types } from '@abacus-network/utils'; +import type { types } from '@abacus-network/utils'; + +import { ChainName } from '../../types'; import { ContractVerificationInput, VerificationInput } from './types'; @@ -20,7 +21,7 @@ export abstract class ContractVerifier { abstract chainNames: ChainName[]; abstract getVerificationInput(chain: ChainName): VerificationInput; - static etherscanLink(chain: ChainName, address: types.Address) { + static etherscanLink(chain: ChainName, address: types.Address): string { if (chain === 'polygon') { return `https://polygonscan.com/address/${address}`; } @@ -29,7 +30,8 @@ export abstract class ContractVerifier { return `https://${prefix}etherscan.io/address/${address}`; } - async verify(hre: any) { + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + async verify(hre: any): Promise { let chain = hre.network.name; if (chain === 'mainnet') { @@ -59,8 +61,9 @@ export abstract class ContractVerifier { async verifyContract( chain: ChainName, input: ContractVerificationInput, + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types hre: any, - ) { + ): Promise { try { console.log( ` Attempt to verify ${ @@ -86,28 +89,32 @@ export abstract class ContractVerifier { console.log('\n\n'); // add space after each attempt } - async verifyProxy(chain: ChainName, address: types.Address) { + async verifyProxy(chain: ChainName, address: types.Address): Promise { const suffix = chain === 'ethereum' ? '' : `-${chain}`; console.log(` Submit ${address} for proxy verification on ${chain}`); // Submit contract for verification - const verifyResponse = await axios.post( - `https://api${suffix}.etherscan.io/api`, - `address=${address}`, + const verifyResponse = await fetch( + `https://api${suffix}.etherscan.io/api?address=${address}`, { - params: { + method: 'POST', + body: JSON.stringify({ module: 'contract', action: 'verifyproxycontract', apikey: this.key, - }, + }), }, ); // Validate that submission worked - if (verifyResponse.status !== 200) { + if (!verifyResponse.ok) { throw new Error('Verify POST failed'); - } else if (verifyResponse.data.status != '1') { - throw new Error(verifyResponse.data.result); + } + + const data = await verifyResponse.json(); + + if (data?.status != '1') { + throw new Error(data?.result); } console.log(` Submitted.`); diff --git a/typescript/deploy/src/verify/types.ts b/typescript/sdk/src/deploy/verify/types.ts similarity index 100% rename from typescript/deploy/src/verify/types.ts rename to typescript/sdk/src/deploy/verify/types.ts diff --git a/typescript/deploy/src/verify/utils.ts b/typescript/sdk/src/deploy/verify/utils.ts similarity index 87% rename from typescript/deploy/src/verify/utils.ts rename to typescript/sdk/src/deploy/verify/utils.ts index 886527d9e..076ba2950 100644 --- a/typescript/deploy/src/verify/utils.ts +++ b/typescript/sdk/src/deploy/verify/utils.ts @@ -1,9 +1,11 @@ -import { Fragment } from '@ethersproject/abi'; -import { ethers } from 'ethers'; +import { ethers, utils } from 'ethers'; import { ContractVerificationInput } from './types'; -export function formatFunctionArguments(fragment: Fragment, args: any[]) { +export function formatFunctionArguments( + fragment: utils.Fragment, + args: any[], +): any { const params = Object.fromEntries( fragment.inputs.map((input, index) => [input.name, args[index]]), ); diff --git a/typescript/sdk/src/domains.ts b/typescript/sdk/src/domains.ts new file mode 100644 index 000000000..4bb5396bd --- /dev/null +++ b/typescript/sdk/src/domains.ts @@ -0,0 +1,11 @@ +import { chainMetadata } from './consts/chainMetadata'; +import { AllChains } from './consts/chains'; +import { ChainName, CompleteChainMap } from './types'; + +export const DomainIdToChainName = Object.fromEntries( + AllChains.map((chain) => [chainMetadata[chain].id, chain]), +) as Record; + +export const ChainNameToDomainId = Object.fromEntries( + AllChains.map((chain) => [chain, chainMetadata[chain].id]), +) as CompleteChainMap; diff --git a/typescript/sdk/src/ethers/index.ts b/typescript/sdk/src/ethers/index.ts deleted file mode 100644 index c3a246b54..000000000 --- a/typescript/sdk/src/ethers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { RetryProvider, RetryJsonRpcProvider } from './retry-provider'; diff --git a/typescript/sdk/src/events.ts b/typescript/sdk/src/events.ts index b92745fb2..003e87f8c 100644 --- a/typescript/sdk/src/events.ts +++ b/typescript/sdk/src/events.ts @@ -1,19 +1,19 @@ -import { TransactionReceipt } from '@ethersproject/abstract-provider'; +import { providers } from 'ethers'; import { TypedEvent, TypedEventFilter } from '@abacus-network/core/dist/common'; -import { chainMetadata } from './chain-metadata'; -import { MultiProvider } from './provider'; +import { chainMetadata } from './consts/chainMetadata'; +import { MultiProvider } from './providers/MultiProvider'; import { ChainName } from './types'; export class Annotated { readonly domain: number; readonly eventName?: string; readonly event: T; - readonly receipt: TransactionReceipt; + readonly receipt: providers.TransactionReceipt; constructor( domain: number, - receipt: TransactionReceipt, + receipt: providers.TransactionReceipt, event: T, callerKnowsWhatTheyAreDoing = false, ) { diff --git a/typescript/sdk/test/gas/calculator.test.ts b/typescript/sdk/src/gas/calculator.test.ts similarity index 95% rename from typescript/sdk/test/gas/calculator.test.ts rename to typescript/sdk/src/gas/calculator.test.ts index 13b4d1ffa..055aa20df 100644 --- a/typescript/sdk/test/gas/calculator.test.ts +++ b/typescript/sdk/src/gas/calculator.test.ts @@ -4,16 +4,14 @@ import sinon from 'sinon'; import { utils } from '@abacus-network/utils'; -import { - AbacusCore, - Chains, - InterchainGasCalculator, - MultiProvider, -} from '../..'; -import { CoreContracts } from '../../src'; -import { ParsedMessage } from '../../src/gas/calculator'; -import { TestChainNames } from '../../src/types'; -import { MockProvider, MockTokenPriceGetter } from '../utils'; +import { Chains } from '../consts/chains'; +import { AbacusCore } from '../core/AbacusCore'; +import { CoreContracts } from '../core/contracts'; +import { MultiProvider } from '../providers/MultiProvider'; +import { MockProvider, MockTokenPriceGetter } from '../test/testUtils'; +import { TestChainNames } from '../types'; + +import { InterchainGasCalculator, ParsedMessage } from './calculator'; const HANDLE_GAS = 100_000; const SUGGESTED_GAS_PRICE = 10; diff --git a/typescript/sdk/src/gas/calculator.ts b/typescript/sdk/src/gas/calculator.ts index 762020225..ad9b5b598 100644 --- a/typescript/sdk/src/gas/calculator.ts +++ b/typescript/sdk/src/gas/calculator.ts @@ -1,12 +1,14 @@ -import { AbacusCore, MultiProvider, chainMetadata } from '..'; import { BigNumber, FixedNumber, ethers } from 'ethers'; import { utils } from '@abacus-network/utils'; +import { chainMetadata } from '../consts/chainMetadata'; +import { AbacusCore } from '../core/AbacusCore'; +import { MultiProvider } from '../providers/MultiProvider'; import { ChainName, Remotes } from '../types'; +import { convertDecimalValue, mulBigAndFixed } from '../utils/number'; import { DefaultTokenPriceGetter, TokenPriceGetter } from './token-prices'; -import { convertDecimalValue, mulBigAndFixed } from './utils'; /** * A note on arithmetic: diff --git a/typescript/sdk/src/gas/index.ts b/typescript/sdk/src/gas/index.ts deleted file mode 100644 index 2f47e6d7c..000000000 --- a/typescript/sdk/src/gas/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { InterchainGasCalculator } from './calculator'; -export { DefaultTokenPriceGetter, TokenPriceGetter } from './token-prices'; diff --git a/typescript/sdk/src/index.ts b/typescript/sdk/src/index.ts index d15fad48c..58cb774e0 100644 --- a/typescript/sdk/src/index.ts +++ b/typescript/sdk/src/index.ts @@ -1,6 +1,24 @@ -export { AbacusApp } from './app'; -export { chainMetadata } from './chain-metadata'; -export { addSignerToConnection, chainConnectionConfigs } from './chains'; +export { AllChains, Chains } from './consts/chains'; +export { chainMetadata } from './consts/chainMetadata'; +export { chainConnectionConfigs } from './consts/chainConnectionConfigs'; +export { environments as coreEnvironments } from './consts/environments'; + +export { + ChainMap, + ChainName, + CompleteChainMap, + Connection, + NameOrDomain, + RemoteChainMap, + Remotes, + TestChainNames, + IChainConnection, +} from './types'; + +export { ChainNameToDomainId, DomainIdToChainName } from './domains'; + +export { AbacusApp } from './AbacusApp'; + export { AbacusAddresses, AbacusContracts, @@ -9,56 +27,77 @@ export { connectContracts, serializeContracts, } from './contracts'; + +export { + Annotated, + getEvents, + queryAnnotatedEvents, + TSContract, +} from './events'; + +export { BeaconProxyAddresses, ProxiedContract, ProxyAddresses } from './proxy'; + +export { Router, RouterContracts, RouterFactories } from './router'; + +export { ChainConnection } from './providers/ChainConnection'; +export { MultiProvider } from './providers/MultiProvider'; +export { RetryJsonRpcProvider, RetryProvider } from './providers/RetryProvider'; + +export { AbacusCore, CoreContractsMap } from './core/AbacusCore'; export { - AbacusCore, - AbacusLifecyleEvent, - AbacusMessage, - AbacusStatus, - AnnotatedDispatch, - AnnotatedLifecycleEvent, CoreContracts, - CoreContractsMap, - coreEnvironments, coreFactories, InboxContracts, - MessageStatus, OutboxContracts, +} from './core/contracts'; +export { + AbacusLifecyleEvent, + AnnotatedDispatch, + AnnotatedLifecycleEvent, +} from './core/events'; +export { + AbacusMessage, + AbacusStatus, + MessageStatus, resolveDomain, resolveId, resolveNetworks, -} from './core'; -export { RetryJsonRpcProvider, RetryProvider } from './ethers'; +} from './core/message'; export { - Annotated, - getEvents, - queryAnnotatedEvents, - TSContract, -} from './events'; + TestCoreApp, + TestCoreContracts, + TestInboxContracts, + TestOutboxContracts, +} from './core/TestCoreApp'; +export { TestCoreDeployer } from './core/TestCoreDeployer'; + +export { InterchainGasCalculator } from './gas/calculator'; +export { DefaultTokenPriceGetter, TokenPriceGetter } from './gas/token-prices'; + +export { AbacusAppChecker, Ownable } from './deploy/AbacusAppChecker'; +export { CheckerViolation, EnvironmentConfig } from './deploy/types'; +export { AbacusCoreDeployer } from './deploy/core/AbacusCoreDeployer'; +export { AbacusCoreChecker } from './deploy/core/AbacusCoreChecker'; export { - DefaultTokenPriceGetter, - InterchainGasCalculator, - TokenPriceGetter, -} from './gas'; -export { ChainConnection, IChainConnection, MultiProvider } from './provider'; -export { BeaconProxyAddresses, ProxiedContract, ProxyAddresses } from './proxy'; -export { - ConnectionClientConfig, - Router, - RouterContracts, - RouterFactories, -} from './router'; + CoreConfig, + CoreViolationType, + ValidatorManagerConfig, + ValidatorManagerViolation, + ValidatorViolation, + ValidatorViolationType, +} from './deploy/core/types'; +export { AbacusDeployer } from './deploy/AbacusDeployer'; +export { UpgradeBeaconViolation } from './deploy/proxy'; +export { AbacusRouterDeployer } from './deploy/router/AbacusRouterDeployer'; +export { AbacusRouterChecker } from './deploy/router/AbacusRouterChecker'; +export { RouterConfig } from './deploy/router/types'; +export { getMultiProviderFromConfigAndSigner } from './deploy/utils'; +export { ContractVerifier } from './deploy/verify/ContractVerifier'; export { - AllChains, - ChainMap, - ChainName, - ChainNameToDomainId, - Chains, - CompleteChainMap, - Connection, - DomainIdToChainName, - NameOrDomain, - RemoteChainMap, - Remotes, - TestChainNames, -} from './types'; -export { objMap, objMapEntries, promiseObjAll, utils } from './utils'; + ContractVerificationInput, + VerificationInput, +} from './deploy/verify/types'; +export * as verificationUtils from './deploy/verify/utils'; + +export { objMap, objMapEntries, promiseObjAll } from './utils'; +export * as utils from './utils'; diff --git a/typescript/sdk/src/provider.ts b/typescript/sdk/src/providers/ChainConnection.ts similarity index 61% rename from typescript/sdk/src/provider.ts rename to typescript/sdk/src/providers/ChainConnection.ts index f96515f40..7d31b3ac4 100644 --- a/typescript/sdk/src/provider.ts +++ b/typescript/sdk/src/providers/ChainConnection.ts @@ -1,16 +1,7 @@ import { Debugger, debug } from 'debug'; import { ethers } from 'ethers'; -import { ChainMap, ChainName } from './types'; -import { MultiGeneric, objMap } from './utils'; - -export interface IChainConnection { - provider: ethers.providers.Provider; - signer?: ethers.Signer; - overrides?: ethers.Overrides; - confirmations?: number; - blockExplorerUrl?: string; -} +import { IChainConnection } from '../types'; export class ChainConnection { provider: ethers.providers.Provider; @@ -56,23 +47,3 @@ export class ChainConnection { return response.wait(this.confirmations); } } - -export class MultiProvider< - Chain extends ChainName = ChainName, -> extends MultiGeneric { - constructor(chainConnectionConfigs: ChainMap) { - super( - objMap( - chainConnectionConfigs, - (_, connection) => new ChainConnection(connection), - ), - ); - } - getChainConnection(chain: Chain): ChainMap[Chain] { - return this.get(chain); - } - // This doesn't work on hardhat providers so we skip for now - // ready() { - // return Promise.all(this.values().map((dc) => dc.provider!.ready)); - // } -} diff --git a/typescript/sdk/src/providers/MultiProvider.ts b/typescript/sdk/src/providers/MultiProvider.ts new file mode 100644 index 000000000..fcc5580f1 --- /dev/null +++ b/typescript/sdk/src/providers/MultiProvider.ts @@ -0,0 +1,24 @@ +import { ChainMap, ChainName, IChainConnection } from '../types'; +import { MultiGeneric, objMap } from '../utils'; + +import { ChainConnection } from './ChainConnection'; + +export class MultiProvider< + Chain extends ChainName = ChainName, +> extends MultiGeneric { + constructor(chainConnectionConfigs: ChainMap) { + super( + objMap( + chainConnectionConfigs, + (_, connection) => new ChainConnection(connection), + ), + ); + } + getChainConnection(chain: Chain): ChainMap[Chain] { + return this.get(chain); + } + // This doesn't work on hardhat providers so we skip for now + // ready() { + // return Promise.all(this.values().map((dc) => dc.provider!.ready)); + // } +} diff --git a/typescript/sdk/src/ethers/retry-provider.ts b/typescript/sdk/src/providers/RetryProvider.ts similarity index 74% rename from typescript/sdk/src/ethers/retry-provider.ts rename to typescript/sdk/src/providers/RetryProvider.ts index 9fbd20b01..1fd6d6a40 100644 --- a/typescript/sdk/src/ethers/retry-provider.ts +++ b/typescript/sdk/src/providers/RetryProvider.ts @@ -2,22 +2,21 @@ // // Mostly taken from the removed version that was in ethers.js // See: https://github.com/ethers-io/ethers.js/discussions/3006 -import { BaseProvider, JsonRpcProvider } from '@ethersproject/providers'; import { ethers } from 'ethers'; -import { retryAsync } from '@abacus-network/utils/dist/src/utils'; +import { utils } from '@abacus-network/utils'; export type RetryOptions = { // The wait interval in between interval: number; - // Maximum number of times to rety + // Maximum number of times to retry retryLimit: number; }; -export class RetryProvider extends BaseProvider { +export class RetryProvider extends ethers.providers.BaseProvider { constructor( - readonly provider: BaseProvider, + readonly provider: ethers.providers.BaseProvider, readonly retryOptions: RetryOptions, ) { super(provider.getNetwork()); @@ -27,7 +26,7 @@ export class RetryProvider extends BaseProvider { // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types perform(method: string, params: any): Promise { - return retryAsync( + return utils.retryAsync( () => this.provider.perform(method, params), this.retryOptions.retryLimit, this.retryOptions.interval, @@ -36,16 +35,16 @@ export class RetryProvider extends BaseProvider { } // Need this separate class for JsonRpcProvider to still expose `getSigner`, so will retry at the request level -export class RetryJsonRpcProvider extends JsonRpcProvider { +export class RetryJsonRpcProvider extends ethers.providers.JsonRpcProvider { constructor( - readonly provider: JsonRpcProvider, + readonly provider: ethers.providers.JsonRpcProvider, readonly retryOptions: RetryOptions, ) { super(provider.connection, provider.network); } async send(method: string, params: Array): Promise { - return retryAsync( + return utils.retryAsync( async () => this.provider.send(method, params), this.retryOptions.retryLimit, this.retryOptions.interval, diff --git a/typescript/sdk/src/proxy.ts b/typescript/sdk/src/proxy.ts index 3e42d0de8..248980cf9 100644 --- a/typescript/sdk/src/proxy.ts +++ b/typescript/sdk/src/proxy.ts @@ -1,6 +1,6 @@ import { Contract } from 'ethers'; -import { types } from '@abacus-network/utils'; +import type { types } from '@abacus-network/utils'; import { Connection } from './types'; diff --git a/typescript/sdk/src/router.ts b/typescript/sdk/src/router.ts index 8a9a022b9..6fed63f07 100644 --- a/typescript/sdk/src/router.ts +++ b/typescript/sdk/src/router.ts @@ -1,7 +1,7 @@ -import { ethers } from 'ethers'; +import type { ethers } from 'ethers'; import { Router } from '@abacus-network/app'; -import { types } from '@abacus-network/utils'; +import type { types } from '@abacus-network/utils'; import { AbacusContracts, AbacusFactories } from './contracts'; diff --git a/typescript/sdk/src/test/.eslintrc b/typescript/sdk/src/test/.eslintrc new file mode 100644 index 000000000..ba8754a12 --- /dev/null +++ b/typescript/sdk/src/test/.eslintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/explicit-module-boundary-types": ["off"] + } +} diff --git a/typescript/sdk/test/utils.ts b/typescript/sdk/src/test/testUtils.ts similarity index 97% rename from typescript/sdk/test/utils.ts rename to typescript/sdk/src/test/testUtils.ts index f16bd2068..876baf5a0 100644 --- a/typescript/sdk/test/utils.ts +++ b/typescript/sdk/src/test/testUtils.ts @@ -1,6 +1,6 @@ import { FixedNumber, ethers } from 'ethers'; -import { ChainMap, ChainName } from '../src'; +import { ChainMap, ChainName } from '../types'; const MOCK_NETWORK = { name: 'MockNetwork', diff --git a/typescript/sdk/src/types.ts b/typescript/sdk/src/types.ts index 62a318349..fc570a078 100644 --- a/typescript/sdk/src/types.ts +++ b/typescript/sdk/src/types.ts @@ -1,52 +1,12 @@ -import { ethers } from 'ethers'; +import type { ethers } from 'ethers'; -import { chainMetadata } from './chain-metadata'; +import type { Chains } from './consts/chains'; -/** - * RPC Pagination information for Polygon - */ -export interface Pagination { - blocks: number; - from: number; -} - -/** - * Enumeration of Abacus supported chains - */ -export enum Chains { // must be string type to be used with Object.keys - arbitrum = 'arbitrum', - alfajores = 'alfajores', - bsc = 'bsc', - mumbai = 'mumbai', - kovan = 'kovan', - goerli = 'goerli', - fuji = 'fuji', - celo = 'celo', - ethereum = 'ethereum', - avalanche = 'avalanche', - optimism = 'optimism', - polygon = 'polygon', - bsctestnet = 'bsctestnet', - arbitrumrinkeby = 'arbitrumrinkeby', - optimismkovan = 'optimismkovan', - auroratestnet = 'auroratestnet', - test1 = 'test1', - test2 = 'test2', - test3 = 'test3', -} export type ChainName = keyof typeof Chains; export type CompleteChainMap = Record; export type ChainMap = Record; - export type TestChainNames = 'test1' | 'test2' | 'test3'; -export const AllChains = Object.keys(Chains) as ChainName[]; -export const DomainIdToChainName = Object.fromEntries( - AllChains.map((chain) => [chainMetadata[chain].id, chain]), -); -export const ChainNameToDomainId = Object.fromEntries( - AllChains.map((chain) => [chain, chainMetadata[chain].id]), -) as CompleteChainMap; export type NameOrDomain = ChainName | number; export type Remotes< @@ -60,14 +20,12 @@ export type RemoteChainMap< Value, > = Record, Value>; -/** - * A Domain (and its characteristics) - */ -export type ChainMetadata = { - id: number; - finalityBlocks: number; - nativeTokenDecimals?: number; - paginate?: Pagination; -}; - export type Connection = ethers.providers.Provider | ethers.Signer; + +export interface IChainConnection { + provider: ethers.providers.Provider; + signer?: ethers.Signer; + overrides?: ethers.Overrides; + confirmations?: number; + blockExplorerUrl?: string; +} diff --git a/typescript/sdk/src/utils.ts b/typescript/sdk/src/utils.ts deleted file mode 100644 index 3c431d2a9..000000000 --- a/typescript/sdk/src/utils.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import { BytesLike, arrayify, hexlify } from '@ethersproject/bytes'; -import { ethers } from 'ethers'; - -import { ChainMap, ChainName, Remotes } from './types'; - -export type Address = string; - -/** - * Converts a 20-byte (or other length) ID to a 32-byte ID. - * Ensures that a bytes-like is 32 long. left-padding with 0s if not. - * - * @param data A string or array of bytes to canonize - * @returns A Uint8Array of length 32 - */ -export function canonizeId(data: BytesLike): Uint8Array { - if (!data) throw new Error('Bad input. Undefined'); - const buf = ethers.utils.arrayify(data); - if (buf.length > 32) { - throw new Error('Too long'); - } - if (buf.length !== 20 && buf.length != 32) { - throw new Error('bad input, expect address or bytes32'); - } - return ethers.utils.zeroPad(buf, 32); -} - -/** - * Converts an Abacus ID of 20 or 32 bytes to the corresponding EVM Address. - * - * For 32-byte IDs this enforces the EVM convention of using the LAST 20 bytes. - * - * @param data The data to truncate - * @returns A 20-byte, 0x-prepended hex string representing the EVM Address - * @throws if the data is not 20 or 32 bytes - */ -export function evmId(data: BytesLike): Address { - const u8a = arrayify(data); - - if (u8a.length === 32) { - return hexlify(u8a.slice(12, 32)); - } else if (u8a.length === 20) { - return hexlify(u8a); - } else { - throw new Error(`Invalid id length. expected 20 or 32. Got ${u8a.length}`); - } -} - -/** - * Sleep async for some time. - * - * @param ms the number of milliseconds to sleep - * @returns A delay promise - */ -export function delay(ms: number): Promise { - return new Promise((resolve) => setTimeout(resolve, ms)); -} - -export class MultiGeneric { - constructor(protected readonly chainMap: ChainMap) {} - - protected get(chain: Chain) { - return this.chainMap[chain]; - } - - protected set(chain: Chain, value: Value) { - this.chainMap[chain] = value; - } - - chains = () => Object.keys(this.chainMap) as Chain[]; - - apply(fn: (n: Chain, dc: Value) => void) { - for (const chain of this.chains()) { - fn(chain, this.chainMap[chain]); - } - } - - map(fn: (n: Chain, dc: Value) => Output) { - const entries: [Chain, Output][] = []; - const chains = this.chains(); - for (const chain of chains) { - entries.push([chain, fn(chain, this.chainMap[chain])]); - } - return Object.fromEntries(entries) as Record; - } - - remoteChains = (name: LocalChain) => - this.chains().filter((key) => key !== name) as Remotes[]; - - extendWithChain = >( - chain: New, - value: Value, - ) => - new MultiGeneric({ - ...this.chainMap, - [chain]: value, - }); - - knownChain = (chain: ChainName) => chain in this.chainMap; -} - -export function inferChainMap(map: M) { - return map as M extends ChainMap - ? Record - : never; -} - -export function objMapEntries( - obj: Record, - func: (k: K, _: I) => O, -): [K, O][] { - return Object.entries(obj).map(([k, v]) => [k as K, func(k as K, v)]); -} - -// Map over the values of the object -export function objMap( - obj: Record, - func: (k: K, _: I) => O, -) { - return Object.fromEntries(objMapEntries(obj, func)) as Record< - K, - O - >; -} - -// promiseObjectAll :: {k: Promise a} -> Promise {k: a} -export const promiseObjAll = (object: { - [key in K]: Promise; -}): Promise> => { - const promiseList = Object.entries(object).map(([name, promise]) => - (promise as Promise).then((result) => [name, result]), - ); - return Promise.all(promiseList).then(Object.fromEntries); -}; - -export const utils = { - objMap, - promiseObjAll, - canonizeId, - evmId, - delay, -}; diff --git a/typescript/sdk/src/utils/.eslintrc b/typescript/sdk/src/utils/.eslintrc new file mode 100644 index 000000000..ba8754a12 --- /dev/null +++ b/typescript/sdk/src/utils/.eslintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/explicit-module-boundary-types": ["off"] + } +} diff --git a/typescript/sdk/src/utils/MultiGeneric.ts b/typescript/sdk/src/utils/MultiGeneric.ts new file mode 100644 index 000000000..5f90bab53 --- /dev/null +++ b/typescript/sdk/src/utils/MultiGeneric.ts @@ -0,0 +1,44 @@ +import { ChainMap, ChainName, Remotes } from '../types'; + +export class MultiGeneric { + constructor(protected readonly chainMap: ChainMap) {} + + protected get(chain: Chain) { + return this.chainMap[chain]; + } + + protected set(chain: Chain, value: Value) { + this.chainMap[chain] = value; + } + + chains = () => Object.keys(this.chainMap) as Chain[]; + + apply(fn: (n: Chain, dc: Value) => void) { + for (const chain of this.chains()) { + fn(chain, this.chainMap[chain]); + } + } + + map(fn: (n: Chain, dc: Value) => Output) { + const entries: [Chain, Output][] = []; + const chains = this.chains(); + for (const chain of chains) { + entries.push([chain, fn(chain, this.chainMap[chain])]); + } + return Object.fromEntries(entries) as Record; + } + + remoteChains = (name: LocalChain) => + this.chains().filter((key) => key !== name) as Remotes[]; + + extendWithChain = >( + chain: New, + value: Value, + ) => + new MultiGeneric({ + ...this.chainMap, + [chain]: value, + }); + + knownChain = (chain: ChainName) => chain in this.chainMap; +} diff --git a/typescript/sdk/src/utils/ids.ts b/typescript/sdk/src/utils/ids.ts new file mode 100644 index 000000000..caee32027 --- /dev/null +++ b/typescript/sdk/src/utils/ids.ts @@ -0,0 +1,41 @@ +import { BytesLike, ethers } from 'ethers'; + +/** + * Converts a 20-byte (or other length) ID to a 32-byte ID. + * Ensures that a bytes-like is 32 long. left-padding with 0s if not. + * + * @param data A string or array of bytes to canonize + * @returns A Uint8Array of length 32 + */ +export function canonizeId(data: BytesLike): Uint8Array { + if (!data) throw new Error('Bad input. Undefined'); + const buf = ethers.utils.arrayify(data); + if (buf.length > 32) { + throw new Error('Too long'); + } + if (buf.length !== 20 && buf.length != 32) { + throw new Error('bad input, expect address or bytes32'); + } + return ethers.utils.zeroPad(buf, 32); +} + +/** + * Converts an Abacus ID of 20 or 32 bytes to the corresponding EVM Address. + * + * For 32-byte IDs this enforces the EVM convention of using the LAST 20 bytes. + * + * @param data The data to truncate + * @returns A 20-byte, 0x-prepended hex string representing the EVM Address + * @throws if the data is not 20 or 32 bytes + */ +export function evmId(data: BytesLike): string { + const u8a = ethers.utils.arrayify(data); + + if (u8a.length === 32) { + return ethers.utils.hexlify(u8a.slice(12, 32)); + } else if (u8a.length === 20) { + return ethers.utils.hexlify(u8a); + } else { + throw new Error(`Invalid id length. expected 20 or 32. Got ${u8a.length}`); + } +} diff --git a/typescript/sdk/src/utils/index.ts b/typescript/sdk/src/utils/index.ts new file mode 100644 index 000000000..3f0212255 --- /dev/null +++ b/typescript/sdk/src/utils/index.ts @@ -0,0 +1,6 @@ +export * from './ids'; +export * from './MultiGeneric'; +export * from './number'; +export * from './objects'; +export * from './sets'; +export * from './time'; diff --git a/typescript/sdk/src/gas/utils.ts b/typescript/sdk/src/utils/number.ts similarity index 100% rename from typescript/sdk/src/gas/utils.ts rename to typescript/sdk/src/utils/number.ts diff --git a/typescript/sdk/src/utils/objects.ts b/typescript/sdk/src/utils/objects.ts new file mode 100644 index 000000000..c3c321505 --- /dev/null +++ b/typescript/sdk/src/utils/objects.ts @@ -0,0 +1,29 @@ +// TODO move to utils package + +export function objMapEntries( + obj: Record, + func: (k: K, _: I) => O, +): [K, O][] { + return Object.entries(obj).map(([k, v]) => [k as K, func(k as K, v)]); +} + +// Map over the values of the object +export function objMap( + obj: Record, + func: (k: K, _: I) => O, +) { + return Object.fromEntries(objMapEntries(obj, func)) as Record< + K, + O + >; +} + +// promiseObjectAll :: {k: Promise a} -> Promise {k: a} +export const promiseObjAll = (object: { + [key in K]: Promise; +}): Promise> => { + const promiseList = Object.entries(object).map(([name, promise]) => + (promise as Promise).then((result) => [name, result]), + ); + return Promise.all(promiseList).then(Object.fromEntries); +}; diff --git a/typescript/sdk/src/utils/sets.ts b/typescript/sdk/src/utils/sets.ts new file mode 100644 index 000000000..630872955 --- /dev/null +++ b/typescript/sdk/src/utils/sets.ts @@ -0,0 +1,11 @@ +// TODO move to utils package + +// Returns a \ b +// Taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#implementing_basic_set_operations +export function setDifference(a: Set, b: Set) { + const diff = new Set(a); + for (const element of b) { + diff.delete(element); + } + return diff; +} diff --git a/typescript/sdk/src/utils/time.ts b/typescript/sdk/src/utils/time.ts new file mode 100644 index 000000000..dd12db099 --- /dev/null +++ b/typescript/sdk/src/utils/time.ts @@ -0,0 +1,11 @@ +// TODO move to utils package + +/** + * Sleep async for some time. + * + * @param ms the number of milliseconds to sleep + * @returns A delay promise + */ +export function delay(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)); +} diff --git a/typescript/sdk/test/utils.test.ts b/typescript/sdk/src/utils/utils.test.ts similarity index 94% rename from typescript/sdk/test/utils.test.ts rename to typescript/sdk/src/utils/utils.test.ts index 03f7c191b..fa5dff527 100644 --- a/typescript/sdk/test/utils.test.ts +++ b/typescript/sdk/src/utils/utils.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { BigNumber, FixedNumber } from 'ethers'; -import { bigToFixed, fixedToBig, mulBigAndFixed } from '../src/gas/utils'; +import { bigToFixed, fixedToBig, mulBigAndFixed } from './number'; describe('utils', () => { describe('bigToFixed', () => { diff --git a/typescript/sdk/tsconfig.json b/typescript/sdk/tsconfig.json index 119d63d25..8d537a5b6 100644 --- a/typescript/sdk/tsconfig.json +++ b/typescript/sdk/tsconfig.json @@ -4,6 +4,5 @@ "outDir": "./dist/", "rootDir": "./src/" }, - "exclude": ["./node_modules/", "./dist/", "./test/"], - "include": ["./src/*.ts", "./src/**/*.ts"] + "include": ["./src/**/*.ts", "./src/*.d.ts"], } diff --git a/typescript/utils/package.json b/typescript/utils/package.json index ff415630a..24836110f 100644 --- a/typescript/utils/package.json +++ b/typescript/utils/package.json @@ -1,12 +1,12 @@ { "name": "@abacus-network/utils", "description": "General utilities for the Abacus network", - "version": "0.2.3", + "version": "0.3.1", "dependencies": { - "chai": "^4.3.0", "ethers": "^5.6.8" }, "devDependencies": { + "chai": "^4.3.0", "prettier": "^2.4.1", "typescript": "^4.7.2" }, @@ -22,6 +22,7 @@ "repository": "https://github.com/abacus-network/abacus-monorepo", "scripts": { "build": "tsc", + "clean": "rm -rf ./dist", "check": "tsc --noEmit", "prettier": "prettier --write ./src" }, diff --git a/typescript/utils/src/utils.ts b/typescript/utils/src/utils.ts index 7c3a09f97..2baaf32b9 100644 --- a/typescript/utils/src/utils.ts +++ b/typescript/utils/src/utils.ts @@ -1,9 +1,17 @@ -import { arrayify, hexlify } from '@ethersproject/bytes'; -import { assert } from 'chai'; -import { ethers } from 'ethers'; +import { ethers, utils } from 'ethers'; import { Address, Domain, HexString, ParsedMessage } from './types'; +export function assert(predicate: any, errorMessage?: string) { + if (!predicate) { + throw new Error(errorMessage ?? 'Error'); + } +} + +export function deepEquals(v1: any, v2: any) { + return JSON.stringify(v1) === JSON.stringify(v2); +} + /* * Gets the byte length of a hex string * @@ -73,12 +81,12 @@ export const formatMessage = ( * @returns */ export function parseMessage(message: string): ParsedMessage { - const buf = Buffer.from(arrayify(message)); + const buf = Buffer.from(utils.arrayify(message)); const origin = buf.readUInt32BE(0); - const sender = hexlify(buf.slice(4, 36)); + const sender = utils.hexlify(buf.slice(4, 36)); const destination = buf.readUInt32BE(36); - const recipient = hexlify(buf.slice(40, 72)); - const body = hexlify(buf.slice(72)); + const recipient = utils.hexlify(buf.slice(40, 72)); + const body = utils.hexlify(buf.slice(72)); return { origin, sender, destination, recipient, body }; } @@ -112,8 +120,8 @@ export function sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); } -// Retries an async function when it raises an exeption -// if all the tries fail it raises the last thrown exeption +// Retries an async function when it raises an exception +// if all the tries fail it raises the last thrown exception export async function retryAsync( runner: () => T, attempts = 3, diff --git a/yarn.lock b/yarn.lock index 2a34d4d25..e2d90b7a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,12 +5,12 @@ __metadata: version: 6 cacheKey: 8 -"@abacus-network/app@0.2.3, @abacus-network/app@^0.2.3, @abacus-network/app@workspace:solidity/app": +"@abacus-network/app@0.3.1, @abacus-network/app@workspace:solidity/app": version: 0.0.0-use.local resolution: "@abacus-network/app@workspace:solidity/app" dependencies: - "@abacus-network/core": ^0.2.3 - "@abacus-network/utils": ^0.2.3 + "@abacus-network/core": 0.3.1 + "@abacus-network/utils": 0.3.1 "@nomiclabs/hardhat-ethers": ^2.0.1 "@nomiclabs/hardhat-waffle": ^2.0.1 "@openzeppelin/contracts-upgradeable": ^4.5.0 @@ -42,11 +42,11 @@ __metadata: languageName: node linkType: hard -"@abacus-network/core@^0.2.3, @abacus-network/core@workspace:solidity/core": +"@abacus-network/core@0.3.1, @abacus-network/core@workspace:solidity/core": version: 0.0.0-use.local resolution: "@abacus-network/core@workspace:solidity/core" dependencies: - "@abacus-network/utils": ^0.2.3 + "@abacus-network/utils": 0.3.1 "@nomiclabs/hardhat-ethers": ^2.0.1 "@nomiclabs/hardhat-waffle": ^2.0.1 "@openzeppelin/contracts": ^4.6.0 @@ -70,55 +70,14 @@ __metadata: languageName: unknown linkType: soft -"@abacus-network/deploy@^0.2.3, @abacus-network/deploy@workspace:typescript/deploy": - version: 0.0.0-use.local - resolution: "@abacus-network/deploy@workspace:typescript/deploy" - dependencies: - "@abacus-network/app": ^0.2.3 - "@abacus-network/core": ^0.2.3 - "@abacus-network/sdk": ^0.2.3 - "@abacus-network/utils": ^0.2.3 - "@types/debug": ^4.1.7 - "@types/node": ^16.9.1 - "@types/yargs": ^17.0.10 - axios: ^0.21.3 - debug: ^4.3.4 - ethers: ^5.6.8 - prettier: ^2.4.1 - ts-node: ^10.8.0 - typescript: ^4.7.2 - yargs: ^17.4.1 - languageName: unknown - linkType: soft - -"@abacus-network/hardhat@workspace:typescript/hardhat": - version: 0.0.0-use.local - resolution: "@abacus-network/hardhat@workspace:typescript/hardhat" +"@abacus-network/helloworld@npm:0.3.1-beta0": + version: 0.3.1-beta0 + resolution: "@abacus-network/helloworld@npm:0.3.1-beta0" dependencies: - "@abacus-network/core": ^0.2.3 - "@abacus-network/deploy": ^0.2.3 - "@abacus-network/sdk": ^0.2.3 - "@abacus-network/utils": ^0.2.3 - "@nomiclabs/hardhat-ethers": ^2.0.5 - "@nomiclabs/hardhat-waffle": ^2.0.2 - ethereum-waffle: ^3.2.2 - ethers: ^5.6.8 - hardhat: ^2.8.4 - prettier: ^2.4.1 - ts-node: ^10.8.0 - typescript: ^4.7.2 - languageName: unknown - linkType: soft - -"@abacus-network/helloworld@npm:0.2.4": - version: 0.2.4 - resolution: "@abacus-network/helloworld@npm:0.2.4" - dependencies: - "@abacus-network/app": 0.2.3 - "@abacus-network/sdk": 0.2.3 + "@abacus-network/sdk": ^0.3.1-beta0 "@openzeppelin/contracts-upgradeable": ^4.6.0 ethers: ^5.4.7 - checksum: 0cc987e6d0f762ac520571ebd431d48de0519e33ba1dee9d90c2d95357baf096827f7e74908ea5ec5445e867a41120a7fbb6fd20465f8aa42669a6b5e18dc253 + checksum: 21114292ef0eb5408405f217942524ef54e379e189120edae94a4a2d2739a5c21edbfd98210831b309ca9a0118640c7ae231d13179f13c503ed94714a91c3055 languageName: node linkType: hard @@ -127,10 +86,8 @@ __metadata: resolution: "@abacus-network/infra@workspace:typescript/infra" dependencies: "@abacus-network/celo-ethers-provider": ^0.1.0 - "@abacus-network/core": ^0.2.3 - "@abacus-network/deploy": ^0.2.3 - "@abacus-network/helloworld": 0.2.4 - "@abacus-network/sdk": ^0.2.3 + "@abacus-network/helloworld": 0.3.1-beta0 + "@abacus-network/sdk": 0.3.1 "@aws-sdk/client-iam": ^3.74.0 "@aws-sdk/client-kms": 3.48.0 "@aws-sdk/client-s3": ^3.74.0 @@ -170,19 +127,26 @@ __metadata: languageName: unknown linkType: soft -"@abacus-network/sdk@0.2.3, @abacus-network/sdk@^0.2.3, @abacus-network/sdk@workspace:typescript/sdk": +"@abacus-network/sdk@0.3.1, @abacus-network/sdk@^0.3.1-beta0, @abacus-network/sdk@workspace:typescript/sdk": version: 0.0.0-use.local resolution: "@abacus-network/sdk@workspace:typescript/sdk" dependencies: - "@abacus-network/app": ^0.2.3 + "@abacus-network/app": 0.3.1 "@abacus-network/celo-ethers-provider": ^0.1.0 - "@abacus-network/core": ^0.2.3 - "@abacus-network/utils": ^0.2.3 + "@abacus-network/core": 0.3.1 + "@abacus-network/utils": 0.3.1 + "@nomiclabs/hardhat-ethers": ^2.0.5 + "@nomiclabs/hardhat-waffle": ^2.0.2 + "@types/debug": ^4.1.7 "@types/node": ^16.9.1 chai: ^4.3.6 + cross-fetch: ^3.1.5 + debug: ^4.3.4 dotenv: ^10.0.0 + ethereum-waffle: ^3.2.2 ethers: ^5.6.8 fs: 0.0.1-security + hardhat: ^2.8.4 mocha: ^9.2.2 prettier: ^2.4.1 sinon: ^13.0.2 @@ -190,7 +154,7 @@ __metadata: languageName: unknown linkType: soft -"@abacus-network/utils@^0.2.3, @abacus-network/utils@workspace:typescript/utils": +"@abacus-network/utils@0.3.1, @abacus-network/utils@workspace:typescript/utils": version: 0.0.0-use.local resolution: "@abacus-network/utils@workspace:typescript/utils" dependencies: @@ -4497,15 +4461,6 @@ __metadata: languageName: node linkType: hard -"axios@npm:^0.21.3": - version: 0.21.4 - resolution: "axios@npm:0.21.4" - dependencies: - follow-redirects: ^1.14.0 - checksum: 44245f24ac971e7458f3120c92f9d66d1fc695e8b97019139de5b0cc65d9b8104647db01e5f46917728edfc0cfd88eb30fc4c55e6053eef4ace76768ce95ff3c - languageName: node - linkType: hard - "babel-code-frame@npm:^6.26.0": version: 6.26.0 resolution: "babel-code-frame@npm:6.26.0" @@ -6347,6 +6302,15 @@ __metadata: languageName: node linkType: hard +"cross-fetch@npm:^3.1.5": + version: 3.1.5 + resolution: "cross-fetch@npm:3.1.5" + dependencies: + node-fetch: 2.6.7 + checksum: f6b8c6ee3ef993ace6277fd789c71b6acf1b504fd5f5c7128df4ef2f125a429e29cd62dc8c127523f04a5f2fa4771ed80e3f3d9695617f441425045f505cf3bb + languageName: node + linkType: hard + "cross-spawn@npm:^6.0.5": version: 6.0.5 resolution: "cross-spawn@npm:6.0.5" @@ -8373,7 +8337,7 @@ __metadata: languageName: node linkType: hard -"follow-redirects@npm:^1.12.1, follow-redirects@npm:^1.14.0": +"follow-redirects@npm:^1.12.1": version: 1.15.1 resolution: "follow-redirects@npm:1.15.1" peerDependenciesMeta: @@ -11902,7 +11866,7 @@ __metadata: languageName: node linkType: hard -"node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.7": +"node-fetch@npm:2.6.7, node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.7": version: 2.6.7 resolution: "node-fetch@npm:2.6.7" dependencies: