Remove typechain package (#238)

asaj/sdk-proposal
Asa Oines 3 years ago committed by GitHub
parent f04959a57b
commit 9527f362d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 230
      package-lock.json
  2. 1
      package.json
  3. 3
      solidity/abacus-core/.gitignore
  4. 2
      solidity/abacus-core/hardhat.config.ts
  5. 13
      solidity/abacus-core/package.json
  6. 2
      solidity/abacus-core/test/common.test.ts
  7. 3
      solidity/abacus-core/test/inbox.test.ts
  8. 3
      solidity/abacus-core/test/lib/AbacusDeployment.ts
  9. 3
      solidity/abacus-core/test/lib/upgrade.ts
  10. 2
      solidity/abacus-core/test/merkle.test.ts
  11. 2
      solidity/abacus-core/test/message.test.ts
  12. 3
      solidity/abacus-core/test/outbox.test.ts
  13. 2
      solidity/abacus-core/test/upgrade.test.ts
  14. 2
      solidity/abacus-core/test/validatorManager.test.ts
  15. 9
      solidity/abacus-core/test/xAppConnectionManager.test.ts
  16. 83
      solidity/abacus-core/tsconfig.json
  17. 3
      solidity/abacus-xapps/.gitignore
  18. 10
      solidity/abacus-xapps/contracts/bridge/BridgeRouter.sol
  19. 4
      solidity/abacus-xapps/contracts/bridge/BridgeToken.sol
  20. 2
      solidity/abacus-xapps/contracts/bridge/ETHHelper.sol
  21. 6
      solidity/abacus-xapps/contracts/bridge/TokenRegistry.sol
  22. 6
      solidity/abacus-xapps/contracts/governance/GovernanceRouter.sol
  23. 4
      solidity/abacus-xapps/contracts/ping-pong/PingPongRouter.sol
  24. 4
      solidity/abacus-xapps/contracts/xapp-template/RouterTemplate.sol
  25. 2
      solidity/abacus-xapps/hardhat.config.ts
  26. 13
      solidity/abacus-xapps/package.json
  27. 484
      solidity/abacus-xapps/recoveryManager.test.ts
  28. 2
      solidity/abacus-xapps/test/bridge/BridgeToken.test.ts
  29. 34
      solidity/abacus-xapps/test/bridge/EthHelper.test.ts
  30. 39
      solidity/abacus-xapps/test/bridge/bridge.test.ts
  31. 2
      solidity/abacus-xapps/test/bridge/bridgeMessage.test.ts
  32. 2
      solidity/abacus-xapps/test/bridge/encoding.test.ts
  33. 7
      solidity/abacus-xapps/test/bridge/lib/BridgeDeploy.ts
  34. 130
      solidity/abacus-xapps/test/bridge/lib/BridgeDeployment.ts
  35. 2
      solidity/abacus-xapps/test/bridge/lib/permit.ts
  36. 10
      solidity/abacus-xapps/test/bridge/lib/utils.ts
  37. 7
      solidity/abacus-xapps/test/governance/governanceRouter.test.ts
  38. 7
      solidity/abacus-xapps/test/governance/lib/GovernanceDeploy.ts
  39. 79
      solidity/abacus-xapps/test/governance/lib/GovernanceDeployment.ts
  40. 83
      solidity/abacus-xapps/tsconfig.json
  41. 2
      tsconfig.package.json
  42. 4
      typescript/abacus-deploy/package.json
  43. 25
      typescript/abacus-deploy/src/bridge/BridgeContracts.ts
  44. 8
      typescript/abacus-deploy/src/bridge/BridgeDeploy.ts
  45. 33
      typescript/abacus-deploy/src/bridge/BridgeInstance.ts
  46. 33
      typescript/abacus-deploy/src/common/BeaconProxy.ts
  47. 38
      typescript/abacus-deploy/src/core/CoreContracts.ts
  48. 18
      typescript/abacus-deploy/src/core/CoreDeploy.ts
  49. 59
      typescript/abacus-deploy/src/core/CoreInstance.ts
  50. 6
      typescript/abacus-deploy/src/core/implementation.ts
  51. 11
      typescript/abacus-deploy/src/governance/GovernanceContracts.ts
  52. 4
      typescript/abacus-deploy/src/governance/GovernanceDeploy.ts
  53. 14
      typescript/abacus-deploy/src/governance/GovernanceInstance.ts
  54. 9
      typescript/abacus-deploy/src/verification/utils.ts
  55. 2
      typescript/abacus-deploy/tsconfig.json
  56. 1
      typescript/abacus-sdk/.gitignore
  57. 12
      typescript/abacus-sdk/package.json
  58. 18
      typescript/abacus-sdk/src/abacus/AbacusContext.ts
  59. 17
      typescript/abacus-sdk/src/abacus/contracts/BridgeContracts.ts
  60. 29
      typescript/abacus-sdk/src/abacus/contracts/CoreContracts.ts
  61. 2
      typescript/abacus-sdk/src/abacus/events/abacusEvents.ts
  62. 2
      typescript/abacus-sdk/src/abacus/events/bridgeEvents.ts
  63. 2
      typescript/abacus-sdk/src/abacus/events/fetch.ts
  64. 8
      typescript/abacus-sdk/src/abacus/messages/AbacusMessage.ts
  65. 6
      typescript/abacus-sdk/src/abacus/messages/BridgeMessage.ts
  66. 4
      typescript/abacus-sdk/src/abacus/tokens/index.ts
  67. 2
      typescript/abacus-sdk/tsconfig.json
  68. 1
      typescript/contract-metrics/.gitignore
  69. 6
      typescript/contract-metrics/package.json
  70. 4
      typescript/contract-metrics/src/monitor/governance.ts
  71. 2
      typescript/contract-metrics/tsconfig.json
  72. 7
      typescript/hardhat/package.json
  73. 4
      typescript/hardhat/src/TestAbacusDeploy.ts
  74. 2
      typescript/hardhat/tsconfig.json
  75. 4
      typescript/typechain/.gitignore
  76. 0
      typescript/typechain/.npmignore
  77. 2
      typescript/typechain/index.ts
  78. 23
      typescript/typechain/package.json
  79. 20
      typescript/typechain/tsconfig.json
  80. 4
      typescript/utils/package.json
  81. 2
      typescript/utils/tsconfig.json

230
package-lock.json generated

@ -10,17 +10,12 @@
"solidity/abacus-core",
"typescript/hardhat",
"solidity/abacus-xapps",
"typescript/typechain",
"typescript/abacus-sdk",
"typescript/contract-metrics",
"typescript/abacus-deploy"
]
},
"node_modules/@abacus-network/abacus-sol": {
"resolved": "solidity/abacus-core",
"link": true
},
"node_modules/@abacus-network/abacus-xapps-sol": {
"node_modules/@abacus-network/apps": {
"resolved": "solidity/abacus-xapps",
"link": true
},
@ -28,6 +23,10 @@
"resolved": "typescript/contract-metrics",
"link": true
},
"node_modules/@abacus-network/core": {
"resolved": "solidity/abacus-core",
"link": true
},
"node_modules/@abacus-network/deploy": {
"resolved": "typescript/abacus-deploy",
"link": true
@ -40,10 +39,6 @@
"resolved": "typescript/abacus-sdk",
"link": true
},
"node_modules/@abacus-network/ts-interface": {
"resolved": "typescript/typechain",
"link": true
},
"node_modules/@abacus-network/utils": {
"resolved": "typescript/utils",
"link": true
@ -24788,8 +24783,8 @@
}
},
"solidity/abacus-core": {
"name": "@abacus-network/abacus-sol",
"version": "0.0.0",
"name": "@abacus-network/core",
"version": "0.0.1",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@abacus-network/utils": "^0.0.5",
@ -24819,11 +24814,11 @@
}
},
"solidity/abacus-xapps": {
"name": "@abacus-network/abacus-xapps-sol",
"name": "@abacus-network/apps",
"version": "0.0.0",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@abacus-network/abacus-sol": "file:../abacus-core",
"@abacus-network/core": "file:../core",
"@abacus-network/hardhat": "^0.0.5",
"@abacus-network/utils": "^0.0.5",
"@openzeppelin/contracts": "~3.4.2",
@ -24851,13 +24846,20 @@
"typescript": "^4.3.5"
}
},
"solidity/abacus-xapps/node_modules/@abacus-network/core": {
"resolved": "solidity/core",
"link": true
},
"solidity/apps": {},
"solidity/core": {},
"typescript/abacus-deploy": {
"name": "@abacus-network/deploy",
"version": "0.0.5",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@abacus-network/apps": "file:../../solidity/apps",
"@abacus-network/core": "file:../../solidity/core",
"@abacus-network/sdk": "^0.0.1",
"@abacus-network/ts-interface": "^0.0.1",
"@aws-sdk/client-kms": "3.48.0",
"@ethersproject/experimental": "^5.3.0",
"@nomiclabs/hardhat-etherscan": "^3.0.3",
@ -24885,6 +24887,14 @@
"typescript": "^4.3.2"
}
},
"typescript/abacus-deploy/node_modules/@abacus-network/apps": {
"resolved": "solidity/apps",
"link": true
},
"typescript/abacus-deploy/node_modules/@abacus-network/core": {
"resolved": "solidity/core",
"link": true
},
"typescript/abacus-deploy/node_modules/@types/node": {
"version": "16.11.26",
"license": "MIT"
@ -24894,7 +24904,8 @@
"version": "0.0.1",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@abacus-network/ts-interface": "^0.0.1",
"@abacus-network/apps": "file:../../solidity/apps",
"@abacus-network/core": "file:../../solidity/core",
"@ethersproject/bignumber": "^5.5.0",
"@ethersproject/bytes": "^5.5.0",
"celo-ethers-provider": "0.0.0",
@ -24912,47 +24923,25 @@
"typescript": "^4.4.3"
}
},
"typescript/abacus-sdk/node_modules/@abacus-network/apps": {
"resolved": "solidity/apps",
"link": true
},
"typescript/abacus-sdk/node_modules/@abacus-network/core": {
"resolved": "solidity/core",
"link": true
},
"typescript/abacus-sdk/node_modules/@types/node": {
"version": "16.11.26",
"dev": true,
"license": "MIT"
},
"typescript/abacus-tests": {
"name": "@abacus-network/test",
"version": "0.0.0",
"extraneous": true,
"license": "MIT OR Apache-2.0",
"dependencies": {
"@abacus-network/abacus-deploy": "^0.0.5",
"@abacus-network/sdk": "^0.0.1",
"@abacus-network/ts-interface": "^0.0.1",
"@types/node": "^15.14.7",
"dotenv": "^10.0.0",
"hardhat-gas-reporter": "^1.0.7"
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.2",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@typechain/ethers-v5": "^7.0.0",
"@types/chai": "^4.2.18",
"@types/mocha": "^8.2.2",
"chai": "^4.3.4",
"ethereum-waffle": "^3.3.0",
"ethers": "^5.5.3",
"hardhat": "^2.8.3",
"mkdirp": "^1.0.4",
"prettier": "2.3.0",
"ts-node": "^10.0.0",
"typechain": "^5.0.0",
"typescript": "^4.3.2"
}
},
"typescript/contract-metrics": {
"name": "@abacus-network/contract-metrics",
"version": "0.0.0",
"dependencies": {
"@abacus-network/apps": "file:../../solidity/apps",
"@abacus-network/sdk": "^0.0.1",
"@abacus-network/ts-interface": "file:../typechain",
"@types/bunyan": "^1.8.7",
"@types/express": "^4.17.13",
"@types/google-spreadsheet": "^3.1.5",
@ -24979,15 +24968,9 @@
"prettier": "^2.4.1"
}
},
"typescript/contract-metrics/node_modules/@abacus-network/ts-interface": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@abacus-network/ts-interface/-/ts-interface-1.1.2.tgz",
"integrity": "sha512-ovlzCqBQTU5lGKxJ1iUO3UF0MEds8TkR9fO7DcweWq+mQQoBWU/l8CwnilFimZL5FG2joEMvRgky4iDMK2z9ww==",
"dependencies": {
"@ethersproject/experimental": "^5.5.0",
"@types/node": "^16.11.21",
"typescript": "^4.5.5"
}
"typescript/contract-metrics/node_modules/@abacus-network/apps": {
"resolved": "solidity/apps",
"link": true
},
"typescript/contract-metrics/node_modules/@types/node": {
"version": "16.11.26",
@ -24998,7 +24981,7 @@
"version": "0.0.5",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@abacus-network/abacus-sol": "^0.0.0",
"@abacus-network/core": "file:../../solidity/core",
"@abacus-network/utils": "^0.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.5",
"@nomiclabs/hardhat-waffle": "^2.0.2",
@ -25012,22 +24995,9 @@
"typescript": "^4.3.2"
}
},
"typescript/typechain": {
"name": "@abacus-network/ts-interface",
"version": "0.0.1",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@ethersproject/experimental": "^5.5.0",
"@types/node": "^16.11.21",
"typescript": "^4.5.5"
},
"devDependencies": {
"ethers": "^5.5.3"
}
},
"typescript/typechain/node_modules/@types/node": {
"version": "16.11.26",
"license": "MIT"
"typescript/hardhat/node_modules/@abacus-network/core": {
"resolved": "solidity/core",
"link": true
},
"typescript/utils": {
"name": "@abacus-network/utils",
@ -25040,37 +25010,10 @@
}
},
"dependencies": {
"@abacus-network/abacus-sol": {
"version": "file:solidity/abacus-core",
"requires": {
"@abacus-network/utils": "^0.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.1",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@openzeppelin/contracts": "^3.4.2",
"@openzeppelin/contracts-upgradeable": "~3.4.2",
"@summa-tx/memview-sol": "^2.0.0",
"@typechain/ethers-v5": "~7.0.0",
"@typechain/hardhat": "^2.0.1",
"chai": "^4.3.0",
"eslint": "^7.20.0",
"ethereum-waffle": "^3.2.2",
"ethers": "^5.4.4",
"hardhat": "^2.8.3",
"hardhat-gas-reporter": "^1.0.7",
"prettier": "^2.2.1",
"prettier-plugin-solidity": "^1.0.0-beta.5",
"solhint": "^3.3.2",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.14",
"ts-generator": "^0.1.1",
"ts-node": "^10.1.0",
"typechain": "^5.0.0"
}
},
"@abacus-network/abacus-xapps-sol": {
"@abacus-network/apps": {
"version": "file:solidity/abacus-xapps",
"requires": {
"@abacus-network/abacus-sol": "file:../abacus-core",
"@abacus-network/core": "file:../core",
"@abacus-network/hardhat": "^0.0.5",
"@abacus-network/utils": "^0.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.1",
@ -25094,13 +25037,18 @@
"ts-node": "^10.1.0",
"typechain": "^5.0.0",
"typescript": "^4.3.5"
},
"dependencies": {
"@abacus-network/core": {
"version": "file:solidity/core"
}
}
},
"@abacus-network/contract-metrics": {
"version": "file:typescript/contract-metrics",
"requires": {
"@abacus-network/apps": "file:../../solidity/apps",
"@abacus-network/sdk": "^0.0.1",
"@abacus-network/ts-interface": "file:../typechain",
"@types/bunyan": "^1.8.7",
"@types/express": "^4.17.13",
"@types/google-spreadsheet": "^3.1.5",
@ -25125,25 +25073,47 @@
"typescript": "^4.4.3"
},
"dependencies": {
"@abacus-network/ts-interface": {
"version": "https://registry.npmjs.org/@abacus-network/ts-interface/-/ts-interface-1.1.2.tgz",
"integrity": "sha512-ovlzCqBQTU5lGKxJ1iUO3UF0MEds8TkR9fO7DcweWq+mQQoBWU/l8CwnilFimZL5FG2joEMvRgky4iDMK2z9ww==",
"requires": {
"@ethersproject/experimental": "^5.5.0",
"@types/node": "^16.11.21",
"typescript": "^4.5.5"
}
"@abacus-network/apps": {
"version": "file:solidity/apps"
},
"@types/node": {
"version": "16.11.26"
}
}
},
"@abacus-network/core": {
"version": "file:solidity/abacus-core",
"requires": {
"@abacus-network/utils": "^0.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.1",
"@nomiclabs/hardhat-waffle": "^2.0.1",
"@openzeppelin/contracts": "^3.4.2",
"@openzeppelin/contracts-upgradeable": "~3.4.2",
"@summa-tx/memview-sol": "^2.0.0",
"@typechain/ethers-v5": "~7.0.0",
"@typechain/hardhat": "^2.0.1",
"chai": "^4.3.0",
"eslint": "^7.20.0",
"ethereum-waffle": "^3.2.2",
"ethers": "^5.4.4",
"hardhat": "^2.8.3",
"hardhat-gas-reporter": "^1.0.7",
"prettier": "^2.2.1",
"prettier-plugin-solidity": "^1.0.0-beta.5",
"solhint": "^3.3.2",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.14",
"ts-generator": "^0.1.1",
"ts-node": "^10.1.0",
"typechain": "^5.0.0"
}
},
"@abacus-network/deploy": {
"version": "file:typescript/abacus-deploy",
"requires": {
"@abacus-network/apps": "file:../../solidity/apps",
"@abacus-network/core": "file:../../solidity/core",
"@abacus-network/sdk": "^0.0.1",
"@abacus-network/ts-interface": "^0.0.1",
"@aws-sdk/client-kms": "3.48.0",
"@ethersproject/experimental": "^5.3.0",
"@nomiclabs/hardhat-ethers": "^2.0.5",
@ -25169,6 +25139,12 @@
"yargs": "^17.3.1"
},
"dependencies": {
"@abacus-network/apps": {
"version": "file:solidity/apps"
},
"@abacus-network/core": {
"version": "file:solidity/core"
},
"@types/node": {
"version": "16.11.26"
}
@ -25177,7 +25153,7 @@
"@abacus-network/hardhat": {
"version": "file:typescript/hardhat",
"requires": {
"@abacus-network/abacus-sol": "^0.0.0",
"@abacus-network/core": "file:../../solidity/core",
"@abacus-network/utils": "^0.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.5",
"@nomiclabs/hardhat-waffle": "^2.0.2",
@ -25189,12 +25165,18 @@
"ts-node": "^10.1.0",
"typechain": "^5.0.0",
"typescript": "^4.3.2"
},
"dependencies": {
"@abacus-network/core": {
"version": "file:solidity/core"
}
}
},
"@abacus-network/sdk": {
"version": "file:typescript/abacus-sdk",
"requires": {
"@abacus-network/ts-interface": "^0.0.1",
"@abacus-network/apps": "file:../../solidity/apps",
"@abacus-network/core": "file:../../solidity/core",
"@ethersproject/bignumber": "^5.5.0",
"@ethersproject/bytes": "^5.5.0",
"@types/node": "^16.9.1",
@ -25210,23 +25192,15 @@
"typescript": "^4.4.3"
},
"dependencies": {
"@types/node": {
"version": "16.11.26",
"dev": true
}
}
"@abacus-network/apps": {
"version": "file:solidity/apps"
},
"@abacus-network/ts-interface": {
"version": "file:typescript/typechain",
"requires": {
"@ethersproject/experimental": "^5.5.0",
"@types/node": "^16.11.21",
"ethers": "^5.5.3",
"typescript": "^4.5.5"
"@abacus-network/core": {
"version": "file:solidity/core"
},
"dependencies": {
"@types/node": {
"version": "16.11.26"
"version": "16.11.26",
"dev": true
}
}
},

@ -10,7 +10,6 @@
"solidity/abacus-core",
"typescript/hardhat",
"solidity/abacus-xapps",
"typescript/typechain",
"typescript/abacus-sdk",
"typescript/contract-metrics",
"typescript/abacus-deploy"

@ -1,7 +1,8 @@
node_modules/
cache/
artifacts/
typechain/
types/
dist/
coverage/
coverage.json
.env

@ -20,7 +20,7 @@ module.exports = {
currency: "USD",
},
typechain: {
outDir: "./typechain",
outDir: "./types",
target: "ethers-v5",
alwaysGenerateOverloads: false, // should overloads with full signatures like deposit(uint256) be generated always, even if there are no overloads?
},

@ -1,5 +1,5 @@
{
"name": "@abacus-network/abacus-sol",
"name": "@abacus-network/core",
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.1",
"@nomiclabs/hardhat-waffle": "^2.0.1",
@ -19,20 +19,19 @@
"ts-node": "^10.1.0",
"typechain": "^5.0.0"
},
"version": "0.0.0",
"description": "Abacus Interchain Communications",
"main": " ",
"version": "0.0.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"directories": {
"test": "test"
},
"scripts": {
"prettier": "prettier --write ./contracts ./libs ./test",
"build": "hardhat compile && hardhat typechain && npm run prettier && npm run copy-typechain",
"copy-typechain": "mkdir -p ../../typescript/typechain/abacus-core/ && cp -r typechain/* ../../typescript/typechain/abacus-core/",
"build": "hardhat compile && hardhat typechain && npm run prettier && tsc && npm run copy-types",
"copy-types": "cp types/*.d.ts dist/",
"test": "hardhat test",
"coverage": "hardhat coverage"
},
"author": "James Prestwich",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@abacus-network/utils": "^0.0.5",

@ -2,7 +2,7 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { ethers } from 'hardhat';
import { expect } from 'chai';
import { TestCommon__factory, TestCommon } from '../typechain';
import { TestCommon__factory, TestCommon } from '../types';
const localDomain = 1000;
const ONLY_OWNER_REVERT_MSG = 'Ownable: caller is not the owner';

@ -16,9 +16,8 @@ import {
ValidatorManager,
ValidatorManager__factory,
TestRecipient__factory,
} from '../typechain';
} from '../types';
const outboxDomainHashTestCases = require('../../../vectors/outboxDomainHash.json');
const merkleTestCases = require('../../../vectors/merkle.json');
const proveAndProcessTestCases = require('../../../vectors/proveAndProcess.json');

@ -1,4 +1,3 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { assert } from 'chai';
import * as ethers from 'ethers';
import { types } from '@abacus-network/utils';
@ -16,7 +15,7 @@ import {
XAppConnectionManager__factory,
TestInbox,
TestInbox__factory,
} from '../../typechain';
} from '../../types';
export interface AbacusInstance {
domain: types.Domain;

@ -1,6 +1,5 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { expect } from 'chai';
import ethers from 'ethers';
import {
MysteryMathV1,
@ -10,7 +9,7 @@ import {
UpgradeBeacon,
UpgradeBeacon__factory,
UpgradeBeaconProxy__factory,
} from '../../typechain';
} from '../../types';
export type MysteryMathUpgrade = {
proxy: MysteryMathV1 | MysteryMathV2;

@ -2,7 +2,7 @@ import { ethers } from 'hardhat';
import { expect } from 'chai';
import { types } from '@abacus-network/utils';
import { TestMerkle, TestMerkle__factory } from '../typechain';
import { TestMerkle, TestMerkle__factory } from '../types';
const merkleTestCases = require('../../../vectors/merkle.json');

@ -1,7 +1,7 @@
import { ethers } from 'hardhat';
import { expect } from 'chai';
import { utils } from '@abacus-network/utils';
import { TestMessage, TestMessage__factory } from '../typechain';
import { TestMessage, TestMessage__factory } from '../types';
const testCases = require('../../../vectors/message.json');

@ -2,9 +2,8 @@ import { ethers } from 'hardhat';
import { expect } from 'chai';
import { types, utils } from '@abacus-network/utils';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { Validator } from './lib/core';
import { TestOutbox, TestOutbox__factory } from '../typechain';
import { TestOutbox, TestOutbox__factory } from '../types';
const destinationNonceTestCases = require('../../../vectors/destinationNonce.json');

@ -6,7 +6,7 @@ import {
UpgradeBeaconController__factory,
UpgradeBeaconController,
MysteryMathV2__factory,
} from '../typechain';
} from '../types';
describe('Upgrade', async () => {
const utils = new UpgradeTestHelpers();

@ -10,7 +10,7 @@ import {
Outbox,
ValidatorManager__factory,
ValidatorManager,
} from '../typechain';
} from '../types';
const outboxDomainHashCases = require('../../../vectors/outboxDomainHash.json');
const localDomain = 1000;

@ -8,10 +8,7 @@ import {
XAppConnectionManager,
XAppConnectionManager__factory,
TestInbox,
} from '../typechain';
import { Validator } from './lib/core';
const signedFailureTestCases = require('../../../vectors/signedFailure.json');
} from '../types';
const ONLY_OWNER_REVERT_MSG = 'Ownable: caller is not the owner';
const localDomain = 1000;
@ -22,12 +19,10 @@ const reserveGas = 15000;
describe('XAppConnectionManager', async () => {
let connectionManager: XAppConnectionManager,
enrolledInbox: TestInbox,
signer: SignerWithAddress,
validator: Validator;
signer: SignerWithAddress;
before(async () => {
[signer] = await ethers.getSigners();
validator = await Validator.fromSigner(signer, localDomain);
});
beforeEach(async () => {

@ -1,73 +1,16 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
"resolveJsonModule": true /* Allows for importing, extracting types from and generating . json files.*/,
/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
"outDir": "./dist/",
"rootDir": "./types/"
},
"exclude": [
"./node_modules/",
"./dist/",
"./types/hardhat.d.ts"
],
"extends": "../../tsconfig.package.json",
"include": [
"./types/*.ts",
"./types/factories/*.ts"
]
}

@ -1,7 +1,8 @@
node_modules/
cache/
artifacts/
typechain/
types/
dist/
coverage/
coverage.json
.env

@ -6,11 +6,11 @@ import {TokenRegistry} from "./TokenRegistry.sol";
import {BridgeMessage} from "./BridgeMessage.sol";
import {IBridgeToken} from "../../interfaces/bridge/IBridgeToken.sol";
// ============ External Imports ============
import {Router} from "@abacus-network/abacus-sol/contracts/router/Router.sol";
import {XAppConnectionClient} from "@abacus-network/abacus-sol/contracts/router/XAppConnectionClient.sol";
import {Outbox} from "@abacus-network/abacus-sol/contracts/Outbox.sol";
import {Version0} from "@abacus-network/abacus-sol/contracts/Version0.sol";
import {TypeCasts} from "@abacus-network/abacus-sol/contracts/XAppConnectionManager.sol";
import {Router} from "@abacus-network/core/contracts/router/Router.sol";
import {XAppConnectionClient} from "@abacus-network/core/contracts/router/XAppConnectionClient.sol";
import {Outbox} from "@abacus-network/core/contracts/Outbox.sol";
import {Version0} from "@abacus-network/core/contracts/Version0.sol";
import {TypeCasts} from "@abacus-network/core/contracts/XAppConnectionManager.sol";
import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";

@ -5,8 +5,8 @@ pragma solidity >=0.6.11;
import {IBridgeToken} from "../../interfaces/bridge/IBridgeToken.sol";
import {ERC20} from "./vendored/OZERC20.sol";
// ============ External Imports ============
import {Version0} from "@abacus-network/abacus-sol/contracts/Version0.sol";
import {TypeCasts} from "@abacus-network/abacus-sol/contracts/XAppConnectionManager.sol";
import {Version0} from "@abacus-network/core/contracts/Version0.sol";
import {TypeCasts} from "@abacus-network/core/contracts/XAppConnectionManager.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
contract BridgeToken is Version0, IBridgeToken, OwnableUpgradeable, ERC20 {

@ -5,7 +5,7 @@ pragma solidity >=0.6.11;
import {BridgeRouter} from "./BridgeRouter.sol";
import {IWeth} from "../../interfaces/bridge/IWeth.sol";
// ============ External Imports ============
import {TypeCasts} from "@abacus-network/abacus-sol/contracts/XAppConnectionManager.sol";
import {TypeCasts} from "@abacus-network/core/contracts/XAppConnectionManager.sol";
contract ETHHelper {
// ============ Immutables ============

@ -6,9 +6,9 @@ import {BridgeMessage} from "./BridgeMessage.sol";
import {Encoding} from "./Encoding.sol";
import {IBridgeToken} from "../../interfaces/bridge/IBridgeToken.sol";
// ============ External Imports ============
import {XAppConnectionClient} from "@abacus-network/abacus-sol/contracts/router/XAppConnectionClient.sol";
import {TypeCasts} from "@abacus-network/abacus-sol/contracts/XAppConnectionManager.sol";
import {UpgradeBeaconProxy} from "@abacus-network/abacus-sol/contracts/upgrade/UpgradeBeaconProxy.sol";
import {XAppConnectionClient} from "@abacus-network/core/contracts/router/XAppConnectionClient.sol";
import {TypeCasts} from "@abacus-network/core/contracts/XAppConnectionManager.sol";
import {UpgradeBeaconProxy} from "@abacus-network/core/contracts/upgrade/UpgradeBeaconProxy.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";

@ -5,9 +5,9 @@ pragma experimental ABIEncoderV2;
// ============ Internal Imports ============
import {GovernanceMessage} from "./GovernanceMessage.sol";
// ============ External Imports ============
import {Version0} from "@abacus-network/abacus-sol/contracts/Version0.sol";
import {Router} from "@abacus-network/abacus-sol/contracts/router/Router.sol";
import {TypeCasts} from "@abacus-network/abacus-sol/contracts/XAppConnectionManager.sol";
import {Version0} from "@abacus-network/core/contracts/Version0.sol";
import {Router} from "@abacus-network/core/contracts/router/Router.sol";
import {TypeCasts} from "@abacus-network/core/contracts/XAppConnectionManager.sol";
import {Initializable} from "@openzeppelin/contracts/proxy/Initializable.sol";
import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol";
import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol";

@ -3,8 +3,8 @@ pragma solidity >=0.6.11;
// ============ External Imports ============
import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol";
import {Router} from "@abacus-network/abacus-sol/contracts/router/Router.sol";
import {XAppConnectionClient} from "@abacus-network/abacus-sol/contracts/router/XAppConnectionClient.sol";
import {Router} from "@abacus-network/core/contracts/router/Router.sol";
import {XAppConnectionClient} from "@abacus-network/core/contracts/router/XAppConnectionClient.sol";
// ============ Internal Imports ============
import {PingPongMessage} from "./PingPongMessage.sol";

@ -3,8 +3,8 @@ pragma solidity >=0.6.11;
// ============ External Imports ============
import {TypedMemView} from "@summa-tx/memview-sol/contracts/TypedMemView.sol";
import {Router} from "@abacus-network/abacus-sol/contracts/router/Router.sol";
import {XAppConnectionClient} from "@abacus-network/abacus-sol/contracts/router/XAppConnectionClient.sol";
import {Router} from "@abacus-network/core/contracts/router/Router.sol";
import {XAppConnectionClient} from "@abacus-network/core/contracts/router/XAppConnectionClient.sol";
// ============ Internal Imports ============
import {Message} from "./MessageTemplate.sol";

@ -21,7 +21,7 @@ module.exports = {
currency: 'USD',
},
typechain: {
outDir: './typechain',
outDir: './types',
target: 'ethers-v5',
alwaysGenerateOverloads: false, // should overloads with full signatures like deposit(uint256) be generated always, even if there are no overloads?
},

@ -1,5 +1,5 @@
{
"name": "@abacus-network/abacus-xapps-sol",
"name": "@abacus-network/apps",
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.1",
"@nomiclabs/hardhat-waffle": "^2.0.1",
@ -21,22 +21,21 @@
"typescript": "^4.3.5"
},
"version": "0.0.0",
"description": "A bridge using abacus",
"main": " ",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"directories": {
"test": "test"
},
"scripts": {
"prettier": "prettier --write ./contracts ./test",
"build": "hardhat compile && hardhat typechain && npm run prettier && npm run copy-typechain",
"copy-typechain": "mkdir -p ../../typescript/typechain/abacus-xapps/ && cp -r typechain/* ../../typescript/typechain/abacus-xapps/",
"build": "hardhat compile && hardhat typechain && npm run prettier && tsc && npm run copy-types",
"copy-types": "cp types/*.d.ts dist/",
"coverage": "hardhat coverage",
"test": "hardhat test"
},
"author": "James Prestwich",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@abacus-network/abacus-sol": "file:../abacus-core",
"@abacus-network/core": "file:../core",
"@abacus-network/hardhat": "^0.0.5",
"@abacus-network/utils": "^0.0.5",
"@openzeppelin/contracts": "~3.4.2",

@ -1,484 +0,0 @@
import { ethers, abacus } from 'hardhat';
import { expect } from 'chai';
import * as types from 'ethers';
import { formatCall, sendFromSigner } from './utils';
import { increaseTimestampBy } from '../utils';
import { Validator } from '../lib/core';
import { Signer } from '../lib/types';
import {
ValidatorManager,
TestGovernanceRouter,
TestOutbox,
} from '../../typechain';
import { AbacusDeployment } from '../lib/AbacusDeployment';
import { GovernanceDeployment } from '../lib/GovernanceDeployment';
async function expectNotInRecovery(
validatorManager: ValidatorManager,
recoveryManager: types.Signer,
randomSigner: Signer,
governor: Signer,
governanceRouter: TestGovernanceRouter,
outbox: TestOutbox,
) {
expect(await governanceRouter.inRecovery()).to.be.false;
// Format abacus call message
const call = await formatCall(validatorManager, 'setValidator', [
1000,
randomSigner.address,
]);
// Expect that Governor *CAN* Call Local & Call Remote
// dispatch call on local governorRouter
await expect(
sendFromSigner(governor, governanceRouter, 'callLocal', [[call]]),
)
.to.emit(validatorManager, 'NewValidator')
.withArgs(1000, randomSigner.address);
// dispatch call on local governorRouter
await expect(
sendFromSigner(governor, governanceRouter, 'callRemote', [2000, [call]]),
).to.emit(outbox, 'Dispatch');
// set xApp Connection Manager
const xAppConnectionManager = await governanceRouter.xAppConnectionManager();
await expect(
sendFromSigner(governor, governanceRouter, 'setXAppConnectionManager', [
randomSigner.address,
]),
).to.not.be.reverted;
// reset xApp Connection Manager to actual contract
await sendFromSigner(governor, governanceRouter, 'setXAppConnectionManager', [
xAppConnectionManager,
]);
// set Router Locally
const otherDomain = 2000;
const previousRouter = await governanceRouter.routers(otherDomain);
await expect(
sendFromSigner(governor, governanceRouter, 'setRouterLocal', [
2000,
abacus.ethersAddressToBytes32(randomSigner.address),
]),
)
.to.emit(governanceRouter, 'SetRouter')
.withArgs(
otherDomain,
previousRouter,
abacus.ethersAddressToBytes32(randomSigner.address),
);
// Expect that Recovery Manager CANNOT Call Local OR Call Remote
// cannot dispatch call on local governorRouter
await expect(
sendFromSigner(recoveryManager, governanceRouter, 'callLocal', [[call]]),
).to.be.revertedWith('! called by governor');
// cannot dispatch call to remote governorRouter
await expect(
sendFromSigner(recoveryManager, governanceRouter, 'callRemote', [
2000,
[call],
]),
).to.be.revertedWith('! called by governor');
// cannot set xAppConnectionManager
await expect(
sendFromSigner(
recoveryManager,
governanceRouter,
'setXAppConnectionManager',
[randomSigner.address],
),
).to.be.revertedWith('! called by governor');
// cannot set Router
await expect(
sendFromSigner(recoveryManager, governanceRouter, 'setRouterLocal', [
2000,
abacus.ethersAddressToBytes32(randomSigner.address),
]),
).to.be.revertedWith('! called by governor');
}
async function expectOnlyRecoveryManagerCanTransferRole(
governor: Signer,
governanceRouter: TestGovernanceRouter,
randomSigner: Signer,
recoveryManager: Signer,
) {
await expect(
sendFromSigner(governor, governanceRouter, 'transferRecoveryManager', [
randomSigner.address,
]),
).to.be.revertedWith('! called by recovery manager');
await expect(
sendFromSigner(randomSigner, governanceRouter, 'transferRecoveryManager', [
randomSigner.address,
]),
).to.be.revertedWith('! called by recovery manager');
await expect(
sendFromSigner(
recoveryManager,
governanceRouter,
'transferRecoveryManager',
[randomSigner.address],
),
)
.to.emit(governanceRouter, 'TransferRecoveryManager')
.withArgs(recoveryManager.address, randomSigner.address);
await expect(
sendFromSigner(randomSigner, governanceRouter, 'transferRecoveryManager', [
recoveryManager.address,
]),
)
.to.emit(governanceRouter, 'TransferRecoveryManager')
.withArgs(randomSigner.address, recoveryManager.address);
}
async function expectOnlyRecoveryManagerCanExitRecovery(
governor: Signer,
governanceRouter: TestGovernanceRouter,
randomSigner: Signer,
recoveryManager: Signer,
) {
await expect(
sendFromSigner(governor, governanceRouter, 'exitRecovery', []),
).to.be.revertedWith('! called by recovery manager');
await expect(
sendFromSigner(randomSigner, governanceRouter, 'exitRecovery', []),
).to.be.revertedWith('! called by recovery manager');
await expect(
sendFromSigner(recoveryManager, governanceRouter, 'exitRecovery', []),
)
.to.emit(governanceRouter, 'ExitRecovery')
.withArgs(recoveryManager.address);
}
async function expectOnlyRecoveryManagerCanInitiateRecovery(
governor: Signer,
governanceRouter: TestGovernanceRouter,
randomSigner: Signer,
recoveryManager: Signer,
) {
await expect(
sendFromSigner(governor, governanceRouter, 'initiateRecoveryTimelock', []),
).to.be.revertedWith('! called by recovery manager');
await expect(
sendFromSigner(
randomSigner,
governanceRouter,
'initiateRecoveryTimelock',
[],
),
).to.be.revertedWith('! called by recovery manager');
expect(await governanceRouter.recoveryActiveAt()).to.equal(0);
await expect(
sendFromSigner(
recoveryManager,
governanceRouter,
'initiateRecoveryTimelock',
[],
),
).to.emit(governanceRouter, 'InitiateRecovery');
expect(await governanceRouter.recoveryActiveAt()).to.not.equal(0);
}
const localDomain = 1000;
const remoteDomain = 2000;
const domains = [localDomain, remoteDomain];
/*
* Deploy the full Abacus suite on two chains
*/
describe('RecoveryManager', async () => {
let abacusDeployment: AbacusDeployment;
let governanceDeployment: GovernanceDeployment;
let governor: Signer,
recoveryManager: Signer,
randomSigner: Signer,
governanceRouter: TestGovernanceRouter,
outbox: TestOutbox,
validatorManager: ValidatorManager;
before(async () => {
[governor, recoveryManager, randomSigner] = await ethers.getSigners();
const validator = await Validator.fromSigner(randomSigner, localDomain);
abacusDeployment = await AbacusDeployment.fromDomains(
domains,
randomSigner,
);
governanceDeployment = await GovernanceDeployment.fromAbacusDeployment(
abacusDeployment,
recoveryManager,
);
for (const domain of domains) {
await abacusDeployment.transferOwnership(
domain,
governanceDeployment.router(domain).address,
);
}
governanceRouter = governanceDeployment.router(localDomain);
outbox = abacusDeployment.outbox(localDomain);
validatorManager = abacusDeployment.validatorManager(localDomain);
// set governor
await governanceRouter.transferGovernor(localDomain, governor.address);
});
it('Before Recovery Initiated: Timelock has not been set', async () => {
expect(await governanceRouter.recoveryActiveAt()).to.equal(0);
});
it('Before Recovery Initiated: Cannot Exit Recovery yet', async () => {
await expect(
sendFromSigner(recoveryManager, governanceRouter, 'exitRecovery', []),
).to.be.revertedWith('recovery not initiated');
});
it('Before Recovery Initiated: Not in Recovery (Governor CAN Call Local & Remote; Recovery Manager CANNOT Call either)', async () => {
await expectNotInRecovery(
validatorManager,
recoveryManager,
randomSigner,
governor,
governanceRouter,
outbox,
);
});
it('Before Recovery Initiated: ONLY RecoveryManager can transfer RecoveryManager role', async () => {
await expectOnlyRecoveryManagerCanTransferRole(
governor,
governanceRouter,
randomSigner,
recoveryManager,
);
});
it('Before Recovery Initiated: ONLY RecoveryManager can Initiate Recovery', async () => {
await expectOnlyRecoveryManagerCanInitiateRecovery(
governor,
governanceRouter,
randomSigner,
recoveryManager,
);
});
it('Before Recovery Active: CANNOT Initiate Recovery Twice', async () => {
await expect(
sendFromSigner(
recoveryManager,
governanceRouter,
'initiateRecoveryTimelock',
[],
),
).to.be.revertedWith('recovery already initiated');
});
it('Before Recovery Active: Not in Recovery (Governor CAN Call Local & Remote; Recovery Manager CANNOT Call either)', async () => {
await expectNotInRecovery(
validatorManager,
recoveryManager,
randomSigner,
governor,
governanceRouter,
outbox,
);
});
it('Before Recovery Active: ONLY RecoveryManager can transfer RecoveryManager role', async () => {
await expectOnlyRecoveryManagerCanTransferRole(
governor,
governanceRouter,
randomSigner,
recoveryManager,
);
});
it('Before Recovery Active: ONLY RecoveryManager can Exit Recovery', async () => {
await expectOnlyRecoveryManagerCanExitRecovery(
governor,
governanceRouter,
randomSigner,
recoveryManager,
);
});
it('Before Recovery Active: ONLY RecoveryManager can Initiate Recovery (CAN initiate a second time)', async () => {
await expectOnlyRecoveryManagerCanInitiateRecovery(
governor,
governanceRouter,
randomSigner,
recoveryManager,
);
});
it('Recovery Active: inRecovery becomes true when timelock expires', async () => {
// increase timestamp on-chain
const timelock = await governanceRouter.recoveryTimelock();
await increaseTimestampBy(ethers.provider, timelock.toNumber());
expect(await governanceRouter.inRecovery()).to.be.true;
});
it('Recovery Active: RecoveryManager CAN call local', async () => {
// Format abacus call message
const call = await formatCall(validatorManager, 'setValidator', [
localDomain,
randomSigner.address,
]);
// dispatch call on local governorRouter
await expect(
sendFromSigner(recoveryManager, governanceRouter, 'callLocal', [[call]]),
)
.to.emit(validatorManager, 'NewValidator')
.withArgs(localDomain, randomSigner.address);
});
it('Recovery Active: RecoveryManager CANNOT call remote', async () => {
// Format abacus call message
const call = await formatCall(validatorManager, 'setValidator', [
localDomain,
randomSigner.address,
]);
// dispatch call on local governorRouter
await expect(
sendFromSigner(recoveryManager, governanceRouter, 'callRemote', [
2000,
[call],
]),
).to.be.revertedWith('! called by governor');
});
it('Recovery Active: RecoveryManager CAN set xAppConnectionManager', async () => {
// set xApp Connection Manager
const xAppConnectionManager =
await governanceRouter.xAppConnectionManager();
await expect(
sendFromSigner(
recoveryManager,
governanceRouter,
'setXAppConnectionManager',
[randomSigner.address],
),
).to.not.be.reverted;
// reset xApp Connection Manager to actual contract
await sendFromSigner(
recoveryManager,
governanceRouter,
'setXAppConnectionManager',
[xAppConnectionManager],
);
});
it('Recovery Active: RecoveryManager CAN set Router locally', async () => {
const otherDomain = 2000;
const previousRouter = await governanceRouter.routers(otherDomain);
await expect(
sendFromSigner(recoveryManager, governanceRouter, 'setRouterLocal', [
2000,
abacus.ethersAddressToBytes32(randomSigner.address),
]),
)
.to.emit(governanceRouter, 'SetRouter')
.withArgs(
otherDomain,
previousRouter,
abacus.ethersAddressToBytes32(randomSigner.address),
);
});
it('Recovery Active: Governor CANNOT call local OR remote', async () => {
// Format abacus call message
const call = await formatCall(validatorManager, 'setValidator', [
localDomain,
randomSigner.address,
]);
// dispatch call on local governorRouter
await expect(
sendFromSigner(governor, governanceRouter, 'callLocal', [[call]]),
).to.be.revertedWith('! called by recovery manager');
// dispatch call on local governorRouter
await expect(
sendFromSigner(governor, governanceRouter, 'callRemote', [2000, [call]]),
).to.be.revertedWith('in recovery');
});
it('Recovery Active: Governor CANNOT set xAppConnectionManager', async () => {
// cannot set xAppConnectionManager
await expect(
sendFromSigner(governor, governanceRouter, 'setXAppConnectionManager', [
randomSigner.address,
]),
).to.be.revertedWith('! called by recovery manager');
});
it('Recovery Active: Governor CANNOT set Router locally', async () => {
// cannot set Router
await expect(
sendFromSigner(governor, governanceRouter, 'setRouterLocal', [
2000,
abacus.ethersAddressToBytes32(randomSigner.address),
]),
).to.be.revertedWith('! called by recovery manager');
});
it('Recovery Active: ONLY RecoveryManager can transfer RecoveryManager role', async () => {
await expectOnlyRecoveryManagerCanTransferRole(
governor,
governanceRouter,
randomSigner,
recoveryManager,
);
});
it('Recovery Active: ONLY RecoveryManager can Exit Recovery', async () => {
await expectOnlyRecoveryManagerCanExitRecovery(
governor,
governanceRouter,
randomSigner,
recoveryManager,
);
});
it('Exited Recovery: Timelock is deleted', async () => {
expect(await governanceRouter.recoveryActiveAt()).to.equal(0);
});
it('Exited Recovery: Not in Recovery (Governor CAN Call Local & Remote; Recovery Manager CANNOT Call either)', async () => {
await expectNotInRecovery(
validatorManager,
recoveryManager,
randomSigner,
governor,
governanceRouter,
outbox,
);
});
it('Exited Recovery: ONLY RecoveryManager can transfer RecoveryManager role', async () => {
await expectOnlyRecoveryManagerCanTransferRole(
governor,
governanceRouter,
randomSigner,
recoveryManager,
);
});
});

@ -4,7 +4,7 @@ import { Wallet } from 'ethers';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { permitDigest } from './lib/permit';
import { BridgeToken__factory, BridgeToken } from '../../typechain';
import { BridgeToken__factory, BridgeToken } from '../../types';
const VALUE = 100;

@ -1,12 +1,9 @@
import { ethers, abacus } from 'hardhat';
import { BytesLike } from 'ethers';
import { expect } from 'chai';
import { utils } from '@abacus-network/utils';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import * as types from './lib/types';
import { serializeMessage } from './lib/utils';
import { BridgeConfig, BridgeDeploy } from './lib/BridgeDeploy';
import { BridgeDeploy } from './lib/BridgeDeploy';
const localDomain = 1000;
const remoteDomain = 2000;
@ -16,47 +13,18 @@ describe('EthHelper', async () => {
let bridge: BridgeDeploy;
let deployer: SignerWithAddress;
let deployerId: string;
let recipient: SignerWithAddress;
let recipientId: string;
let transferToSelfMessage: BytesLike;
let transferMessage: BytesLike;
const value = 1;
before(async () => {
[deployer, recipient] = await ethers.getSigners();
deployerId = utils.addressToBytes32(deployer.address);
recipientId = utils.addressToBytes32(recipient.address);
await abacus.deploy(domains, deployer);
bridge = new BridgeDeploy(deployer);
await bridge.deploy(abacus);
const tokenId: types.TokenIdentifier = {
domain: localDomain,
id: utils.addressToBytes32(bridge.weth(localDomain).address),
};
const transferToSelfMessageObj: types.Message = {
tokenId,
action: {
type: types.BridgeMessageTypes.TRANSFER,
recipient: deployerId,
amount: value,
},
};
transferToSelfMessage = serializeMessage(transferToSelfMessageObj);
const transferMessageObj: types.Message = {
tokenId,
action: {
type: types.BridgeMessageTypes.TRANSFER,
recipient: recipientId,
amount: value,
},
};
transferMessage = serializeMessage(transferMessageObj);
});
it('send function', async () => {

@ -6,8 +6,8 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { utils } from '@abacus-network/utils';
import * as types from './lib/types';
import { serializeMessage } from './lib/utils';
import { BridgeConfig, BridgeDeploy } from './lib/BridgeDeploy';
import { BridgeToken, BridgeToken__factory, IERC20 } from '../../typechain';
import { BridgeDeploy } from './lib/BridgeDeploy';
import { BridgeToken, BridgeToken__factory, IERC20 } from '../../types';
const localDomain = 1000;
const remoteDomain = 2000;
@ -256,7 +256,7 @@ describe('BridgeRouter', async () => {
ethers.constants.MaxUint256,
);
const sendTx = await bridge
await bridge
.router(localDomain)
.send(localToken.address, TOKEN_VALUE, remoteDomain, deployerId);
@ -462,7 +462,6 @@ describe('BridgeRouter', async () => {
describe('details message', async () => {
let localToken: BridgeToken;
let requestMessage: BytesLike;
let outgoingDetails: BytesLike;
let incomingDetails: BytesLike;
let transferMessage: BytesLike;
let repr: BridgeToken;
@ -487,20 +486,6 @@ describe('BridgeRouter', async () => {
};
requestMessage = serializeMessage(requestMessageObj);
const outgoingDetailsObj: types.Message = {
tokenId: {
domain: localDomain,
id: utils.addressToBytes32(localToken.address),
},
action: {
type: types.BridgeMessageTypes.DETAILS,
name: utils.stringToBytes32(TEST_NAME),
symbol: utils.stringToBytes32(TEST_SYMBOL),
decimals: TEST_DECIMALS,
},
};
outgoingDetails = serializeMessage(outgoingDetailsObj);
// generate transfer action
const transferMessageObj: types.Message = {
tokenId: testTokenId,
@ -536,14 +521,6 @@ describe('BridgeRouter', async () => {
.router(localDomain)
.requestDetails(remoteDomain, testToken);
const requestDetailsObj: types.Message = {
tokenId: testTokenId,
action: {
type: types.BridgeMessageTypes.REQUEST_DETAILS,
},
};
const requestDetails = serializeMessage(requestDetailsObj);
await expect(requestTx).to.emit(abacus.outbox(localDomain), 'Dispatch');
});
@ -721,16 +698,6 @@ describe('BridgeRouter', async () => {
describe('when transferring a custom token', () => {
it('allows outbound transfers of both assets', async () => {
const smallTransfer: types.Message = {
tokenId: testTokenId,
action: {
type: types.BridgeMessageTypes.TRANSFER,
recipient: deployerId,
amount: TOKEN_VALUE,
},
};
const smallTransferMessage = serializeMessage(smallTransfer);
const defaultSendTx = await bridge
.router(localDomain)
.send(defaultRepr.address, TOKEN_VALUE, remoteDomain, deployerId);

@ -18,7 +18,7 @@ import {
serializeTransferAction,
serializeRequestDetailsAction,
} from './lib/utils';
import { TestBridgeMessage__factory, TestBridgeMessage } from '../../typechain';
import { TestBridgeMessage__factory, TestBridgeMessage } from '../../types';
const stringToBytes32 = (s: string): string => {
const str = Buffer.from(s.slice(0, 32), 'utf-8');

@ -1,5 +1,5 @@
import { ethers } from 'hardhat';
import { TestEncoding__factory } from '../../typechain';
import { TestEncoding__factory } from '../../types';
describe('Encoding', async () => {
it('encodes', async () => {

@ -12,11 +12,8 @@ import {
BridgeRouter__factory,
ETHHelper,
ETHHelper__factory,
} from '../../../typechain';
import {
UpgradeBeacon__factory,
UpgradeBeacon,
} from '@abacus-network/abacus-sol/typechain';
} from '../../../types';
import { UpgradeBeacon__factory, UpgradeBeacon } from '@abacus-network/core';
export type BridgeConfig = SignerWithAddress;

@ -1,130 +0,0 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { assert } from 'chai';
import * as ethers from 'ethers';
import { AbacusDeployment } from '@abacus-network/abacus-sol/test/lib/AbacusDeployment';
import { utils, types } from '@abacus-network/utils';
import {
MockWeth__factory,
MockWeth,
BridgeToken,
BridgeToken__factory,
BridgeRouter,
BridgeRouter__factory,
ETHHelper,
ETHHelper__factory,
} from '../../../typechain';
import {
UpgradeBeacon__factory,
UpgradeBeacon,
} from '@abacus-network/abacus-sol/typechain';
export interface BridgeInstance {
domain: types.Domain;
router: BridgeRouter;
helper: ETHHelper;
beacon: UpgradeBeacon;
token: BridgeToken;
weth: MockWeth;
signer: ethers.Signer;
}
export class BridgeDeployment {
constructor(
public readonly domains: types.Domain[],
public readonly instances: Record<number, BridgeInstance>,
) {}
static async fromAbacusDeployment(
abacus: AbacusDeployment,
signer: ethers.Signer,
) {
const instances: Record<number, BridgeInstance> = {};
for (const domain of abacus.domains) {
const instance = await BridgeDeployment.deployInstance(
domain,
signer,
abacus.instances[domain].connectionManager.address,
);
instances[domain] = instance;
}
for (const local of abacus.domains) {
for (const remote of abacus.domains) {
if (local !== remote) {
await instances[local].router.enrollRemoteRouter(
remote,
utils.addressToBytes32(instances[remote].router.address),
);
}
}
}
return new BridgeDeployment(abacus.domains, instances);
}
static async deployInstance(
domain: types.Domain,
signer: ethers.Signer,
connectionManagerAddress: types.Address,
): Promise<BridgeInstance> {
const wethFactory = new MockWeth__factory(signer);
const weth = await wethFactory.deploy();
await weth.initialize();
const tokenFactory = new BridgeToken__factory(signer);
const token = await tokenFactory.deploy();
await token.initialize();
const beaconFactory = new UpgradeBeacon__factory(signer);
const beacon = await beaconFactory.deploy(
token.address,
await signer.getAddress(),
);
const routerFactory = new BridgeRouter__factory(signer);
const router = await routerFactory.deploy();
await router.initialize(beacon.address, connectionManagerAddress);
const helperFactory = new ETHHelper__factory(signer);
const helper = await helperFactory.deploy(weth.address, router.address);
return {
domain,
beacon,
router,
helper,
token,
weth,
signer,
};
}
router(domain: types.Domain): BridgeRouter {
return this.instances[domain].router;
}
signer(domain: types.Domain): ethers.Signer {
return this.instances[domain].signer;
}
weth(domain: types.Domain): MockWeth {
return this.instances[domain].weth;
}
helper(domain: types.Domain): ETHHelper {
return this.instances[domain].helper;
}
async bridgeToken(
local: types.Domain,
remote: types.Domain,
address: ethers.BytesLike,
): Promise<BridgeToken> {
const router = this.router(local);
const reprAddr = await router['getLocalAddress(uint32,bytes32)'](
remote,
address,
);
return BridgeToken__factory.connect(reprAddr, this.signer(local));
}
}

@ -1,5 +1,5 @@
import { BigNumber, BigNumberish, ethers } from 'ethers';
import { BridgeToken } from '../../../typechain';
import { BridgeToken } from '../../../types';
const PERMIT_TYPEHASH = ethers.utils.keccak256(
ethers.utils.toUtf8Bytes(

@ -3,16 +3,6 @@ import { ethers } from 'ethers';
import * as types from './types';
const typeToByte = (type: number): string => `0x0${type}`;
const MESSAGE_LEN = {
identifier: 1,
tokenId: 36,
transfer: 65,
details: 66,
requestDetails: 1,
};
// Formats Transfer Message
export function formatTransfer(
to: ethers.BytesLike,

@ -9,12 +9,7 @@ import {
increaseTimestampBy,
} from './lib/utils';
import { GovernanceConfig, GovernanceDeploy } from './lib/GovernanceDeploy';
import {
TestSet,
TestSet__factory,
GovernanceRouter,
GovernanceRouter__factory,
} from '../../typechain';
import { TestSet, TestSet__factory, GovernanceRouter } from '../../types';
const recoveryTimelock = 60 * 60 * 24 * 7;
const localDomain = 1000;

@ -1,11 +1,8 @@
import { ethers } from 'ethers';
import { types, utils } from '@abacus-network/utils';
import { types } from '@abacus-network/utils';
import { TestAbacusDeploy, TestRouterDeploy } from '@abacus-network/hardhat';
import {
GovernanceRouter__factory,
GovernanceRouter,
} from '../../../typechain';
import { GovernanceRouter__factory, GovernanceRouter } from '../../../types';
export type Governor = {
domain: types.Domain;

@ -1,79 +0,0 @@
import { ethers } from 'ethers';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { utils, types } from '@abacus-network/utils';
import { AbacusDeployment } from '@abacus-network/abacus-sol/test';
import {
GovernanceRouter__factory,
GovernanceRouter,
} from '../../../typechain';
export interface GovernanceInstance {
domain: types.Domain;
router: GovernanceRouter;
}
const recoveryTimelock = 60 * 60 * 24 * 7;
export class GovernanceDeployment {
constructor(
public readonly domains: types.Domain[],
public readonly instances: Record<number, GovernanceInstance>,
) {}
static async fromAbacusDeployment(
abacus: AbacusDeployment,
governor: SignerWithAddress,
recoveryManager: SignerWithAddress,
) {
// Deploy routers.
const instances: Record<number, GovernanceInstance> = {};
for (const domain of abacus.domains) {
const instance = await GovernanceDeployment.deployInstance(
domain,
governor,
recoveryManager,
abacus.connectionManager(domain).address,
);
instances[domain] = instance;
}
// Make all routers aware of eachother.
for (const local of abacus.domains) {
for (const remote of abacus.domains) {
await instances[local].router.enrollRemoteRouter(
remote,
utils.addressToBytes32(instances[remote].router.address),
);
}
}
// Set the governor on one router, clear it on all other routers.
for (let i = 0; i < abacus.domains.length; i++) {
const addr = i === 0 ? governor.address : ethers.constants.AddressZero;
await instances[abacus.domains[i]].router.setGovernor(addr);
}
return new GovernanceDeployment(abacus.domains, instances);
}
static async deployInstance(
domain: types.Domain,
governor: SignerWithAddress,
recoveryManager: SignerWithAddress,
connectionManagerAddress: types.Address,
): Promise<GovernanceInstance> {
const routerFactory = new GovernanceRouter__factory(governor);
const router = await routerFactory.deploy(recoveryTimelock);
await router.initialize(connectionManagerAddress);
await router.transferOwnership(recoveryManager.address);
return {
domain,
router,
};
}
router(domain: types.Domain): GovernanceRouter {
return this.instances[domain].router;
}
}

@ -1,73 +1,16 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
"resolveJsonModule": true /* Allows for importing, extracting types from and generating . json files.*/,
/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
"outDir": "./dist/",
"rootDir": "./types/"
},
"exclude": [
"./node_modules/",
"./dist/",
"./types/hardhat.d.ts"
],
"extends": "../../tsconfig.package.json",
"include": [
"./types/*.ts",
"./types/factories/*.ts"
]
}

@ -1,10 +1,10 @@
{
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"incremental": false,
"lib": ["es2015", "es5", "dom"],
"module": "commonjs",
"moduleResolution": "node",

@ -28,11 +28,11 @@
"kathy": "hardhat kathy --environment local",
"prettier": "prettier --write *.ts ./src ./config ./scripts ./test"
},
"author": "Celo Labs Inc.",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@abacus-network/apps": "file:../../solidity/apps",
"@abacus-network/core": "file:../../solidity/core",
"@abacus-network/sdk": "^0.0.1",
"@abacus-network/ts-interface": "^0.0.1",
"@aws-sdk/client-kms": "3.48.0",
"@ethersproject/experimental": "^5.3.0",
"@nomiclabs/hardhat-etherscan": "^3.0.3",

@ -1,14 +1,21 @@
import fs from 'fs';
import { xapps } from '@abacus-network/ts-interface';
import {
ETHHelper,
ETHHelper__factory,
BridgeRouter,
BridgeRouter__factory,
BridgeToken,
BridgeToken__factory,
} from '@abacus-network/apps';
import { ethers } from 'ethers';
import { CommonContracts, BeaconProxy } from '../common';
import { BridgeContractAddresses } from './types';
export class BridgeContracts extends CommonContracts<BridgeContractAddresses> {
constructor(
public readonly router: BeaconProxy<xapps.BridgeRouter>,
public readonly token: BeaconProxy<xapps.BridgeToken>,
public readonly helper?: xapps.ETHHelper,
public readonly router: BeaconProxy<BridgeRouter>,
public readonly token: BeaconProxy<BridgeToken>,
public readonly helper?: ETHHelper,
) {
super();
}
@ -31,20 +38,20 @@ export class BridgeContracts extends CommonContracts<BridgeContractAddresses> {
addresses: BridgeContractAddresses,
signer: ethers.Signer,
): BridgeContracts {
const router: BeaconProxy<xapps.BridgeRouter> = BeaconProxy.fromObject(
const router: BeaconProxy<BridgeRouter> = BeaconProxy.fromObject(
addresses.router,
xapps.BridgeRouter__factory.abi,
BridgeRouter__factory.abi,
signer,
);
const token: BeaconProxy<xapps.BridgeToken> = BeaconProxy.fromObject(
const token: BeaconProxy<BridgeToken> = BeaconProxy.fromObject(
addresses.token,
xapps.BridgeToken__factory.abi,
BridgeToken__factory.abi,
signer,
);
if (addresses.helper) {
const helper = xapps.ETHHelper__factory.connect(addresses.helper, signer);
const helper = ETHHelper__factory.connect(addresses.helper, signer);
return new BridgeContracts(router, token, helper);
}
return new BridgeContracts(router, token);

@ -1,4 +1,4 @@
import { xapps } from '@abacus-network/ts-interface';
import { BridgeToken, BridgeRouter, ETHHelper } from '@abacus-network/apps';
import { types } from '@abacus-network/utils';
import { BridgeConfig } from './types';
import { BridgeInstance } from './BridgeInstance';
@ -30,15 +30,15 @@ export class BridgeDeploy extends RouterDeploy<BridgeInstance, BridgeConfig> {
);
}
token(domain: types.Domain): xapps.BridgeToken {
token(domain: types.Domain): BridgeToken {
return this.instances[domain].token;
}
router(domain: types.Domain): xapps.BridgeRouter {
router(domain: types.Domain): BridgeRouter {
return this.instances[domain].router;
}
helper(domain: types.Domain): xapps.ETHHelper | undefined {
helper(domain: types.Domain): ETHHelper | undefined {
return this.instances[domain].helper;
}
}

@ -1,4 +1,11 @@
import { xapps } from '@abacus-network/ts-interface';
import {
ETHHelper,
ETHHelper__factory,
BridgeRouter,
BridgeRouter__factory,
BridgeToken,
BridgeToken__factory,
} from '@abacus-network/apps';
import { types } from '@abacus-network/utils';
import { ChainConfig } from '../config';
import { ContractDeployer, BeaconProxy } from '../common';
@ -26,17 +33,17 @@ export class BridgeInstance extends RouterInstance<BridgeContracts> {
const core = config.core[chain.name];
if (core === undefined) throw new Error('could not find core');
const token: BeaconProxy<xapps.BridgeToken> = await BeaconProxy.deploy(
const token: BeaconProxy<BridgeToken> = await BeaconProxy.deploy(
chain,
new xapps.BridgeToken__factory(chain.signer),
new BridgeToken__factory(chain.signer),
core.upgradeBeaconController,
[],
[],
);
const router: BeaconProxy<xapps.BridgeRouter> = await BeaconProxy.deploy(
const router: BeaconProxy<BridgeRouter> = await BeaconProxy.deploy(
chain,
new xapps.BridgeRouter__factory(chain.signer),
new BridgeRouter__factory(chain.signer),
core.upgradeBeaconController,
[],
[token.beacon.address, core.xAppConnectionManager],
@ -45,8 +52,8 @@ export class BridgeInstance extends RouterInstance<BridgeContracts> {
const weth = config.weth[chain.name];
if (weth) {
const deployer = new ContractDeployer(chain);
const helper: xapps.ETHHelper = await deployer.deploy(
new xapps.ETHHelper__factory(chain.signer),
const helper: ETHHelper = await deployer.deploy(
new ETHHelper__factory(chain.signer),
weth,
router.address,
);
@ -57,15 +64,15 @@ export class BridgeInstance extends RouterInstance<BridgeContracts> {
return new BridgeInstance(chain, contracts);
}
get token(): xapps.BridgeToken {
get token(): BridgeToken {
return this.contracts.token.contract;
}
get router(): xapps.BridgeRouter {
get router(): BridgeRouter {
return this.contracts.router.contract;
}
get helper(): xapps.ETHHelper | undefined {
get helper(): ETHHelper | undefined {
return this.contracts.helper;
}
@ -75,14 +82,14 @@ export class BridgeInstance extends RouterInstance<BridgeContracts> {
getBeaconProxyVerificationInput(
'BridgeToken',
this.contracts.token,
xapps.BridgeToken__factory.bytecode,
BridgeToken__factory.bytecode,
),
);
input = input.concat(
getBeaconProxyVerificationInput(
'BridgeRouter',
this.contracts.router,
xapps.BridgeRouter__factory.bytecode,
BridgeRouter__factory.bytecode,
),
);
if (this.helper) {
@ -90,7 +97,7 @@ export class BridgeInstance extends RouterInstance<BridgeContracts> {
getContractVerificationInput(
'ETH Helper',
this.helper,
xapps.ETHHelper__factory.bytecode,
ETHHelper__factory.bytecode,
),
);
}

@ -1,5 +1,10 @@
import { ethers } from 'ethers';
import { core } from '@abacus-network/ts-interface';
import {
UpgradeBeacon,
UpgradeBeacon__factory,
UpgradeBeaconProxy,
UpgradeBeaconProxy__factory,
} from '@abacus-network/core';
import { types } from '@abacus-network/utils';
import { ChainConfig } from '../config';
@ -14,8 +19,8 @@ export type ProxiedAddress = {
export class BeaconProxy<T extends ethers.Contract> {
constructor(
public readonly implementation: T,
public readonly proxy: core.UpgradeBeaconProxy,
public readonly beacon: core.UpgradeBeacon,
public readonly proxy: UpgradeBeaconProxy,
public readonly beacon: UpgradeBeacon,
public readonly contract: T,
) {}
@ -33,8 +38,8 @@ export class BeaconProxy<T extends ethers.Contract> {
): Promise<BeaconProxy<T>> {
const deployer = new ContractDeployer(chain, false);
const implementation: T = await deployer.deploy(factory, ...deployArgs);
const beacon: core.UpgradeBeacon = await deployer.deploy(
new core.UpgradeBeacon__factory(chain.signer),
const beacon: UpgradeBeacon = await deployer.deploy(
new UpgradeBeacon__factory(chain.signer),
implementation.address,
ubcAddress,
);
@ -43,8 +48,8 @@ export class BeaconProxy<T extends ethers.Contract> {
'initialize',
initArgs,
);
const proxy: core.UpgradeBeaconProxy = await deployer.deploy(
new core.UpgradeBeaconProxy__factory(chain.signer),
const proxy: UpgradeBeaconProxy = await deployer.deploy(
new UpgradeBeaconProxy__factory(chain.signer),
beacon.address,
initData,
);
@ -69,14 +74,8 @@ export class BeaconProxy<T extends ethers.Contract> {
abi,
signer,
) as T;
const proxy = core.UpgradeBeaconProxy__factory.connect(
addresses.proxy,
signer,
);
const beacon = core.UpgradeBeacon__factory.connect(
addresses.beacon,
signer,
);
const proxy = UpgradeBeaconProxy__factory.connect(addresses.proxy, signer);
const beacon = UpgradeBeacon__factory.connect(addresses.beacon, signer);
const contract = new ethers.Contract(addresses.proxy, abi, signer) as T;
return new BeaconProxy<T>(implementation, proxy, beacon, contract);
}
@ -95,8 +94,8 @@ export class BeaconProxy<T extends ethers.Contract> {
'initialize',
initArgs,
);
const proxy: core.UpgradeBeaconProxy = await deployer.deploy(
new core.UpgradeBeaconProxy__factory(chain.signer),
const proxy: UpgradeBeaconProxy = await deployer.deploy(
new UpgradeBeaconProxy__factory(chain.signer),
this.beacon.address,
initData,
);

@ -1,6 +1,17 @@
import fs from 'fs';
import { ethers } from 'ethers';
import { core } from '@abacus-network/ts-interface';
import {
UpgradeBeaconController,
UpgradeBeaconController__factory,
XAppConnectionManager,
XAppConnectionManager__factory,
ValidatorManager,
ValidatorManager__factory,
Outbox,
Outbox__factory,
Inbox,
Inbox__factory,
} from '@abacus-network/core';
import { types } from '@abacus-network/utils';
import { BeaconProxy, CommonContracts, ProxiedAddress } from '../common';
@ -8,11 +19,11 @@ import { CoreContractAddresses } from './types';
export class CoreContracts extends CommonContracts<CoreContractAddresses> {
constructor(
public readonly upgradeBeaconController: core.UpgradeBeaconController,
public readonly xAppConnectionManager: core.XAppConnectionManager,
public readonly validatorManager: core.ValidatorManager,
public readonly outbox: BeaconProxy<core.Outbox>,
public readonly inboxes: Record<types.Domain, BeaconProxy<core.Inbox>>,
public readonly upgradeBeaconController: UpgradeBeaconController,
public readonly xAppConnectionManager: XAppConnectionManager,
public readonly validatorManager: ValidatorManager,
public readonly outbox: BeaconProxy<Outbox>,
public readonly inboxes: Record<types.Domain, BeaconProxy<Inbox>>,
) {
super();
}
@ -44,33 +55,32 @@ export class CoreContracts extends CommonContracts<CoreContractAddresses> {
addresses: CoreContractAddresses,
signer: ethers.Signer,
): CoreContracts {
const upgradeBeaconController =
core.UpgradeBeaconController__factory.connect(
const upgradeBeaconController = UpgradeBeaconController__factory.connect(
addresses.upgradeBeaconController,
signer,
);
const xAppConnectionManager = core.XAppConnectionManager__factory.connect(
const xAppConnectionManager = XAppConnectionManager__factory.connect(
addresses.xAppConnectionManager,
signer,
);
const validatorManager = core.ValidatorManager__factory.connect(
const validatorManager = ValidatorManager__factory.connect(
addresses.validatorManager,
signer,
);
const outbox: BeaconProxy<core.Outbox> = BeaconProxy.fromObject(
const outbox: BeaconProxy<Outbox> = BeaconProxy.fromObject(
addresses.outbox,
core.Outbox__factory.abi,
Outbox__factory.abi,
signer,
);
const inboxes: Record<types.Domain, BeaconProxy<core.Inbox>> = {};
const inboxes: Record<types.Domain, BeaconProxy<Inbox>> = {};
Object.keys(addresses.inboxes)
.map((d) => parseInt(d))
.map((domain: types.Domain) => {
inboxes[domain] = BeaconProxy.fromObject(
addresses.inboxes[domain],
core.Inbox__factory.abi,
Inbox__factory.abi,
signer,
);
});

@ -1,6 +1,12 @@
import path from 'path';
import { types } from '@abacus-network/utils';
import { core } from '@abacus-network/ts-interface';
import {
UpgradeBeaconController,
XAppConnectionManager,
ValidatorManager,
Outbox,
Inbox,
} from '@abacus-network/core';
import { CoreInstance } from './CoreInstance';
import { CoreContracts } from './CoreContracts';
import { CoreConfig } from './types';
@ -17,23 +23,23 @@ export class CoreDeploy extends CommonDeploy<CoreInstance, CoreConfig> {
return CoreInstance.deploy(domain, this.chains, config);
}
upgradeBeaconController(domain: types.Domain): core.UpgradeBeaconController {
upgradeBeaconController(domain: types.Domain): UpgradeBeaconController {
return this.instances[domain].upgradeBeaconController;
}
validatorManager(domain: types.Domain): core.ValidatorManager {
validatorManager(domain: types.Domain): ValidatorManager {
return this.instances[domain].validatorManager;
}
outbox(domain: types.Domain): core.Outbox {
outbox(domain: types.Domain): Outbox {
return this.instances[domain].outbox;
}
inbox(local: types.Domain, remote: types.Domain): core.Inbox {
inbox(local: types.Domain, remote: types.Domain): Inbox {
return this.instances[local].inbox(remote);
}
xAppConnectionManager(domain: types.Domain): core.XAppConnectionManager {
xAppConnectionManager(domain: types.Domain): XAppConnectionManager {
return this.instances[domain].xAppConnectionManager;
}

@ -1,6 +1,18 @@
import { ethers } from 'ethers';
import { types } from '@abacus-network/utils';
import { core } from '@abacus-network/ts-interface';
import {
UpgradeBeaconController,
UpgradeBeaconController__factory,
XAppConnectionManager,
XAppConnectionManager__factory,
ValidatorManager,
ValidatorManager__factory,
Outbox,
Outbox__factory,
Inbox,
Inbox__factory,
UpgradeBeaconProxy__factory,
} from '@abacus-network/core';
import { ChainConfig } from '../config';
import { BeaconProxy, ContractDeployer, CommonInstance } from '../common';
import {
@ -20,13 +32,11 @@ export class CoreInstance extends CommonInstance<CoreContracts> {
const chain = chains[domain];
const deployer = new ContractDeployer(chain);
const upgradeBeaconController: core.UpgradeBeaconController =
await deployer.deploy(
new core.UpgradeBeaconController__factory(chain.signer),
);
const upgradeBeaconController: UpgradeBeaconController =
await deployer.deploy(new UpgradeBeaconController__factory(chain.signer));
const validatorManager: core.ValidatorManager = await deployer.deploy(
new core.ValidatorManager__factory(chain.signer),
const validatorManager: ValidatorManager = await deployer.deploy(
new ValidatorManager__factory(chain.signer),
);
await validatorManager.enrollValidator(
domain,
@ -34,21 +44,20 @@ export class CoreInstance extends CommonInstance<CoreContracts> {
chain.overrides,
);
const outbox: BeaconProxy<core.Outbox> = await BeaconProxy.deploy(
const outbox: BeaconProxy<Outbox> = await BeaconProxy.deploy(
chain,
new core.Outbox__factory(chain.signer),
new Outbox__factory(chain.signer),
upgradeBeaconController.address,
[domain],
[validatorManager.address],
);
const xAppConnectionManager: core.XAppConnectionManager =
await deployer.deploy(
new core.XAppConnectionManager__factory(chain.signer),
const xAppConnectionManager: XAppConnectionManager = await deployer.deploy(
new XAppConnectionManager__factory(chain.signer),
);
await xAppConnectionManager.setOutbox(outbox.address, chain.overrides);
const inboxes: Record<types.Domain, BeaconProxy<core.Inbox>> = {};
const inboxes: Record<types.Domain, BeaconProxy<Inbox>> = {};
const domains = Object.keys(chains).map((d) => parseInt(d));
const remotes = domains.filter((d) => d !== domain);
for (let i = 0; i < remotes.length; i++) {
@ -62,7 +71,7 @@ export class CoreInstance extends CommonInstance<CoreContracts> {
if (i === 0) {
inboxes[remote] = await BeaconProxy.deploy(
chain,
new core.Inbox__factory(chain.signer),
new Inbox__factory(chain.signer),
upgradeBeaconController.address,
[domain, config.processGas, config.reserveGas],
initArgs,
@ -113,23 +122,23 @@ export class CoreInstance extends CommonInstance<CoreContracts> {
return Object.keys(this.contracts.inboxes).map((d) => parseInt(d));
}
get upgradeBeaconController(): core.UpgradeBeaconController {
get upgradeBeaconController(): UpgradeBeaconController {
return this.contracts.upgradeBeaconController;
}
get validatorManager(): core.ValidatorManager {
get validatorManager(): ValidatorManager {
return this.contracts.validatorManager;
}
get outbox(): core.Outbox {
get outbox(): Outbox {
return this.contracts.outbox.contract;
}
inbox(domain: types.Domain): core.Inbox {
inbox(domain: types.Domain): Inbox {
return this.contracts.inboxes[domain].contract;
}
get xAppConnectionManager(): core.XAppConnectionManager {
get xAppConnectionManager(): XAppConnectionManager {
return this.contracts.xAppConnectionManager;
}
get verificationInput(): VerificationInput {
@ -138,28 +147,28 @@ export class CoreInstance extends CommonInstance<CoreContracts> {
getContractVerificationInput(
'XAppConnectionManager',
this.xAppConnectionManager,
core.XAppConnectionManager__factory.bytecode,
XAppConnectionManager__factory.bytecode,
),
);
input.push(
getContractVerificationInput(
'ValidatorManager',
this.validatorManager,
core.ValidatorManager__factory.bytecode,
ValidatorManager__factory.bytecode,
),
);
input.push(
getContractVerificationInput(
'UpgradeBeaconController',
this.upgradeBeaconController,
core.UpgradeBeaconController__factory.bytecode,
UpgradeBeaconController__factory.bytecode,
),
);
input = input.concat(
getBeaconProxyVerificationInput(
'Outbox',
this.contracts.outbox,
core.Outbox__factory.bytecode,
Outbox__factory.bytecode,
),
);
// All Inboxes share the same implementation and upgrade beacon.
@ -170,7 +179,7 @@ export class CoreInstance extends CommonInstance<CoreContracts> {
getBeaconProxyVerificationInput(
'Inbox',
inbox,
core.Inbox__factory.bytecode,
Inbox__factory.bytecode,
),
);
} else {
@ -178,7 +187,7 @@ export class CoreInstance extends CommonInstance<CoreContracts> {
getContractVerificationInput(
'Inbox Proxy',
inbox.proxy,
core.UpgradeBeaconProxy__factory.bytecode,
UpgradeBeaconProxy__factory.bytecode,
true,
),
);

@ -1,4 +1,4 @@
import { core } from '@abacus-network/ts-interface';
import { Inbox__factory, Outbox__factory } from '@abacus-network/core';
import { types } from '@abacus-network/utils';
import { CoreDeploy } from './CoreDeploy';
import { CoreInstance } from './CoreInstance';
@ -30,7 +30,7 @@ export class ImplementationDeployer {
*/
private async _deployOutboxImplementation(domain: types.Domain) {
const signer = this.deploy.signer(domain);
const factory = new core.Outbox__factory(signer);
const factory = new Outbox__factory(signer);
const implementation = await factory.deploy(
domain,
this.deploy.chains[domain].overrides,
@ -50,7 +50,7 @@ export class ImplementationDeployer {
*/
private async _deployInboxImplementation(domain: types.Domain) {
const signer = this.deploy.signer(domain);
const factory = new core.Inbox__factory(signer);
const factory = new Inbox__factory(signer);
const implementation = await factory.deploy(
domain,
this.config.processGas,

@ -1,11 +1,14 @@
import fs from 'fs';
import { xapps } from '@abacus-network/ts-interface';
import {
GovernanceRouter,
GovernanceRouter__factory,
} from '@abacus-network/apps';
import { ethers } from 'ethers';
import { CommonContracts, BeaconProxy } from '../common';
import { GovernanceContractAddresses } from './types';
export class GovernanceContracts extends CommonContracts<GovernanceContractAddresses> {
constructor(public readonly router: BeaconProxy<xapps.GovernanceRouter>) {
constructor(public readonly router: BeaconProxy<GovernanceRouter>) {
super();
}
@ -28,9 +31,9 @@ export class GovernanceContracts extends CommonContracts<GovernanceContractAddre
addresses: GovernanceContractAddresses,
signer: ethers.Signer,
): GovernanceContracts {
const router: BeaconProxy<xapps.GovernanceRouter> = BeaconProxy.fromObject(
const router: BeaconProxy<GovernanceRouter> = BeaconProxy.fromObject(
addresses.router,
xapps.GovernanceRouter__factory.abi,
GovernanceRouter__factory.abi,
signer,
);
return new GovernanceContracts(router);

@ -1,6 +1,6 @@
import { ethers } from 'ethers';
import { types } from '@abacus-network/utils';
import { xapps } from '@abacus-network/ts-interface';
import { GovernanceRouter } from '@abacus-network/apps';
import { CommonDeploy, DeployType } from '../common';
import { ChainConfig } from '../config';
import { RouterDeploy } from '../router';
@ -47,7 +47,7 @@ export class GovernanceDeploy extends RouterDeploy<
);
}
router(domain: types.Domain): xapps.GovernanceRouter {
router(domain: types.Domain): GovernanceRouter {
return this.instances[domain].router;
}
}

@ -1,4 +1,7 @@
import { xapps } from '@abacus-network/ts-interface';
import {
GovernanceRouter,
GovernanceRouter__factory,
} from '@abacus-network/apps';
import { types } from '@abacus-network/utils';
import { ChainConfig } from '../config';
import { BeaconProxy } from '../common';
@ -22,10 +25,9 @@ export class GovernanceInstance extends RouterInstance<GovernanceContracts> {
const core = config.core[chain.name];
if (core === undefined) throw new Error('could not find core');
const router: BeaconProxy<xapps.GovernanceRouter> =
await BeaconProxy.deploy(
const router: BeaconProxy<GovernanceRouter> = await BeaconProxy.deploy(
chain,
new xapps.GovernanceRouter__factory(chain.signer),
new GovernanceRouter__factory(chain.signer),
core.upgradeBeaconController,
[config.recoveryTimelock],
[core.xAppConnectionManager],
@ -39,7 +41,7 @@ export class GovernanceInstance extends RouterInstance<GovernanceContracts> {
return new GovernanceInstance(chain, contracts);
}
get router(): xapps.GovernanceRouter {
get router(): GovernanceRouter {
return this.contracts.router.contract;
}
@ -47,7 +49,7 @@ export class GovernanceInstance extends RouterInstance<GovernanceContracts> {
return getBeaconProxyVerificationInput(
'GovernanceRouter',
this.contracts.router,
xapps.GovernanceRouter__factory.bytecode,
GovernanceRouter__factory.bytecode,
);
}
}

@ -1,5 +1,8 @@
import { ethers } from 'ethers';
import { core } from '@abacus-network/ts-interface';
import {
UpgradeBeacon__factory,
UpgradeBeaconProxy__factory,
} from '@abacus-network/core';
import { BeaconProxy } from '../common';
import {
@ -60,7 +63,7 @@ export function getBeaconProxyVerificationInput(
address: contract.beacon.address,
constructorArguments: getConstructorArguments(
contract.beacon,
core.UpgradeBeacon__factory.bytecode,
UpgradeBeacon__factory.bytecode,
),
};
const proxy: ContractVerificationInput = {
@ -68,7 +71,7 @@ export function getBeaconProxyVerificationInput(
address: contract.proxy.address,
constructorArguments: getConstructorArguments(
contract.proxy,
core.UpgradeBeaconProxy__factory.bytecode,
UpgradeBeaconProxy__factory.bytecode,
),
isProxy: true,
};

@ -4,7 +4,7 @@
"rootDir": "./"
},
"exclude": ["./node_modules/", "./dist/", "./tmp.ts"],
"extends": "../tsconfig.package.json",
"extends": "../../tsconfig.package.json",
"include": [
"./*.ts",
"./config/**/*.ts",

@ -1,3 +1,2 @@
.env
dist
tsconfig.tsbuildinfo

@ -5,14 +5,11 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf ./dist/ && rm tsconfig.tsbuildinfo & tsc",
"check": "rm tsconfig.tsbuildinfo & tsc --noEmit",
"build": "tsc",
"check": "tsc --noEmit",
"prettier": "prettier --write ./src",
"lint": "npm run prettier && eslint ./src",
"lint:fix": "npm run prettier && eslint --fix ./src",
"prepublishOnly": "npm run build"
},
"author": "Celo Labs Inc.",
"license": "MIT OR Apache-2.0",
"devDependencies": {
"@types/node": "^16.9.1",
@ -26,10 +23,11 @@
"typescript": "^4.4.3"
},
"dependencies": {
"@abacus-network/apps": "file:../../solidity/apps",
"@abacus-network/core": "file:../../solidity/core",
"@ethersproject/bignumber": "^5.5.0",
"@ethersproject/bytes": "^5.5.0",
"celo-ethers-provider": "0.0.0",
"ethers": "^5.4.7",
"@abacus-network/ts-interface": "^0.0.1"
"ethers": "^5.4.7"
}
}

@ -1,6 +1,7 @@
import { BigNumberish, ethers } from 'ethers';
import { MultiProvider } from '..';
import { xapps, core } from '@abacus-network/ts-interface';
import { Inbox } from '@abacus-network/core';
import { BridgeToken, BridgeToken__factory } from '@abacus-network/apps';
import { BridgeContracts } from './contracts/BridgeContracts';
import { Governor, CoreContracts } from './contracts/CoreContracts';
import { ResolvedTokenInfo, TokenIdentifier } from './tokens';
@ -198,7 +199,7 @@ export class AbacusContext extends MultiProvider {
getInboxFor(
outbox: string | number,
remote: string | number,
): core.Inbox | undefined {
): Inbox | undefined {
return this.getCore(remote)?.getInbox(this.resolveDomain(outbox));
}
@ -213,10 +214,7 @@ export class AbacusContext extends MultiProvider {
* @returns An interface for the Inbox
* @throws If no inbox is found.
*/
mustGetInboxFor(
outbox: string | number,
remote: string | number,
): core.Inbox {
mustGetInboxFor(outbox: string | number, remote: string | number): Inbox {
const inbox = this.getInboxFor(outbox, remote);
if (!inbox) {
throw new Error(`Missing inbox for outbox ${outbox} & remote ${remote}`);
@ -277,7 +275,7 @@ export class AbacusContext extends MultiProvider {
async resolveRepresentation(
nameOrDomain: string | number,
token: TokenIdentifier,
): Promise<xapps.BridgeToken | undefined> {
): Promise<BridgeToken | undefined> {
const domain = this.resolveDomain(nameOrDomain);
const bridge = this.getBridge(domain);
@ -292,7 +290,7 @@ export class AbacusContext extends MultiProvider {
return;
}
let contract = new xapps.BridgeToken__factory().attach(evmId(address));
let contract = new BridgeToken__factory().attach(evmId(address));
const connection = this.getConnection(domain);
if (connection) {
@ -315,7 +313,7 @@ export class AbacusContext extends MultiProvider {
async resolveRepresentations(
token: TokenIdentifier,
): Promise<ResolvedTokenInfo> {
const tokens: Map<number, xapps.BridgeToken> = new Map();
const tokens: Map<number, BridgeToken> = new Map();
await Promise.all(
this.domainNumbers.map(async (domain) => {
@ -389,7 +387,7 @@ export class AbacusContext extends MultiProvider {
async resolveCanonicalToken(
nameOrDomain: string | number,
representation: Address,
): Promise<xapps.BridgeToken> {
): Promise<BridgeToken> {
const canonicalId = await this.resolveCanonicalIdentifier(
nameOrDomain,
representation,

@ -1,5 +1,10 @@
import { ethers } from 'ethers';
import { xapps } from '@abacus-network/ts-interface';
import {
BridgeRouter,
BridgeRouter__factory,
ETHHelper,
ETHHelper__factory,
} from '@abacus-network/apps';
import { Contracts } from '../../contracts';
type Address = string;
@ -16,8 +21,8 @@ interface BridgeInfo {
export class BridgeContracts extends Contracts {
domain: number;
bridgeRouter: xapps.BridgeRouter;
ethHelper?: xapps.ETHHelper;
bridgeRouter: BridgeRouter;
ethHelper?: ETHHelper;
constructor(
domain: number,
@ -27,11 +32,9 @@ export class BridgeContracts extends Contracts {
) {
super(domain, bridgeRouter, ethHelper, signer);
this.domain = domain;
this.bridgeRouter = new xapps.BridgeRouter__factory(signer).attach(
bridgeRouter,
);
this.bridgeRouter = new BridgeRouter__factory(signer).attach(bridgeRouter);
if (ethHelper) {
this.ethHelper = new xapps.ETHHelper__factory(signer).attach(ethHelper);
this.ethHelper = new ETHHelper__factory(signer).attach(ethHelper);
}
}

@ -1,5 +1,16 @@
import { ethers } from 'ethers';
import { core, xapps } from '@abacus-network/ts-interface';
import {
Inbox,
Outbox,
Inbox__factory,
Outbox__factory,
XAppConnectionManager,
XAppConnectionManager__factory,
} from '@abacus-network/core';
import {
GovernanceRouter,
GovernanceRouter__factory,
} from '@abacus-network/apps';
import { Contracts } from '../../contracts';
import { InboxInfo } from '../domains/domain';
import { CallBatch } from '../govern';
@ -52,37 +63,37 @@ export class CoreContracts extends Contracts {
});
}
getInbox(domain: number): core.Inbox | undefined {
getInbox(domain: number): Inbox | undefined {
if (!this.providerOrSigner) {
throw new Error('No provider or signer. Call `connect` first.');
}
const inbox = this._inboxes.get(domain);
if (!inbox) return;
return core.Inbox__factory.connect(inbox.address, this.providerOrSigner);
return Inbox__factory.connect(inbox.address, this.providerOrSigner);
}
get outbox(): core.Outbox {
get outbox(): Outbox {
if (!this.providerOrSigner) {
throw new Error('No provider or signer. Call `connect` first.');
}
return core.Outbox__factory.connect(this._outbox, this.providerOrSigner);
return Outbox__factory.connect(this._outbox, this.providerOrSigner);
}
get governanceRouter(): xapps.GovernanceRouter {
get governanceRouter(): GovernanceRouter {
if (!this.providerOrSigner) {
throw new Error('No provider or signer. Call `connect` first.');
}
return xapps.GovernanceRouter__factory.connect(
return GovernanceRouter__factory.connect(
this._governanceRouter,
this.providerOrSigner,
);
}
get xAppConnectionManager(): core.XAppConnectionManager {
get xAppConnectionManager(): XAppConnectionManager {
if (!this.providerOrSigner) {
throw new Error('No provider or signer. Call `connect` first.');
}
return core.XAppConnectionManager__factory.connect(
return XAppConnectionManager__factory.connect(
this._xAppConnectionManager,
this.providerOrSigner,
);

@ -2,7 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber';
import { Result } from '@ethersproject/abi';
import { TransactionReceipt } from '@ethersproject/abstract-provider';
import { TypedEvent } from '@abacus-network/ts-interface/dist/abacus-core/commons';
import { TypedEvent } from '@abacus-network/core/dist/commons';
// copied from the Outbox.d.ts
export type DispatchTypes = [string, BigNumber, BigNumber, string, string];

@ -1,4 +1,4 @@
import { TypedEvent } from '@abacus-network/ts-interface/dist/abacus-core/commons';
import { TypedEvent } from '@abacus-network/core/dist/commons';
import { BigNumber } from 'ethers';
import { Annotated } from '.';

@ -5,7 +5,7 @@ import { Result } from '@ethersproject/abi';
import {
TypedEvent,
TypedEventFilter,
} from '@abacus-network/ts-interface/dist/abacus-core/commons';
} from '@abacus-network/core/dist/commons';
// specifies an interface shared by the TS generated contracts
export interface TSContract<T extends Result, U> {

@ -1,7 +1,7 @@
import { BigNumber } from '@ethersproject/bignumber';
import { arrayify, hexlify } from '@ethersproject/bytes';
import { TransactionReceipt } from '@ethersproject/abstract-provider';
import { core } from '@abacus-network/ts-interface';
import { Inbox, Outbox, Outbox__factory } from '@abacus-network/core';
import { AbacusContext } from '..';
import { delay } from '../../utils';
import {
@ -77,8 +77,8 @@ export function parseMessage(message: string): ParsedMessage {
export class AbacusMessage {
readonly dispatch: AnnotatedDispatch;
readonly message: ParsedMessage;
readonly outbox: core.Outbox;
readonly inbox: core.Inbox;
readonly outbox: Outbox;
readonly inbox: Inbox;
readonly context: AbacusContext;
protected cache: EventCache;
@ -116,7 +116,7 @@ export class AbacusMessage {
receipt: TransactionReceipt,
): AbacusMessage[] {
const messages: AbacusMessage[] = [];
const outbox = new core.Outbox__factory().interface;
const outbox = new Outbox__factory().interface;
for (const log of receipt.logs) {
try {

@ -2,7 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber';
import { arrayify, hexlify } from '@ethersproject/bytes';
import { TransactionReceipt } from '@ethersproject/abstract-provider';
import { ethers } from 'ethers';
import { xapps } from '@abacus-network/ts-interface';
import { ERC20 } from '@abacus-network/apps';
import { BridgeContracts, AbacusContext } from '..';
import { ResolvedTokenInfo, TokenIdentifier } from '../tokens';
import { AbacusMessage } from './AbacusMessage';
@ -301,7 +301,7 @@ class BridgeMessage extends AbacusMessage {
*
* @returns The resolved token interface.
*/
async assetAtOrigin(): Promise<xapps.ERC20 | undefined> {
async assetAtOrigin(): Promise<ERC20 | undefined> {
return (await this.asset()).tokens.get(this.origin);
}
@ -314,7 +314,7 @@ class BridgeMessage extends AbacusMessage {
*
* @returns The resolved token interface.
*/
async assetAtDestination(): Promise<xapps.ERC20 | undefined> {
async assetAtDestination(): Promise<ERC20 | undefined> {
return (await this.asset()).tokens.get(this.destination);
}
}

@ -1,5 +1,5 @@
import { BytesLike } from 'ethers';
import { xapps } from '@abacus-network/ts-interface';
import { BridgeToken } from '@abacus-network/apps';
import wellKnown from './wellKnown';
import testnetWellKnown from './testnetWellKnown';
@ -14,7 +14,7 @@ export type ResolvedTokenInfo = {
// The canonical identifier
id: BytesLike;
// The contract on each chain
tokens: Map<number, xapps.BridgeToken>;
tokens: Map<number, BridgeToken>;
};
export const tokens = wellKnown;

@ -1,5 +1,5 @@
{
"extends": "../tsconfig.package.json",
"extends": "../../tsconfig.package.json",
"compilerOptions": {
"outDir": "./dist/",
"rootDir": "./src/"

@ -1,4 +1,3 @@
dist/
unprocessed/
tsconfig.tsbuildinfo
credentials.json

@ -7,13 +7,13 @@
"value": "ts-node src/value.ts | ./node_modules/.bin/bunyan",
"trace": "ts-node src/trace.ts",
"gas": "ts-node src/gas.ts",
"build": "rm tsconfig.tsbuildinfo & tsc",
"check": "rm tsconfig.tsbuildinfo & tsc --noEmit",
"build": "tsc",
"check": "tsc --noEmit",
"prettier": "prettier --write ."
},
"dependencies": {
"@abacus-network/apps": "file:../../solidity/apps",
"@abacus-network/sdk": "^0.0.1",
"@abacus-network/ts-interface": "file:../typechain",
"@types/bunyan": "^1.8.7",
"@types/express": "^4.17.13",
"@types/google-spreadsheet": "^3.1.5",

@ -1,5 +1,5 @@
import { AbacusContext } from '@abacus-network/sdk';
import { xapps } from '@abacus-network/ts-interface';
import { GovernanceRouter } from '@abacus-network/apps';
import config from '../config';
export async function monitorGovernance(
@ -16,7 +16,7 @@ export async function monitorGovernance(
async function monitorRecoveryActiveAt(
network: string,
router: xapps.GovernanceRouter,
router: GovernanceRouter,
) {
const logger = config.baseLogger.child({
network,

@ -4,6 +4,6 @@
"rootDir": "./src/"
},
"exclude": ["./node_modules/", "./dist/", "./tmp.ts"],
"extends": "../tsconfig.package.json",
"extends": "../../tsconfig.package.json",
"include": ["./src/*.ts", "./src/**/*.ts"]
}

@ -3,17 +3,16 @@
"name": "@abacus-network/hardhat",
"version": "0.0.5",
"description": "Abacus hardhat tools",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"check": "tsc --noEmit",
"prettier": "prettier --write ./src"
},
"author": "Celo Labs Inc.",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@abacus-network/abacus-sol": "^0.0.0",
"@abacus-network/core": "file:../../solidity/core",
"@abacus-network/utils": "^0.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.5",
"@nomiclabs/hardhat-waffle": "^2.0.2",

@ -11,8 +11,8 @@ import {
XAppConnectionManager__factory,
TestInbox,
TestInbox__factory,
} from "@abacus-network/abacus-sol/typechain";
import { Validator } from "@abacus-network/abacus-sol/test/lib/core";
} from "@abacus-network/core";
import { Validator } from "@abacus-network/core/test/lib/core";
import { TestDeploy } from "./TestDeploy";
export type TestAbacusConfig = {

@ -4,7 +4,7 @@
"rootDir": "./"
},
"exclude": ["./node_modules/", "./dist/", "./tmp.ts"],
"extends": "../tsconfig.package.json",
"extends": "../../tsconfig.package.json",
"include": [
"./index.ts",
"./src/*.ts"

@ -1,4 +0,0 @@
.env
dist
abacus-core/*
abacus-xapps/*

@ -1,2 +0,0 @@
export * as core from "./abacus-core";
export * as xapps from "./abacus-xapps";

@ -1,23 +0,0 @@
{
"scripts": {
"build": "tsc && npm run copy-files",
"check": "tsc --noEmit",
"copy-files": "cp abacus-core/*.d.ts dist/abacus-core && cp abacus-xapps/*.d.ts dist/abacus-xapps"
},
"devDependencies": {
"ethers": "^5.5.3"
},
"name": "@abacus-network/ts-interface",
"version": "0.0.1",
"description": "Abacus contract typechain gens",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Celo Labs Inc.",
"license": "MIT OR Apache-2.0",
"prepublish": "npm run build",
"dependencies": {
"@ethersproject/experimental": "^5.5.0",
"@types/node": "^16.11.21",
"typescript": "^4.5.5"
}
}

@ -1,20 +0,0 @@
{
"compilerOptions": {
"outDir": "./dist/",
"rootDir": "./"
},
"exclude": [
"./node_modules/",
"./dist/",
"./abacus-core/hardhat.d.ts",
"./abacus-xapps/hardhat.d.ts"
],
"extends": "../tsconfig.package.json",
"include": [
"./index.ts",
"./abacus-core/*.ts",
"./abacus-xapps/*.ts",
"./abacus-core/factories/*.ts",
"./abacus-xapps/factories/*.ts"
]
}

@ -3,8 +3,8 @@
"name": "@abacus-network/utils",
"version": "0.0.5",
"description": "Abacus utilities",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"check": "tsc --noEmit",

@ -4,7 +4,7 @@
"rootDir": "./"
},
"exclude": ["./node_modules/", "./dist/", "./tmp.ts"],
"extends": "../tsconfig.package.json",
"extends": "../../tsconfig.package.json",
"include": [
"./index.ts",
"./src/*.ts"

Loading…
Cancel
Save