refactor: remove all relative imports in TS (#797)

buddies-main-deployment
James Prestwich 3 years ago committed by GitHub
parent 8ec38ff1c2
commit adfb4ef50e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      typescript/optics-deploy/.gitignore
  2. 75
      typescript/optics-deploy/package-lock.json
  3. 18
      typescript/optics-deploy/package.json
  4. 1
      typescript/optics-deploy/scripts/mainnet/core.ts
  5. 2
      typescript/optics-deploy/src/bridge/BridgeContracts.ts
  6. 53
      typescript/optics-deploy/src/bridge/TestBridgeDeploy.ts
  7. 54
      typescript/optics-deploy/src/bridge/checks.ts
  8. 18
      typescript/optics-deploy/src/bridge/index.ts
  9. 2
      typescript/optics-deploy/src/chain.ts
  10. 2
      typescript/optics-deploy/src/core/CoreContracts.ts
  11. 6
      typescript/optics-deploy/src/core/CoreDeploy.ts
  12. 125
      typescript/optics-deploy/src/core/checks.ts
  13. 45
      typescript/optics-deploy/src/core/index.ts
  14. 43
      typescript/optics-deploy/src/deploy.ts
  15. 14
      typescript/optics-deploy/src/proxyUtils.ts
  16. 9
      typescript/optics-deploy/src/utils.ts
  17. 87
      typescript/optics-deploy/tsconfig.json
  18. 0
      typescript/optics-provider/.npmignore
  19. 18
      typescript/optics-provider/package-lock.json
  20. 10
      typescript/optics-provider/package.json
  21. 2
      typescript/optics-provider/src/optics/index.ts
  22. 82
      typescript/optics-provider/tsconfig.json
  23. 1
      typescript/optics-provider/tsconfig.tsbuildinfo
  24. 1
      typescript/optics-tests/.gitignore
  25. 4
      typescript/optics-tests/hardhat.config.ts
  26. 59
      typescript/optics-tests/lib/bridge.ts
  27. 2
      typescript/optics-tests/lib/core.ts
  28. 2
      typescript/optics-tests/lib/permit.ts
  29. 17
      typescript/optics-tests/lib/types.ts
  30. 17999
      typescript/optics-tests/package-lock.json
  31. 10
      typescript/optics-tests/package.json
  32. 2
      typescript/optics-tests/test/bridge/BridgeToken.test.ts
  33. 26
      typescript/optics-tests/test/bridge/EthHelper.test.ts
  34. 34
      typescript/optics-tests/test/bridge/bridge.test.ts
  35. 179
      typescript/optics-tests/test/bridge/bridgeMessage.test.ts
  36. 2
      typescript/optics-tests/test/bridge/encoding.test.ts
  37. 8
      typescript/optics-tests/test/common.test.ts
  38. 18
      typescript/optics-tests/test/cross-chain/governanceRouter.test.ts
  39. 6
      typescript/optics-tests/test/cross-chain/recoveryManager.test.ts
  40. 24
      typescript/optics-tests/test/cross-chain/simpleMessage.test.ts
  41. 2
      typescript/optics-tests/test/cross-chain/utils.ts
  42. 54
      typescript/optics-tests/test/deploy.test.ts
  43. 25
      typescript/optics-tests/test/home.test.ts
  44. 8
      typescript/optics-tests/test/merkle.test.ts
  45. 7
      typescript/optics-tests/test/message.test.ts
  46. 2
      typescript/optics-tests/test/multiProvider.test.ts
  47. 9
      typescript/optics-tests/test/queue.test.ts
  48. 35
      typescript/optics-tests/test/replica.test.ts
  49. 7
      typescript/optics-tests/test/testChain.ts
  50. 2
      typescript/optics-tests/test/upgrade.test.ts
  51. 14
      typescript/optics-tests/test/utils.ts
  52. 13
      typescript/optics-tests/test/xAppConnectionManager.test.ts
  53. 82
      typescript/optics-tests/tsconfig.json
  54. 4
      typescript/typechain/optics-xapps/hardhat.d.ts
  55. 2
      typescript/typechain/optics-xapps/index.ts
  56. 4
      typescript/typechain/package-lock.json
  57. 13
      typescript/typechain/package.json

@ -1,2 +1,4 @@
node_modules
node_modules/
tmp.ts
dist/
.env

@ -1,21 +1,24 @@
{
"name": "optics-deploy",
"version": "1.0.0",
"name": "@optics-xyz/deploy",
"version": "0.0.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "optics-deploy",
"version": "1.0.0",
"name": "@optics-xyz/deploy",
"version": "0.0.3",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@ethersproject/experimental": "^5.3.0",
"@optics-xyz/multi-provider": "^0.0.4",
"@optics-xyz/ts-interface": "^1.0.9",
"@types/node": "^16.7.2",
"axios": "^0.21.3",
"chai": "^4.3.4",
"dotenv": "^10.0.0"
},
"devDependencies": {
"chai": "^4.3.4",
"@types/chai": "^4.2.21",
"ethers": "^5.4.4",
"prettier": "^2.3.1",
"ts-node": "^10.1.0",
@ -711,6 +714,19 @@
"@ethersproject/strings": "^5.4.0"
}
},
"node_modules/@optics-xyz/multi-provider": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/@optics-xyz/multi-provider/-/multi-provider-0.0.4.tgz",
"integrity": "sha512-9gpxRsiVGo/xcBZiRh7oDFN8DBhe+PtGZYEH8sI5sa5R3Z3F8SkYUKMFO3iXktc2qoXeUuGNYcoJOWWYIk+SCA=="
},
"node_modules/@optics-xyz/ts-interface": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@optics-xyz/ts-interface/-/ts-interface-1.0.9.tgz",
"integrity": "sha512-zkA5bUuVZf8n3uw51KF/RNo205y1JCYkCzr+NZsHKZBldjUnbA8qj6d1DBtxHk1B3Dgrk41M3pGTtqhpGWue7g==",
"dependencies": {
"@ethersproject/experimental": "^5.3.0"
}
},
"node_modules/@tsconfig/node10": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz",
@ -735,6 +751,12 @@
"integrity": "sha512-FTgBI767POY/lKNDNbIzgAX6miIDBs6NTCbdlDb8TrWovHsSvaVIZDlTqym29C6UqhzwcJx4CYr+AlrMywA0cA==",
"dev": true
},
"node_modules/@types/chai": {
"version": "4.2.21",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.21.tgz",
"integrity": "sha512-yd+9qKmJxm496BOV9CMNaey8TWsikaZOwMRwPHQIjcOJM9oV+fi9ZMNw3JsVnbEEbo2gRTDnGEBv8pjyn67hNg==",
"dev": true
},
"node_modules/@types/node": {
"version": "16.7.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.2.tgz",
@ -773,7 +795,6 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz",
"integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
"dev": true,
"engines": {
"node": "*"
}
@ -827,7 +848,6 @@
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz",
"integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==",
"dev": true,
"dependencies": {
"assertion-error": "^1.1.0",
"check-error": "^1.0.2",
@ -844,7 +864,6 @@
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
"integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=",
"dev": true,
"engines": {
"node": "*"
}
@ -896,7 +915,6 @@
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
"integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==",
"dev": true,
"dependencies": {
"type-detect": "^4.0.0"
},
@ -1050,7 +1068,6 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
"integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=",
"dev": true,
"engines": {
"node": "*"
}
@ -1203,7 +1220,6 @@
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
"integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==",
"dev": true,
"engines": {
"node": "*"
}
@ -1324,7 +1340,6 @@
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
"dev": true,
"engines": {
"node": ">=4"
}
@ -1799,6 +1814,19 @@
"@ethersproject/strings": "^5.4.0"
}
},
"@optics-xyz/multi-provider": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/@optics-xyz/multi-provider/-/multi-provider-0.0.4.tgz",
"integrity": "sha512-9gpxRsiVGo/xcBZiRh7oDFN8DBhe+PtGZYEH8sI5sa5R3Z3F8SkYUKMFO3iXktc2qoXeUuGNYcoJOWWYIk+SCA=="
},
"@optics-xyz/ts-interface": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@optics-xyz/ts-interface/-/ts-interface-1.0.9.tgz",
"integrity": "sha512-zkA5bUuVZf8n3uw51KF/RNo205y1JCYkCzr+NZsHKZBldjUnbA8qj6d1DBtxHk1B3Dgrk41M3pGTtqhpGWue7g==",
"requires": {
"@ethersproject/experimental": "^5.3.0"
}
},
"@tsconfig/node10": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz",
@ -1823,6 +1851,12 @@
"integrity": "sha512-FTgBI767POY/lKNDNbIzgAX6miIDBs6NTCbdlDb8TrWovHsSvaVIZDlTqym29C6UqhzwcJx4CYr+AlrMywA0cA==",
"dev": true
},
"@types/chai": {
"version": "4.2.21",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.21.tgz",
"integrity": "sha512-yd+9qKmJxm496BOV9CMNaey8TWsikaZOwMRwPHQIjcOJM9oV+fi9ZMNw3JsVnbEEbo2gRTDnGEBv8pjyn67hNg==",
"dev": true
},
"@types/node": {
"version": "16.7.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.2.tgz",
@ -1857,8 +1891,7 @@
"assertion-error": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz",
"integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
"dev": true
"integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw=="
},
"axios": {
"version": "0.21.3",
@ -1909,7 +1942,6 @@
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz",
"integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==",
"dev": true,
"requires": {
"assertion-error": "^1.1.0",
"check-error": "^1.0.2",
@ -1922,8 +1954,7 @@
"check-error": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
"integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=",
"dev": true
"integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII="
},
"command-line-args": {
"version": "4.0.7",
@ -1961,7 +1992,6 @@
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
"integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==",
"dev": true,
"requires": {
"type-detect": "^4.0.0"
}
@ -2074,8 +2104,7 @@
"get-func-name": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
"integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=",
"dev": true
"integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE="
},
"glob": {
"version": "7.1.7",
@ -2206,8 +2235,7 @@
"pathval": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
"integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==",
"dev": true
"integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ=="
},
"prettier": {
"version": "2.3.2",
@ -2285,8 +2313,7 @@
"type-detect": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
"dev": true
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g=="
},
"typechain": {
"version": "5.1.1",

@ -1,26 +1,32 @@
{
"devDependencies": {
"chai": "^4.3.4",
"@types/chai": "^4.2.21",
"ethers": "^5.4.4",
"prettier": "^2.3.1",
"ts-node": "^10.1.0",
"typechain": "^5.0.0",
"typescript": "^4.3.2"
},
"name": "optics-deploy",
"version": "1.0.0",
"prepublish": "npm run build",
"name": "@optics-xyz/deploy",
"version": "0.0.3",
"description": "Optics deploy tools",
"main": "src/index.ts",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"scripts": {
"prettier": "prettier --write ./src ./config ./scripts",
"test": "echo \"Error: no test specified\" && exit 1"
"build": "tsc",
"check": "tsc --noEmit",
"prettier": "prettier --write ./src ./config ./scripts"
},
"author": "Celo Labs Inc.",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@ethersproject/experimental": "^5.3.0",
"@optics-xyz/multi-provider": "^0.0.4",
"@optics-xyz/ts-interface": "^1.0.9",
"@types/node": "^16.7.2",
"axios": "^0.21.3",
"chai": "^4.3.4",
"dotenv": "^10.0.0"
}
}

@ -3,7 +3,6 @@ import * as celo from '../../config/mainnets/celo';
import * as ethereum from '../../config/mainnets/ethereum';
import * as polygon from '../../config/mainnets/polygon';
import { CoreDeploy } from '../../src/core/CoreDeploy';
import { deployEnvironment } from '../../src/chain';
let celoConfig = celo.config;
let kovanConfig = ethereum.config;

@ -1,4 +1,4 @@
import * as xAppContracts from '../../../typechain/optics-xapps';
import * as xAppContracts from '@optics-xyz/ts-interface/dist/optics-xapps';
import { BeaconProxy } from '../proxyUtils';
import { Contracts } from '../contracts';

@ -1,8 +1,8 @@
import { BytesLike, Signer } from 'ethers';
import { BigNumber, BytesLike, Signer } from 'ethers';
import {
UpgradeBeaconController,
UpgradeBeaconController__factory,
} from '../../../typechain/optics-core';
} from '@optics-xyz/ts-interface/dist/optics-core';
import {
BridgeRouter,
BridgeToken,
@ -11,18 +11,55 @@ import {
MockCore__factory,
MockWeth,
MockWeth__factory,
} from '../../../typechain/optics-xapps';
} from '@optics-xyz/ts-interface/dist/optics-xapps';
import { ContractVerificationInput } from '../deploy';
import { BridgeContracts } from './BridgeContracts';
import * as process from '.';
import { TokenId } from '../../../optics-tests/lib/types';
import { Chain } from '../chain';
import { getTestChain } from '../../../optics-tests/test/testChain';
import { TokenIdentifier } from '@optics-xyz/multi-provider/dist/optics/tokens';
import { CoreConfig } from '../core/CoreDeploy';
function toBytes32(address: string): string {
return '0x' + '00'.repeat(12) + address.slice(2);
}
export async function getTestChain(
ethers: any,
domain: number,
updater: string,
watchers: string[],
recoveryManager?: string,
): Promise<[Chain, CoreConfig]> {
const [, , , , , , , deployer] = await ethers.getSigners();
return [
{
name: 'hh',
provider: ethers.provider,
deployer,
gasPrice: BigNumber.from(20000000000),
gasLimit: BigNumber.from(6_000_000),
confirmations: 0,
domain,
config: {
domain,
name: 'hh',
rpc: 'NA',
},
},
{
environment: 'dev',
recoveryTimelock: 1,
recoveryManager: recoveryManager || ethers.constants.AddressZero,
updater,
optimisticSeconds: 3,
watchers,
processGas: 850_000,
reserveGas: 15_000,
},
];
}
// A BridgeRouter deployed with a mock Core suite.
//
// Intended usage: instatiate in hardhat tests with `deploy`. Interact with
@ -65,13 +102,13 @@ export default class TestBridgeDeploy {
this.chain = chain;
}
static async deploy(signer: Signer): Promise<TestBridgeDeploy> {
static async deploy(ethers: any, signer: Signer): Promise<TestBridgeDeploy> {
const mockCore = await new MockCore__factory(signer).deploy();
const mockWeth = await new MockWeth__factory(signer).deploy();
const ubc = await new UpgradeBeaconController__factory(signer).deploy();
const contracts = new BridgeContracts();
const domain = await mockCore.localDomain();
const [chain] = await getTestChain(domain, '', []);
const [chain] = await getTestChain(ethers, domain, '', []);
chain.deployer = signer;
let deploy = new TestBridgeDeploy(
@ -138,7 +175,7 @@ export default class TestBridgeDeploy {
return `0x${'11'.repeat(32)}`;
}
get testTokenId(): TokenId {
get testTokenId(): TokenIdentifier {
return {
domain: this.remoteDomain,
id: this.testToken,

@ -21,21 +21,51 @@ export async function checkBridgeDeploy(
}
const bridgeRouter = deploy.contracts.bridgeRouter?.proxy!;
await Promise.all(remotes.map(async (remoteDomain) => {
const registeredRouter = await bridgeRouter.remotes(remoteDomain);
expect(registeredRouter).to.not.equal(emptyAddr);
}))
await Promise.all(
remotes.map(async (remoteDomain) => {
const registeredRouter = await bridgeRouter.remotes(remoteDomain);
expect(registeredRouter).to.not.equal(emptyAddr);
}),
);
expect(await bridgeRouter.owner()).to.equal(deploy.coreContractAddresses.governance.proxy);
expect(await bridgeRouter.owner()).to.equal(
deploy.coreContractAddresses.governance.proxy,
);
// check verification addresses
checkVerificationInput(deploy, 'BridgeToken Implementation', deploy.contracts.bridgeToken?.implementation.address!);
checkVerificationInput(deploy, 'BridgeToken UpgradeBeacon', deploy.contracts.bridgeToken?.beacon.address!);
checkVerificationInput(deploy, 'BridgeToken Proxy', deploy.contracts.bridgeToken?.proxy.address!);
checkVerificationInput(deploy, 'BridgeRouter Implementation', deploy.contracts.bridgeRouter?.implementation.address!);
checkVerificationInput(deploy, 'BridgeRouter UpgradeBeacon', deploy.contracts.bridgeRouter?.beacon.address!);
checkVerificationInput(deploy, 'BridgeRouter Proxy', deploy.contracts.bridgeRouter?.proxy.address!);
checkVerificationInput(
deploy,
'BridgeToken Implementation',
deploy.contracts.bridgeToken?.implementation.address!,
);
checkVerificationInput(
deploy,
'BridgeToken UpgradeBeacon',
deploy.contracts.bridgeToken?.beacon.address!,
);
checkVerificationInput(
deploy,
'BridgeToken Proxy',
deploy.contracts.bridgeToken?.proxy.address!,
);
checkVerificationInput(
deploy,
'BridgeRouter Implementation',
deploy.contracts.bridgeRouter?.implementation.address!,
);
checkVerificationInput(
deploy,
'BridgeRouter UpgradeBeacon',
deploy.contracts.bridgeRouter?.beacon.address!,
);
checkVerificationInput(
deploy,
'BridgeRouter Proxy',
deploy.contracts.bridgeRouter?.proxy.address!,
);
if (deploy.config.weth) {
expect(deploy.verificationInput[6].address).to.equal(deploy.contracts.ethHelper?.address);
expect(deploy.verificationInput[6].address).to.equal(
deploy.contracts.ethHelper?.address,
);
}
}

@ -1,7 +1,7 @@
import * as proxyUtils from '../proxyUtils';
import { checkBridgeDeploy } from './checks';
import * as xAppContracts from '../../../typechain/optics-xapps';
import { toBytes32 } from '../../../optics-tests/lib/utils';
import * as xAppContracts from '@optics-xyz/ts-interface/dist/optics-xapps';
import { toBytes32 } from '../utils';
import fs from 'fs';
import { BridgeDeploy } from './BridgeDeploy';
import TestBridgeDeploy from './TestBridgeDeploy';
@ -31,7 +31,7 @@ export async function deployBridges(deploys: Deploy[]) {
await deployTokenUpgradeBeacon(deploy);
await deployBridgeRouter(deploy);
await deployEthHelper(deploy);
})
}),
);
// after all BridgeRouters have been deployed,
@ -39,7 +39,7 @@ export async function deployBridges(deploys: Deploy[]) {
await Promise.all(
deploys.map(async (deploy) => {
await enrollAllBridgeRouters(deploy, deploys);
})
}),
);
// after all peer BridgeRouters have been co-enrolled,
@ -47,17 +47,17 @@ export async function deployBridges(deploys: Deploy[]) {
await Promise.all(
deploys.map(async (deploy) => {
await transferOwnershipToGovernance(deploy);
})
}),
);
await Promise.all(
deploys.map(async (local) => {
const remotes = deploys
.filter(remote => remote.chain.domain != local.chain.domain)
.map(remote => remote.chain.domain);
.filter((remote) => remote.chain.domain != local.chain.domain)
.map((remote) => remote.chain.domain);
await checkBridgeDeploy(local, remotes);
})
)
}),
);
if (!isTestDeploy) {
// output the Bridge deploy information to a subdirectory

@ -2,8 +2,8 @@ import * as ethers from 'ethers';
import { BigNumber } from 'ethers';
import { NonceManager } from '@ethersproject/experimental';
import { ProxyAddresses } from './proxyUtils';
import { Address } from '../../optics-tests/lib/types';
type Address = string;
export type DeployEnvironment = 'dev' | 'staging' | 'prod';
export type CoreContractAddresses = {

@ -1,4 +1,4 @@
import * as contracts from '../../../typechain/optics-core';
import * as contracts from '@optics-xyz/ts-interface/dist/optics-core';
import { BeaconProxy, ProxyAddresses } from '../proxyUtils';
import { Contracts } from '../contracts';
import { CoreContractAddresses } from '../chain';

@ -1,7 +1,6 @@
import {
Chain,
ChainJson,
CoreContractAddresses,
CoreDeployAddresses,
DeployEnvironment,
RustConfig,
@ -9,8 +8,9 @@ import {
} from '../chain';
import { CoreContracts } from './CoreContracts';
import { Deploy } from '../deploy';
import { Address } from '../../../optics-tests/lib/types';
import { BigNumber, BigNumberish } from '@ethersproject/bignumber';
import { BigNumberish } from '@ethersproject/bignumber';
type Address = string;
type Governor = {
domain: number;

@ -14,15 +14,21 @@ export function assertBeaconProxy(beaconProxy: BeaconProxy<Contract>) {
expect(beaconProxy.implementation).to.not.be.undefined;
}
export function checkVerificationInput(deploy: Deploy | BridgeDeploy | TestBridgeDeploy, name: string, addr: string) {
const inputAddr = deploy.verificationInput.filter(contract => contract.name == name)[0].address;
export function checkVerificationInput(
deploy: Deploy | BridgeDeploy | TestBridgeDeploy,
name: string,
addr: string,
) {
const inputAddr = deploy.verificationInput.filter(
(contract) => contract.name == name,
)[0].address;
expect(inputAddr).to.equal(addr);
}
export async function checkCoreDeploy(
deploy: Deploy,
remoteDomains: number[],
governorDomain: number
governorDomain: number,
) {
// Home upgrade setup contracts are defined
assertBeaconProxy(deploy.contracts.home!);
@ -38,14 +44,21 @@ export async function checkCoreDeploy(
// Replica upgrade setup contracts are defined
assertBeaconProxy(deploy.contracts.replicas[domain]!);
// governanceRouter for remote domain is registered
const registeredRouter = await deploy.contracts.governance?.proxy.routers(domain);
const registeredRouter = await deploy.contracts.governance?.proxy.routers(
domain,
);
expect(registeredRouter).to.not.equal(emptyAddr);
// replica is enrolled in xAppConnectionManager
const enrolledReplica = await deploy.contracts.xAppConnectionManager?.domainToReplica(domain);
const enrolledReplica =
await deploy.contracts.xAppConnectionManager?.domainToReplica(domain);
expect(enrolledReplica).to.not.equal(emptyAddr);
//watchers have permission in xAppConnectionManager
deploy.config.watchers.forEach(async watcher => {
const watcherPermissions = await deploy.contracts.xAppConnectionManager?.watcherPermission(watcher, domain);
deploy.config.watchers.forEach(async (watcher) => {
const watcherPermissions =
await deploy.contracts.xAppConnectionManager?.watcherPermission(
watcher,
domain,
);
expect(watcherPermissions).to.be.true;
});
}
@ -56,13 +69,13 @@ export async function checkCoreDeploy(
const replicaImpl = firstReplica.implementation.address;
const replicaBeacon = firstReplica.beacon.address;
// check every other implementation/beacon matches the first
remoteDomains.slice(1).forEach(remoteDomain => {
const replica = deploy.contracts.replicas[remoteDomain]!
remoteDomains.slice(1).forEach((remoteDomain) => {
const replica = deploy.contracts.replicas[remoteDomain]!;
const implementation = replica.implementation.address;
const beacon = replica.beacon.address;
expect(implementation).to.equal(replicaImpl);
expect(beacon).to.equal(replicaBeacon);
})
});
}
// contracts are defined
@ -72,23 +85,26 @@ export async function checkCoreDeploy(
// governor is set on governor chain, empty on others
const gov = await deploy.contracts.governance?.proxy.governor();
const localDomain = await deploy.contracts.home?.proxy.localDomain()
const localDomain = await deploy.contracts.home?.proxy.localDomain();
if (governorDomain == localDomain) {
expect(gov).to.not.equal(emptyAddr);
} else {
expect(gov).to.equal(emptyAddr);
}
// governor domain is correct
expect(await deploy.contracts.governance?.proxy.governorDomain()).to.equal(governorDomain);
expect(await deploy.contracts.governance?.proxy.governorDomain()).to.equal(
governorDomain,
);
// Home is set on xAppConnectionManager
const xAppManagerHome = await deploy.contracts.xAppConnectionManager?.home();
const homeAddress = deploy.contracts.home?.proxy.address
const homeAddress = deploy.contracts.home?.proxy.address;
expect(xAppManagerHome).to.equal(homeAddress);
// governor has ownership over following contracts
const updaterManagerOwner = await deploy.contracts.updaterManager?.owner();
const xAppManagerOwner = await deploy.contracts.xAppConnectionManager?.owner();
const xAppManagerOwner =
await deploy.contracts.xAppConnectionManager?.owner();
const beaconOwner = await deploy.contracts.upgradeBeaconController?.owner();
const homeOwner = await deploy.contracts.home?.proxy.owner();
const governorAddr = deploy.contracts.governance?.proxy.address;
@ -98,26 +114,73 @@ export async function checkCoreDeploy(
expect(homeOwner).to.equal(governorAddr);
// check verification addresses
checkVerificationInput(deploy, 'UpgradeBeaconController', deploy.contracts.upgradeBeaconController?.address!);
checkVerificationInput(deploy, 'XAppConnectionManager', deploy.contracts.xAppConnectionManager?.address!);
checkVerificationInput(deploy, 'UpdaterManager', deploy.contracts.updaterManager?.address!);
checkVerificationInput(deploy, 'Home Implementation', deploy.contracts.home?.implementation.address!);
checkVerificationInput(deploy, 'Home UpgradeBeacon', deploy.contracts.home?.beacon.address!);
checkVerificationInput(deploy, 'Home Proxy', deploy.contracts.home?.proxy.address!);
checkVerificationInput(deploy, 'Governance Implementation', deploy.contracts.governance?.implementation.address!);
checkVerificationInput(deploy, 'Governance UpgradeBeacon', deploy.contracts.governance?.beacon.address!);
checkVerificationInput(deploy, 'Governance Proxy', deploy.contracts.governance?.proxy.address!);
checkVerificationInput(
deploy,
'UpgradeBeaconController',
deploy.contracts.upgradeBeaconController?.address!,
);
checkVerificationInput(
deploy,
'XAppConnectionManager',
deploy.contracts.xAppConnectionManager?.address!,
);
checkVerificationInput(
deploy,
'UpdaterManager',
deploy.contracts.updaterManager?.address!,
);
checkVerificationInput(
deploy,
'Home Implementation',
deploy.contracts.home?.implementation.address!,
);
checkVerificationInput(
deploy,
'Home UpgradeBeacon',
deploy.contracts.home?.beacon.address!,
);
checkVerificationInput(
deploy,
'Home Proxy',
deploy.contracts.home?.proxy.address!,
);
checkVerificationInput(
deploy,
'Governance Implementation',
deploy.contracts.governance?.implementation.address!,
);
checkVerificationInput(
deploy,
'Governance UpgradeBeacon',
deploy.contracts.governance?.beacon.address!,
);
checkVerificationInput(
deploy,
'Governance Proxy',
deploy.contracts.governance?.proxy.address!,
);
if (remoteDomains.length > 0) {
checkVerificationInput(deploy, 'Replica Implementation', deploy.contracts.replicas[remoteDomains[0]]?.implementation.address!);
checkVerificationInput(deploy, 'Replica UpgradeBeacon', deploy.contracts.replicas[remoteDomains[0]]?.beacon.address!);
checkVerificationInput(
deploy,
'Replica Implementation',
deploy.contracts.replicas[remoteDomains[0]]?.implementation.address!,
);
checkVerificationInput(
deploy,
'Replica UpgradeBeacon',
deploy.contracts.replicas[remoteDomains[0]]?.beacon.address!,
);
const replicaProxies = deploy.verificationInput.filter(contract => contract.name == 'Replica Proxy');
remoteDomains.forEach(domain => {
const replicaProxy = replicaProxies.find(proxy => {
return proxy.address = deploy.contracts.replicas[domain]?.proxy.address
const replicaProxies = deploy.verificationInput.filter(
(contract) => contract.name == 'Replica Proxy',
);
remoteDomains.forEach((domain) => {
const replicaProxy = replicaProxies.find((proxy) => {
return (proxy.address =
deploy.contracts.replicas[domain]?.proxy.address);
});
expect(replicaProxy).to.not.be.undefined;
})
});
}
}

@ -4,9 +4,9 @@ import fs from 'fs';
import * as proxyUtils from '../proxyUtils';
import { CoreDeploy } from './CoreDeploy';
import { toBytes32 } from '../../../optics-tests/lib/utils';
import * as contracts from '../../../typechain/optics-core';
import * as contracts from '@optics-xyz/ts-interface/dist/optics-core';
import { checkCoreDeploy } from './checks';
import { toBytes32 } from '../utils';
function log(isTest: boolean, str: string) {
if (!isTest) {
@ -474,8 +474,14 @@ export async function deployTwoChains(gov: CoreDeploy, non: CoreDeploy) {
log(isTestDeploy, 'Beginning Two Chain deploy process');
log(isTestDeploy, `Deploy env is ${gov.config.environment}`);
log(isTestDeploy, `${gov.chain.name} is governing`);
log(isTestDeploy, `Updater for ${gov.chain.name} Home is ${gov.config.updater}`);
log(isTestDeploy, `Updater for ${non.chain.name} Home is ${non.config.updater}`);
log(
isTestDeploy,
`Updater for ${gov.chain.name} Home is ${gov.config.updater}`,
);
log(
isTestDeploy,
`Updater for ${non.chain.name} Home is ${non.config.updater}`,
);
log(isTestDeploy, 'awaiting provider ready');
await Promise.all([gov.ready(), non.ready()]);
@ -546,7 +552,8 @@ export async function deployNChains(deploys: CoreDeploy[]) {
log(isTestDeploy, `Deploy env is ${deploys[0].config.environment}`);
log(isTestDeploy, `${deploys[0].chain.name} is governing`);
deploys.forEach((deploy) => {
log(isTestDeploy,
log(
isTestDeploy,
`Updater for ${deploy.chain.name} Home is ${deploy.config.updater}`,
);
});
@ -555,15 +562,19 @@ export async function deployNChains(deploys: CoreDeploy[]) {
const nonGovChains = deploys.slice(1);
log(isTestDeploy, 'awaiting provider ready');
await Promise.all([deploys.map(async (deploy) => {
await deploy.ready();
})]);
await Promise.all([
deploys.map(async (deploy) => {
await deploy.ready();
}),
]);
log(isTestDeploy, 'done readying');
// deploy optics on each chain
await Promise.all(deploys.map(async (deploy) => {
await deployOptics(deploy);
}));
await Promise.all(
deploys.map(async (deploy) => {
await deployOptics(deploy);
}),
);
// enroll remotes on every chain
//
@ -571,7 +582,9 @@ export async function deployNChains(deploys: CoreDeploy[]) {
// which results in multiple replica implementations on the home chain.
//
for (let local of deploys) {
const remotes = deploys.filter(d => d.chain.domain !== local.chain.domain);
const remotes = deploys.filter(
(d) => d.chain.domain !== local.chain.domain,
);
for (let remote of remotes) {
log(
isTestDeploy,
@ -604,9 +617,11 @@ export async function deployNChains(deploys: CoreDeploy[]) {
const govDomain = deploys[0].chain.domain;
for (var i = 0; i < deploys.length; i++) {
const localDomain = deploys[i].chain.domain;
const remoteDomains = deploys.map(deploy => deploy.chain.domain).filter(domain => {
return domain != localDomain
});
const remoteDomains = deploys
.map((deploy) => deploy.chain.domain)
.filter((domain) => {
return domain != localDomain;
});
await checkCoreDeploy(deploys[i], remoteDomains, govDomain);
}

@ -1,18 +1,39 @@
import { Contract, ethers } from 'ethers';
import { ethers } from 'ethers';
import { Chain } from './chain';
import { Contracts } from './contracts';
type XAppConnectionName = "XAppConnectionManager";
type UpdaterManagerName = "UpdaterManager";
type UBCName = "UpgradeBeaconController";
type HomeName = "Home UpgradeBeacon" | "Home Proxy" | "Home Implementation";
type ReplicaName = "Replica UpgradeBeacon" | "Replica Proxy" | "Replica Implementation";
type GovernanceName = "Governance UpgradeBeacon" | "Governance Proxy" | "Governance Implementation";
type EthHelperName = "ETH Helper";
type BridgeTokenName = "BridgeToken UpgradeBeacon" | "BridgeToken Proxy" | "BridgeToken Implementation";
type BridgeRouterName = "BridgeRouter UpgradeBeacon" | "BridgeRouter Proxy" | "BridgeRouter Implementation";
type XAppConnectionName = 'XAppConnectionManager';
type UpdaterManagerName = 'UpdaterManager';
type UBCName = 'UpgradeBeaconController';
type HomeName = 'Home UpgradeBeacon' | 'Home Proxy' | 'Home Implementation';
type ReplicaName =
| 'Replica UpgradeBeacon'
| 'Replica Proxy'
| 'Replica Implementation';
type GovernanceName =
| 'Governance UpgradeBeacon'
| 'Governance Proxy'
| 'Governance Implementation';
type EthHelperName = 'ETH Helper';
type BridgeTokenName =
| 'BridgeToken UpgradeBeacon'
| 'BridgeToken Proxy'
| 'BridgeToken Implementation';
type BridgeRouterName =
| 'BridgeRouter UpgradeBeacon'
| 'BridgeRouter Proxy'
| 'BridgeRouter Implementation';
export type ContractVerificationName = XAppConnectionName | UpdaterManagerName | UBCName | HomeName | ReplicaName | GovernanceName | EthHelperName | BridgeTokenName | BridgeRouterName;
export type ContractVerificationName =
| XAppConnectionName
| UpdaterManagerName
| UBCName
| HomeName
| ReplicaName
| GovernanceName
| EthHelperName
| BridgeTokenName
| BridgeRouterName;
export type ContractVerificationInput = {
name: ContractVerificationName;

@ -1,13 +1,18 @@
import { BytesLike, ethers } from 'ethers';
import * as contracts from '../../typechain/optics-core';
import * as contracts from '@optics-xyz/ts-interface/dist/optics-core';
import { CoreDeploy } from './core/CoreDeploy';
import { BridgeDeploy } from './bridge/BridgeDeploy';
import TestBridgeDeploy from './bridge/TestBridgeDeploy';
type Deploy = CoreDeploy | BridgeDeploy | TestBridgeDeploy;
type ProxyNames = "Home" | "Replica" | "Governance" | "BridgeToken" | "BridgeRouter";
type ProxyNames =
| 'Home'
| 'Replica'
| 'Governance'
| 'BridgeToken'
| 'BridgeRouter';
export class BeaconProxy<T extends ethers.Contract> {
implementation: T;
@ -51,10 +56,7 @@ export async function deployProxy<T extends ethers.Contract>(
// we cast here because Factories don't have associated types
// this is unsafe if the specified typevar doesn't match the factory output
// :(
const implementation = (await factory.deploy(
...deployArgs,
deploy.overrides,
));
const implementation = await factory.deploy(...deployArgs, deploy.overrides);
const beacon = await _deployBeacon(deploy, implementation);
const proxy = await _deployProxy(deploy, beacon, initData);

@ -0,0 +1,9 @@
/*
* Converts address to Bytes32
*
* @param address - the address
* @return The address as bytes32
*/
export function toBytes32(address: string): string {
return '0x' + '00'.repeat(12) + address.slice(2);
}

@ -1,72 +1,21 @@
{
"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'). */
/* 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": "./"
},
"exclude": ["./node_modules/", "./dist/", "./tmp.ts"],
"extends": "../tsconfig.package.json",
"include": [
"./config/mainnets/*.ts",
"./config/testnets/*.ts",
"./scripts/alfajoresArbitrum/*.ts",
"./scripts/alfajoresKovan/*.ts",
"./scripts/fourTestnets/*.ts",
"./scripts/mainnet/*.ts",
"./scripts/threeTestnets/*.ts",
"./src/*.ts",
"./src/core/*.ts",
"./src/bridge/*.ts",
"./src/verification/*.ts"
]
}

@ -1,16 +1,16 @@
{
"name": "@optics-xyz/multi-provider",
"version": "0.0.0",
"version": "0.0.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@optics-xyz/multi-provider",
"version": "0.0.0",
"version": "0.0.4",
"license": "MIT OR Apache-2.0",
"devDependencies": {
"@ethersproject/hardware-wallets": "^5.4.0",
"@optics-xyz/ts-interface": "^1.0.7",
"@optics-xyz/ts-interface": "^1.0.9",
"@types/node": "^16.9.1",
"dotenv": "^10.0.0",
"ethers": "^5.4.6",
@ -922,9 +922,9 @@
"dev": true
},
"node_modules/@optics-xyz/ts-interface": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/@optics-xyz/ts-interface/-/ts-interface-1.0.7.tgz",
"integrity": "sha512-MSpbaHJyC6Q65Tu+IhohM4kgmVyoza656hnfeDmfdB39WtX4wIcOVVU0vXjl+4AS/kryTDERB7T9eT4GYbluEA==",
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@optics-xyz/ts-interface/-/ts-interface-1.0.9.tgz",
"integrity": "sha512-zkA5bUuVZf8n3uw51KF/RNo205y1JCYkCzr+NZsHKZBldjUnbA8qj6d1DBtxHk1B3Dgrk41M3pGTtqhpGWue7g==",
"dev": true,
"dependencies": {
"@ethersproject/experimental": "^5.3.0"
@ -2527,9 +2527,9 @@
"dev": true
},
"@optics-xyz/ts-interface": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/@optics-xyz/ts-interface/-/ts-interface-1.0.7.tgz",
"integrity": "sha512-MSpbaHJyC6Q65Tu+IhohM4kgmVyoza656hnfeDmfdB39WtX4wIcOVVU0vXjl+4AS/kryTDERB7T9eT4GYbluEA==",
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@optics-xyz/ts-interface/-/ts-interface-1.0.9.tgz",
"integrity": "sha512-zkA5bUuVZf8n3uw51KF/RNo205y1JCYkCzr+NZsHKZBldjUnbA8qj6d1DBtxHk1B3Dgrk41M3pGTtqhpGWue7g==",
"dev": true,
"requires": {
"@ethersproject/experimental": "^5.3.0"

@ -1,17 +1,19 @@
{
"name": "@optics-xyz/multi-provider",
"version": "0.0.0",
"version": "0.0.4",
"description": "multi-provider for Optics",
"main": "src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"check": "tsc --noEmit"
},
"prepublish": "tsc",
"author": "Celo Labs Inc.",
"license": "MIT OR Apache-2.0",
"dependencies": {},
"devDependencies": {
"@ethersproject/hardware-wallets": "^5.4.0",
"@optics-xyz/ts-interface": "^1.0.7",
"@optics-xyz/ts-interface": "^1.0.9",
"@types/node": "^16.9.1",
"dotenv": "^10.0.0",
"ethers": "^5.4.6",

@ -1,5 +1,3 @@
import tokens from './tokens';
export { BridgeContracts } from './contracts/BridgeContracts';
export { CoreContracts } from './contracts/CoreContracts';
export {

@ -1,72 +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'). */
/* 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": "./src/"
},
"exclude": ["./node_modules/", "./dist/"],
"extends": "../tsconfig.package.json",
"include": [
"./src/*.ts",
"./src/optics/*.ts",
"./src/optics/contracts/*.ts",
"./src/optics/domains/*.ts",
"./src/optics/messages/*.ts",
"./src/optics/tokens/*.ts"
]
}

File diff suppressed because one or more lines are too long

@ -1,2 +1,3 @@
node_modules
cache
dist/

@ -1,9 +1,9 @@
import '@nomiclabs/hardhat-waffle';
import './lib/index';
import '@nomiclabs/hardhat-waffle';
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: "0.7.6",
solidity: '0.7.6',
};

@ -1,3 +1,4 @@
import { TokenIdentifier } from '@optics-xyz/multi-provider/dist/optics';
import { assert } from 'chai';
import { ethers } from 'ethers';
@ -19,28 +20,38 @@ const MESSAGE_LEN = {
tokenId: 36,
transfer: 65,
details: 66,
requestDetails: 1
}
requestDetails: 1,
};
// Formats Transfer Message
export function formatTransfer(to: ethers.BytesLike, amnt: number | ethers.BytesLike): ethers.BytesLike {
export function formatTransfer(
to: ethers.BytesLike,
amnt: number | ethers.BytesLike,
): ethers.BytesLike {
return ethers.utils.solidityPack(
['bytes1', 'bytes32', 'uint256'],
[BridgeMessageTypes.TRANSFER, to, amnt]
[BridgeMessageTypes.TRANSFER, to, amnt],
);
}
// Formats Details Message
export function formatDetails(name: string, symbol: string, decimals: number): ethers.BytesLike {
export function formatDetails(
name: string,
symbol: string,
decimals: number,
): ethers.BytesLike {
return ethers.utils.solidityPack(
['bytes1', 'bytes32', 'bytes32', 'uint8'],
[BridgeMessageTypes.DETAILS, name, symbol, decimals]
[BridgeMessageTypes.DETAILS, name, symbol, decimals],
);
}
// Formats Request Details message
export function formatRequestDetails(): ethers.BytesLike {
return ethers.utils.solidityPack(['bytes1'], [BridgeMessageTypes.REQUEST_DETAILS]);
return ethers.utils.solidityPack(
['bytes1'],
[BridgeMessageTypes.REQUEST_DETAILS],
);
}
// Formats the Token ID
@ -48,32 +59,41 @@ export function formatTokenId(domain: number, id: string): ethers.BytesLike {
return ethers.utils.solidityPack(['uint32', 'bytes32'], [domain, id]);
}
export function formatMessage(tokenId: ethers.BytesLike, action: ethers.BytesLike): ethers.BytesLike {
export function formatMessage(
tokenId: ethers.BytesLike,
action: ethers.BytesLike,
): ethers.BytesLike {
return ethers.utils.solidityPack(['bytes', 'bytes'], [tokenId, action]);
}
export function serializeTransferAction(transferAction: types.TransferAction): ethers.BytesLike {
export function serializeTransferAction(
transferAction: types.TransferAction,
): ethers.BytesLike {
const { type, recipient, amount } = transferAction;
assert(type === BridgeMessageTypes.TRANSFER);
return formatTransfer(recipient, amount);
}
export function serializeDetailsAction(detailsAction: types.DetailsAction): ethers.BytesLike {
export function serializeDetailsAction(
detailsAction: types.DetailsAction,
): ethers.BytesLike {
const { type, name, symbol, decimals } = detailsAction;
assert(type === BridgeMessageTypes.DETAILS);
return formatDetails(name, symbol, decimals);
}
export function serializeRequestDetailsAction(requestDetailsAction: types.RequestDetailsAction): ethers.BytesLike {
export function serializeRequestDetailsAction(
requestDetailsAction: types.RequestDetailsAction,
): ethers.BytesLike {
assert(requestDetailsAction.type === BridgeMessageTypes.REQUEST_DETAILS);
return formatRequestDetails();
}
export function serializeAction(action: types.Action): ethers.BytesLike {
let actionBytes: ethers.BytesLike = [];
switch(action.type) {
switch (action.type) {
case BridgeMessageTypes.TRANSFER: {
actionBytes = serializeTransferAction(action);
break;
@ -87,21 +107,24 @@ export function serializeAction(action: types.Action): ethers.BytesLike {
break;
}
default: {
console.error("Invalid action");
console.error('Invalid action');
break;
}
}
return actionBytes;
}
export function serializeTokenId(tokenId: types.TokenId): ethers.BytesLike {
return formatTokenId(tokenId.domain, tokenId.id);
export function serializeTokenId(tokenId: TokenIdentifier): ethers.BytesLike {
if (typeof tokenId.domain !== 'number' || typeof tokenId.id !== 'string') {
throw new Error('!types');
}
return formatTokenId(tokenId.domain as number, tokenId.id as string);
}
export function serializeMessage(message: types.Message): ethers.BytesLike {
const tokenId = serializeTokenId(message.tokenId);
const action = serializeAction(message.action);
return formatMessage(tokenId, action)
return formatMessage(tokenId, action);
}
export const bridge: types.HardhatBridgeHelpers = {
@ -113,5 +136,5 @@ export const bridge: types.HardhatBridgeHelpers = {
serializeRequestDetailsAction,
serializeAction,
serializeTokenId,
serializeMessage
}
serializeMessage,
};

@ -198,4 +198,4 @@ export const optics: types.HardhatOpticsHelpers = {
destinationAndNonce,
domainHash,
signedFailureNotification,
};
};

@ -1,5 +1,5 @@
import { BigNumber, BigNumberish, ethers } from 'ethers';
import { BridgeToken } from '../../typechain/optics-xapps';
import { BridgeToken } from '@optics-xyz/ts-interface/dist/optics-xapps';
const PERMIT_TYPEHASH = ethers.utils.keccak256(
ethers.utils.toUtf8Bytes(

@ -1,4 +1,5 @@
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { TokenIdentifier } from '@optics-xyz/multi-provider/dist/optics';
import { BytesLike, ethers } from 'ethers';
import { BridgeMessageTypes } from './bridge';
@ -109,32 +110,28 @@ export type MessageLen = {
transfer: number;
details: number;
requestDetails: number;
}
};
export type Action = DetailsAction | TransferAction | RequestDetailsAction;
export type TokenId = {
domain: number;
id: string;
}
export type Message = {
tokenId: TokenId;
tokenId: TokenIdentifier;
action: Action;
}
};
export type TransferAction = {
type: BridgeMessageTypes.TRANSFER;
recipient: ethers.BytesLike;
amount: number | ethers.BytesLike;
}
};
export type DetailsAction = {
type: BridgeMessageTypes.DETAILS;
name: string;
symbol: string;
decimals: number;
}
};
export type RequestDetailsAction = {
type: BridgeMessageTypes.REQUEST_DETAILS;
}
};

File diff suppressed because it is too large Load Diff

@ -16,17 +16,21 @@
"typescript": "^4.3.2"
},
"dependencies": {
"@optics-xyz/deploy": "^0.0.3",
"@optics-xyz/multi-provider": "^0.0.4",
"@optics-xyz/ts-interface": "^1.0.9",
"@types/node": "^15.14.7",
"dotenv": "^10.0.0",
"ethers": "^5.4.1"
},
"name": "optics-ts",
"name": "@optics-xyz/optics-test",
"version": "1.0.0",
"description": "Optics typescript tools",
"description": "Optics typescript tests and tools",
"main": "index.ts",
"scripts": {
"check": "tsc --noEmit",
"prettier": "prettier --write ./test ./lib",
"test": "cd ../../ && ./scripts/test-solidity.sh",
"test": "hardhat test",
"testNoCompile": "hardhat test"
},
"author": "Celo Labs Inc.",

@ -7,7 +7,7 @@ import { permitDigest } from '../../lib/permit';
import {
BridgeToken__factory,
BridgeToken,
} from '../../../typechain/optics-xapps';
} from '@optics-xyz/ts-interface/dist/optics-xapps';
const VALUE = 100;

@ -1,11 +1,13 @@
import { ethers, bridge } from 'hardhat';
const { BridgeMessageTypes } = bridge;
import { Signer } from 'ethers';
import { expect } from 'chai';
import * as types from '../../lib/types';
import { toBytes32 } from '../../lib/utils';
import TestBridgeDeploy from '../../../optics-deploy/src/bridge/TestBridgeDeploy';
import TestBridgeDeploy from '@optics-xyz/deploy/dist/src/bridge/TestBridgeDeploy';
import { TokenIdentifier } from '@optics-xyz/multi-provider/dist/optics';
const { BridgeMessageTypes } = bridge;
describe('EthHelper', async () => {
let deploy: TestBridgeDeploy;
@ -29,20 +31,20 @@ describe('EthHelper', async () => {
deployerId = toBytes32(deployerAddress).toLowerCase();
recipientAddress = await recipient.getAddress();
recipientId = toBytes32(recipientAddress).toLowerCase();
deploy = await TestBridgeDeploy.deploy(deployer);
deploy = await TestBridgeDeploy.deploy(ethers, deployer);
const tokenId: types.TokenId = {
const tokenId: TokenIdentifier = {
domain: deploy.localDomain,
id: toBytes32(deploy.mockWeth.address)
}
id: toBytes32(deploy.mockWeth.address),
};
const transferToSelfMessageObj: types.Message = {
tokenId,
action: {
type: BridgeMessageTypes.TRANSFER,
recipient: deployerId,
amount: value
}
}
amount: value,
},
};
transferToSelfMessage = bridge.serializeMessage(transferToSelfMessageObj);
const transferMessageObj: types.Message = {
@ -50,9 +52,9 @@ describe('EthHelper', async () => {
action: {
type: BridgeMessageTypes.TRANSFER,
recipient: recipientId,
amount: value
}
}
amount: value,
},
};
transferMessage = bridge.serializeMessage(transferMessageObj);
});

@ -1,24 +1,18 @@
import { expect } from 'chai';
import { BigNumber, BytesLike } from 'ethers';
import { ethers, bridge } from 'hardhat';
const { BridgeMessageTypes } = bridge;
import { BigNumber, BytesLike } from 'ethers';
import * as types from '../../lib/types';
import { toBytes32 } from '../../lib/utils';
import TestBridgeDeploy from '../../../optics-deploy/src/bridge/TestBridgeDeploy';
import TestBridgeDeploy from '@optics-xyz/deploy/dist/src/bridge/TestBridgeDeploy';
import {
BridgeToken,
BridgeToken__factory,
IERC20,
} from '../../../typechain/optics-xapps';
} from '@optics-xyz/ts-interface/dist/optics-xapps';
import { stringToBytes32 } from '../utils';
const stringToBytes32 = (s: string): string => {
const str = Buffer.from(s.slice(0, 32), 'utf-8');
const result = Buffer.alloc(32);
str.copy(result);
return '0x' + result.toString('hex');
};
const { BridgeMessageTypes } = bridge;
describe('BridgeRouter', async () => {
let deployer: types.Signer;
@ -40,7 +34,7 @@ describe('BridgeRouter', async () => {
describe('invalid messages', async () => {
before(async () => {
deploy = await TestBridgeDeploy.deploy(deployer);
deploy = await TestBridgeDeploy.deploy(ethers, deployer);
});
it('rejects invalid messages', async () => {
@ -56,7 +50,7 @@ describe('BridgeRouter', async () => {
describe('transfer message', async () => {
before(async () => {
deploy = await TestBridgeDeploy.deploy(deployer);
deploy = await TestBridgeDeploy.deploy(ethers, deployer);
});
describe('remotely-originating asset roundtrup', async () => {
@ -64,7 +58,7 @@ describe('BridgeRouter', async () => {
let repr: IERC20;
before(async () => {
deploy = await TestBridgeDeploy.deploy(deployer);
deploy = await TestBridgeDeploy.deploy(ethers, deployer);
// generate transfer action
const transferMessageObj: types.Message = {
@ -200,7 +194,7 @@ describe('BridgeRouter', async () => {
let localToken: BridgeToken;
before(async () => {
deploy = await TestBridgeDeploy.deploy(deployer);
deploy = await TestBridgeDeploy.deploy(ethers, deployer);
localToken = await new BridgeToken__factory(deployer).deploy();
await localToken.initialize();
@ -306,7 +300,7 @@ describe('BridgeRouter', async () => {
describe('prefill', async () => {
before(async () => {
deploy = await TestBridgeDeploy.deploy(deployer);
deploy = await TestBridgeDeploy.deploy(ethers, deployer);
});
it('errors for non-existing assets', async () => {
@ -334,7 +328,7 @@ describe('BridgeRouter', async () => {
let transferMessage: string;
before(async () => {
deploy = await TestBridgeDeploy.deploy(deployer);
deploy = await TestBridgeDeploy.deploy(ethers, deployer);
// generate actions
recipient = `0x${'00'.repeat(19)}ff`;
@ -416,7 +410,7 @@ describe('BridgeRouter', async () => {
let transferMessage: string;
before(async () => {
deploy = await TestBridgeDeploy.deploy(deployer);
deploy = await TestBridgeDeploy.deploy(ethers, deployer);
localToken = await new BridgeToken__factory(deployer).deploy();
await localToken.initialize();
await localToken.mint(deployerAddress, TOKEN_VALUE);
@ -489,7 +483,7 @@ describe('BridgeRouter', async () => {
const TEST_DECIMALS = 8;
before(async () => {
deploy = await TestBridgeDeploy.deploy(deployer);
deploy = await TestBridgeDeploy.deploy(ethers, deployer);
localToken = await new BridgeToken__factory(deployer).deploy();
await localToken.initialize();
await localToken.setDetails(TEST_NAME, TEST_SYMBOL, TEST_DECIMALS);
@ -651,7 +645,7 @@ describe('BridgeRouter', async () => {
const VALUE = `0xffffffffffffffff`;
before(async () => {
deploy = await TestBridgeDeploy.deploy(deployer);
deploy = await TestBridgeDeploy.deploy(ethers, deployer);
// generate transfer action
const transferMessageObj: types.Message = {

@ -8,8 +8,9 @@ import { formatTokenId } from '../../lib/bridge';
import * as types from '../../lib/types';
import {
TestBridgeMessage__factory,
TestBridgeMessage
} from '../../../typechain/optics-xapps';
TestBridgeMessage,
} from '@optics-xyz/ts-interface/dist/optics-xapps';
import { TokenIdentifier } from '@optics-xyz/multi-provider/dist/optics';
const stringToBytes32 = (s: string): string => {
const str = Buffer.from(s.slice(0, 32), 'utf-8');
@ -27,23 +28,26 @@ describe('BridgeMessage', async () => {
const TOKEN_VALUE = 0xffff;
// tokenId
const testTokenId: types.TokenId = {
const testTokenId: TokenIdentifier = {
domain: 1,
id: '0x' + '11'.repeat(32)
}
const tokenIdBytes = formatTokenId(testTokenId.domain, testTokenId.id);
id: '0x' + '11'.repeat(32),
};
const tokenIdBytes = formatTokenId(
testTokenId.domain as number,
testTokenId.id as string,
);
// transfer action/message
const transferAction: types.TransferAction = {
type: BridgeMessageTypes.TRANSFER,
recipient: deployerId,
amount: TOKEN_VALUE
}
amount: TOKEN_VALUE,
};
const transferBytes = bridge.serializeTransferAction(transferAction);
const transferMessage: types.Message = {
tokenId: testTokenId,
action: transferAction
}
action: transferAction,
};
const transferMessageBytes = bridge.serializeMessage(transferMessage);
// details action/message
@ -51,27 +55,30 @@ describe('BridgeMessage', async () => {
type: BridgeMessageTypes.DETAILS,
name: stringToBytes32('TEST TOKEN'),
symbol: stringToBytes32('TEST'),
decimals: 8
}
decimals: 8,
};
const detailsBytes = bridge.serializeDetailsAction(detailsAction);
const detailsMessage: types.Message = {
tokenId: testTokenId,
action: detailsAction
}
action: detailsAction,
};
const detailsMessageBytes = bridge.serializeMessage(detailsMessage);
// requestDetails action/message
const requestDetailsAction: types.RequestDetailsAction = {
type: BridgeMessageTypes.REQUEST_DETAILS
type: BridgeMessageTypes.REQUEST_DETAILS,
};
const requestDetailsBytes = bridge.serializeRequestDetailsAction(requestDetailsAction);
const requestDetailsBytes =
bridge.serializeRequestDetailsAction(requestDetailsAction);
const requestDetailsMessage: types.Message = {
tokenId: testTokenId,
action: {
type: BridgeMessageTypes.REQUEST_DETAILS
}
}
const requestDetailsMessageBytes = bridge.serializeMessage(requestDetailsMessage);
type: BridgeMessageTypes.REQUEST_DETAILS,
},
};
const requestDetailsMessageBytes = bridge.serializeMessage(
requestDetailsMessage,
);
before(async () => {
const [signer] = await ethers.getSigners();
@ -82,54 +89,91 @@ describe('BridgeMessage', async () => {
it('validates actions', async () => {
const invalidAction = '0x00';
const invalidActionLen = '0x0300'
// transfer message is valid
let isAction = await bridgeMessage.testIsValidAction(transferBytes, BridgeMessageTypes.TRANSFER);
let isAction = await bridgeMessage.testIsValidAction(
transferBytes,
BridgeMessageTypes.TRANSFER,
);
expect(isAction).to.be.true;
// details message is valid
isAction = await bridgeMessage.testIsValidAction(detailsBytes, BridgeMessageTypes.DETAILS);
isAction = await bridgeMessage.testIsValidAction(
detailsBytes,
BridgeMessageTypes.DETAILS,
);
expect(isAction).to.be.true;
// request details message is valid
isAction = await bridgeMessage.testIsValidAction(requestDetailsBytes, BridgeMessageTypes.REQUEST_DETAILS);
isAction = await bridgeMessage.testIsValidAction(
requestDetailsBytes,
BridgeMessageTypes.REQUEST_DETAILS,
);
expect(isAction).to.be.true;
// not a valid message type
isAction = await bridgeMessage.testIsValidAction(transferBytes, BridgeMessageTypes.INVALID);
isAction = await bridgeMessage.testIsValidAction(
transferBytes,
BridgeMessageTypes.INVALID,
);
expect(isAction).to.be.false;
// not a valid action type
isAction = await bridgeMessage.testIsValidAction(invalidAction, BridgeMessageTypes.TRANSFER);
isAction = await bridgeMessage.testIsValidAction(
invalidAction,
BridgeMessageTypes.TRANSFER,
);
expect(isAction).to.be.false;
// TODO: Action length is not checked, should it be? We do check message length
// invalid length
// isAction = await bridgeMessage.testIsValidAction(invalidActionLen, BridgeMessageTypes.TRANSFER);
// expect(isAction).to.be.false;
});
it('validates message length', async () => {
const invalidMessageLen = '0x' + '03'.repeat(38);
// valid transfer message
let isValidLen = await bridgeMessage.testIsValidMessageLength(transferMessageBytes);
let isValidLen = await bridgeMessage.testIsValidMessageLength(
transferMessageBytes,
);
expect(isValidLen).to.be.true;
// valid details message
isValidLen = await bridgeMessage.testIsValidMessageLength(detailsMessageBytes);
isValidLen = await bridgeMessage.testIsValidMessageLength(
detailsMessageBytes,
);
expect(isValidLen).to.be.true;
// valid requestDetails message
isValidLen = await bridgeMessage.testIsValidMessageLength(requestDetailsMessageBytes);
isValidLen = await bridgeMessage.testIsValidMessageLength(
requestDetailsMessageBytes,
);
expect(isValidLen).to.be.true;
// invalid message length
isValidLen = await bridgeMessage.testIsValidMessageLength(invalidMessageLen);
isValidLen = await bridgeMessage.testIsValidMessageLength(
invalidMessageLen,
);
expect(isValidLen).to.be.false;
// TODO: check that message length matches type?
});
it('formats message', async () => {
// formats message
const newMessage = await bridgeMessage.testFormatMessage(tokenIdBytes, transferBytes, BridgeMessageTypes.TOKEN_ID, BridgeMessageTypes.TRANSFER);
const newMessage = await bridgeMessage.testFormatMessage(
tokenIdBytes,
transferBytes,
BridgeMessageTypes.TOKEN_ID,
BridgeMessageTypes.TRANSFER,
);
expect(newMessage).to.equal(transferMessageBytes);
// reverts with bad tokenId
await expect(bridgeMessage.testFormatMessage(tokenIdBytes, transferBytes, BridgeMessageTypes.INVALID, BridgeMessageTypes.TRANSFER)).to.be.reverted;
await expect(
bridgeMessage.testFormatMessage(
tokenIdBytes,
transferBytes,
BridgeMessageTypes.INVALID,
BridgeMessageTypes.TRANSFER,
),
).to.be.reverted;
// reverts with bad action
await expect(bridgeMessage.testFormatMessage(tokenIdBytes, transferBytes, BridgeMessageTypes.TOKEN_ID, BridgeMessageTypes.INVALID)).to.be.revertedWith('!action');
await expect(
bridgeMessage.testFormatMessage(
tokenIdBytes,
transferBytes,
BridgeMessageTypes.TOKEN_ID,
BridgeMessageTypes.INVALID,
),
).to.be.revertedWith('!action');
});
it('returns correct message type', async () => {
@ -160,7 +204,9 @@ describe('BridgeMessage', async () => {
isDetails = await bridgeMessage.testIsDetails(requestDetailsBytes);
expect(isDetails).to.be.false;
let isRequestDetails = await bridgeMessage.testIsRequestDetails(requestDetailsBytes);
let isRequestDetails = await bridgeMessage.testIsRequestDetails(
requestDetailsBytes,
);
expect(isRequestDetails).to.be.true;
isRequestDetails = await bridgeMessage.testIsRequestDetails(detailsBytes);
expect(isRequestDetails).to.be.false;
@ -184,13 +230,20 @@ describe('BridgeMessage', async () => {
it('formats transfer action', async () => {
const { recipient, amount } = transferAction;
const newTransfer = await bridgeMessage.testFormatTransfer(recipient, amount);
const newTransfer = await bridgeMessage.testFormatTransfer(
recipient,
amount,
);
expect(newTransfer).to.equal(transferBytes);
});
it('formats details action', async () => {
const { name, symbol, decimals } = detailsAction;
const newDetails = await bridgeMessage.testFormatDetails(name, symbol, decimals);
const newDetails = await bridgeMessage.testFormatDetails(
name,
symbol,
decimals,
);
expect(newDetails).to.equal(detailsBytes);
});
@ -200,24 +253,30 @@ describe('BridgeMessage', async () => {
});
it('formats token id', async () => {
const newTokenId = await bridgeMessage.testFormatTokenId(testTokenId.domain, testTokenId.id);
const newTokenId = await bridgeMessage.testFormatTokenId(
testTokenId.domain,
testTokenId.id,
);
expect(newTokenId).to.equal(tokenIdBytes);
});
it('returns elements of a token id', async () => {
const evmId = '0x' + testTokenId.id.slice(26);
const [domain, id, newEvmId] = await bridgeMessage.testSplitTokenId(tokenIdBytes);
const evmId = '0x' + (testTokenId.id as string).slice(26);
const [domain, id, newEvmId] = await bridgeMessage.testSplitTokenId(
tokenIdBytes,
);
expect(domain).to.equal(testTokenId.domain);
expect(id).to.equal(testTokenId.id);
expect(newEvmId).to.equal(evmId);
const stuff = await bridgeMessage.testSplitTokenId(transferMessageBytes);
await bridgeMessage.testSplitTokenId(transferMessageBytes);
});
it('returns elements of a transfer action', async () => {
const evmRecipient = deployerAddress;
const [type, recipient, newEvmRecipient, amount] = await bridgeMessage.testSplitTransfer(transferBytes);
const [type, recipient, newEvmRecipient, amount] =
await bridgeMessage.testSplitTransfer(transferBytes);
expect(type).to.equal(BridgeMessageTypes.TRANSFER);
expect(recipient).to.equal(transferAction.recipient);
expect(newEvmRecipient).to.equal(evmRecipient);
@ -225,7 +284,9 @@ describe('BridgeMessage', async () => {
});
it('returns elements of a details action', async () => {
const [type, name, symbol, decimals] = await bridgeMessage.testSplitDetails(detailsBytes);
const [type, name, symbol, decimals] = await bridgeMessage.testSplitDetails(
detailsBytes,
);
expect(type).to.equal(BridgeMessageTypes.DETAILS);
expect(name).to.equal(detailsAction.name);
expect(symbol).to.equal(detailsAction.symbol);
@ -233,7 +294,9 @@ describe('BridgeMessage', async () => {
});
it('returns elements of a message', async () => {
const [newTokenId, action] = await bridgeMessage.testSplitMessage(transferMessageBytes);
const [newTokenId, action] = await bridgeMessage.testSplitMessage(
transferMessageBytes,
);
expect(newTokenId).to.equal(tokenIdBytes);
expect(action).to.equal(transferBytes);
});
@ -241,10 +304,20 @@ describe('BridgeMessage', async () => {
it('fails if message type is not valid', async () => {
const revertMsg = 'Validity assertion failed';
await expect(bridgeMessage.testMustBeTransfer(detailsBytes)).to.be.revertedWith(revertMsg);
await expect(bridgeMessage.testMustBeDetails(transferBytes)).to.be.revertedWith(revertMsg);
await expect(bridgeMessage.testMustBeRequestDetails(transferBytes)).to.be.revertedWith(revertMsg);
await expect(bridgeMessage.testMustBeTokenId(transferBytes)).to.be.revertedWith(revertMsg);
await expect(bridgeMessage.testMustBeMessage(transferBytes)).to.be.revertedWith(revertMsg);
await expect(
bridgeMessage.testMustBeTransfer(detailsBytes),
).to.be.revertedWith(revertMsg);
await expect(
bridgeMessage.testMustBeDetails(transferBytes),
).to.be.revertedWith(revertMsg);
await expect(
bridgeMessage.testMustBeRequestDetails(transferBytes),
).to.be.revertedWith(revertMsg);
await expect(
bridgeMessage.testMustBeTokenId(transferBytes),
).to.be.revertedWith(revertMsg);
await expect(
bridgeMessage.testMustBeMessage(transferBytes),
).to.be.revertedWith(revertMsg);
});
});
});

@ -1,6 +1,6 @@
import { ethers } from 'hardhat';
import * as contracts from '../../../typechain/optics-xapps';
import * as contracts from '@optics-xyz/ts-interface/dist/optics-xapps';
describe('Encoding', async () => {
it('encodes', async () => {

@ -1,11 +1,15 @@
import { ethers } from 'hardhat';
import { expect } from 'chai';
import { TestCommon__factory, TestCommon } from '../../typechain/optics-core';
import { OpticsState, Updater } from '../lib/core';
import { Signer } from '../lib/types';
import signedUpdateTestCases from '../../../vectors/signedUpdate.json';
import {
TestCommon__factory,
TestCommon,
} from '@optics-xyz/ts-interface/dist/optics-core';
const signedUpdateTestCases = require('../../../vectors/signedUpdate.json');
const localDomain = 1000;
describe('Common', async () => {

@ -1,22 +1,17 @@
import { ethers, optics } from 'hardhat';
import { expect } from 'chai';
import { providers } from 'ethers';
import {
updateReplica,
formatCall,
formatOpticsMessage,
} from './utils';
import { updateReplica, formatCall, formatOpticsMessage } from './utils';
import { increaseTimestampBy, UpgradeTestHelpers } from '../utils';
import { getTestDeploy } from '../testChain';
import { Updater } from '../../lib/core';
import { Address, Signer } from '../../lib/types';
import { CoreDeploy as Deploy } from '../../../optics-deploy/src/core/CoreDeploy';
import { CoreDeploy as Deploy } from '@optics-xyz/deploy/dist/src/core/CoreDeploy';
import {
deployNChains,
deployUnenrolledReplica,
} from '../../../optics-deploy/src/core';
import * as contracts from '../../../typechain/optics-core';
} from '@optics-xyz/deploy/dist/src/core';
import * as contracts from '@optics-xyz/ts-interface/dist/optics-core';
const helpers = require('../../../../vectors/proof.json');
@ -141,10 +136,7 @@ describe('GovernanceRouter', async () => {
// Increase time enough for both updates to be confirmable
const optimisticSeconds = deploy.config.optimisticSeconds;
await increaseTimestampBy(
deploy.chain.provider,
optimisticSeconds * 2,
);
await increaseTimestampBy(deploy.chain.provider, optimisticSeconds * 2);
// after confirming, committedRoot should be equal to the last submitted update
expect(await governorReplicaOnNonGovernorChain.committedRoot()).to.equal(

@ -7,9 +7,9 @@ import { increaseTimestampBy } from '../utils';
import { getTestDeploy } from '../testChain';
import { Updater } from '../../lib/core';
import { Signer } from '../../lib/types';
import { CoreDeploy as Deploy } from '../../../optics-deploy/src/core/CoreDeploy';
import { deployNChains } from '../../../optics-deploy/src/core';
import * as contracts from '../../../typechain/optics-core';
import { CoreDeploy as Deploy } from '@optics-xyz/deploy/dist/src/core/CoreDeploy';
import { deployNChains } from '@optics-xyz/deploy/dist/src/core';
import * as contracts from '@optics-xyz/ts-interface/dist/optics-core';
async function expectNotInRecovery(
updaterManager: contracts.UpdaterManager,

@ -3,17 +3,16 @@ import { expect } from 'chai';
import * as utils from './utils';
import { getTestDeploy } from '../testChain';
import { increaseTimestampBy } from '../utils';
import { Updater, MessageStatus } from '../../lib/core';
import { Update, Signer, BytesArray } from '../../lib/types';
import { CoreDeploy as Deploy } from '../../../optics-deploy/src/core/CoreDeploy';
import { deployTwoChains } from '../../../optics-deploy/src/core';
import { CoreDeploy as Deploy } from '@optics-xyz/deploy/dist/src/core/CoreDeploy';
import { deployTwoChains } from '@optics-xyz/deploy/dist/src/core';
import {
TestRecipient__factory,
TestReplica,
} from '../../../typechain/optics-core';
} from '@optics-xyz/ts-interface/dist/optics-core';
import proveAndProcessTestCases from '../../../../vectors/proveAndProcess.json';
const proveAndProcessTestCases = require('../../../../vectors/proveAndProcess.json');
const domains = [1000, 2000];
const localDomain = domains[0];
@ -32,11 +31,7 @@ describe('SimpleCrossChainMessage', async () => {
// deploys[1] is the remote deploy
let deploys: Deploy[] = [];
let randomSigner: Signer,
firstRootSubmittedToReplica: string,
updater: Updater,
latestRoot: string,
latestUpdate: Update;
let randomSigner: Signer, updater: Updater, latestUpdate: Update;
before(async () => {
[randomSigner] = await ethers.getSigners();
@ -83,11 +78,10 @@ describe('SimpleCrossChainMessage', async () => {
);
latestUpdate = update;
latestRoot = update.newRoot;
});
it('Destination Replica Accepts the first update', async () => {
firstRootSubmittedToReplica = await utils.updateReplica(
await utils.updateReplica(
latestUpdate,
deploys[1].contracts.replicas[localDomain].proxy!,
);
@ -102,9 +96,7 @@ describe('SimpleCrossChainMessage', async () => {
messages,
updater,
);
latestUpdate = update;
latestRoot = update.newRoot;
});
it('Destination Replica Accepts the second update', async () => {
@ -167,6 +159,8 @@ describe('SimpleCrossChainMessage', async () => {
// expect call to have been processed
expect(await TestRecipient.processed()).to.be.true;
expect(await replica.messages(messageHash)).to.equal(MessageStatus.PROCESSED);
expect(await replica.messages(messageHash)).to.equal(
MessageStatus.PROCESSED,
);
});
});

@ -9,7 +9,7 @@ import {
TestReplica,
Home,
TestGovernanceRouter,
} from '../../../typechain/optics-core';
} from '@optics-xyz/ts-interface/dist/optics-core';
type MessageDetails = {
message: string;

@ -4,16 +4,18 @@ import { expect } from 'chai';
import { getTestDeploy } from './testChain';
import { Updater } from '../lib/core';
import { Signer } from '../lib/types';
import { CoreContractAddresses } from '../../optics-deploy/src/chain';
import { deployBridges } from '../../optics-deploy/src/bridge';
import { BridgeDeploy } from '../../optics-deploy/src/bridge/BridgeDeploy';
import { checkBridgeDeploy } from '../../optics-deploy/src/bridge/checks';
import { deployTwoChains, deployNChains } from '../../optics-deploy/src/core';
import { CoreDeploy } from '../../optics-deploy/src/core/CoreDeploy';
import { CoreContractAddresses } from '@optics-xyz/deploy/dist/src/chain';
import { deployBridges } from '@optics-xyz/deploy/dist/src/bridge';
import { BridgeDeploy } from '@optics-xyz/deploy/dist/src/bridge/BridgeDeploy';
import {
deployTwoChains,
deployNChains,
} from '@optics-xyz/deploy/dist/src/core';
import { CoreDeploy } from '@optics-xyz/deploy/dist/src/core/CoreDeploy';
import {
MockWeth,
MockWeth__factory,
} from '../../typechain/optics-xapps';
} from '@optics-xyz/ts-interface/dist/optics-xapps';
const domains = [1000, 2000, 3000, 4000];
@ -21,9 +23,7 @@ const domains = [1000, 2000, 3000, 4000];
* Deploy the full Optics suite on two chains
*/
describe('core deploy scripts', async () => {
let signer: Signer,
recoveryManager: Signer,
updater: Updater;
let signer: Signer, recoveryManager: Signer, updater: Updater;
before(async () => {
[signer, recoveryManager] = await ethers.getSigners();
@ -34,7 +34,11 @@ describe('core deploy scripts', async () => {
it('2-chain deploy', async () => {
let deploys: CoreDeploy[] = [];
for (var i = 0; i < 2; i++) {
deploys.push(await getTestDeploy(domains[i], updater.address, [recoveryManager.address]));
deploys.push(
await getTestDeploy(domains[i], updater.address, [
recoveryManager.address,
]),
);
}
// deploy optics contracts on 2 chains
@ -49,7 +53,11 @@ describe('core deploy scripts', async () => {
it(`${i}-chain deploy`, async () => {
let deploys: CoreDeploy[] = [];
for (let j = 0; j < i; j++) {
deploys.push(await getTestDeploy(domains[j], updater.address, [recoveryManager.address]));
deploys.push(
await getTestDeploy(domains[j], updater.address, [
recoveryManager.address,
]),
);
}
// deploy optics contracts on `i` chains
@ -60,18 +68,18 @@ describe('core deploy scripts', async () => {
it(`asserts there is at least one deploy config`, async () => {
const deploys: CoreDeploy[] = [];
const errMsg = 'Must pass at least one deploy config'
const errMsg = 'Must pass at least one deploy config';
try {
await deployNChains(deploys);
// `deployNChains` should error and skip to catch block. If it didn't, we need to make it fail
// here (same as `expect(true).to.be.false`, but more explicit)
expect('no error').to.equal(errMsg);
} catch(e: any) {
} catch (e: any) {
// expect correct error message
expect(e.message).to.equal(errMsg);
}
})
});
});
});
@ -92,7 +100,11 @@ describe('bridge deploy scripts', async () => {
// deploy core contracts on 2 chains
for (let i = 0; i < numChains; i++) {
deploys.push(await getTestDeploy(domains[i], updater.address, [recoveryManager.address]));
deploys.push(
await getTestDeploy(domains[i], updater.address, [
recoveryManager.address,
]),
);
}
await deployNChains(deploys);
@ -108,14 +120,14 @@ describe('bridge deploy scripts', async () => {
{},
'',
true,
coreAddresses[0]
coreAddresses[0],
);
const kovanDeploy = new BridgeDeploy(
deploys[1].chain,
{ weth: mockWeth.address },
'',
true,
coreAddresses[1]
coreAddresses[1],
);
// deploy bridges
@ -129,21 +141,21 @@ describe('bridge deploy scripts', async () => {
{},
'',
true,
coreAddresses[0]
coreAddresses[0],
);
const kovanDeploy = new BridgeDeploy(
deploys[1].chain,
{ weth: mockWeth.address },
'',
true,
coreAddresses[1]
coreAddresses[1],
);
const rinkebyDeploy = new BridgeDeploy(
deploys[2].chain,
{ weth: mockWeth.address },
'',
true,
coreAddresses[2]
coreAddresses[2],
);
// deploy 3 bridges

@ -3,17 +3,17 @@ import { expect } from 'chai';
import { getTestDeploy } from './testChain';
import { OpticsState, Updater } from '../lib/core';
import { Signer } from '../lib/types';
import { CoreDeploy as Deploy } from '../../optics-deploy/src/core/CoreDeploy';
import * as deploys from '../../optics-deploy/src/core';
import { CoreDeploy as Deploy } from '@optics-xyz/deploy/dist/src/core/CoreDeploy';
import * as deploys from '@optics-xyz/deploy/dist/src/core';
import {
TestHome,
UpdaterManager__factory,
UpdaterManager,
} from '../../typechain/optics-core';
} from '@optics-xyz/ts-interface/dist/optics-core';
import homeDomainHashTestCases from '../../../vectors/homeDomainHash.json';
import destinationNonceTestCases from '../../../vectors/destinationNonce.json';
const homeDomainHashTestCases = require('../../../vectors/homeDomainHash.json');
const destinationNonceTestCases = require('../../../vectors/destinationNonce.json');
const localDomain = 1000;
const destDomain = 2000;
@ -128,15 +128,12 @@ describe('Home', async () => {
const nonce = await home.nonces(localDomain);
// Format data that will be emitted from Dispatch event
const destinationAndNonce = optics.destinationAndNonce(
destDomain,
nonce,
);
const destinationAndNonce = optics.destinationAndNonce(destDomain, nonce);
const opticsMessage = optics.formatMessage(
localDomain,
signer.address,
nonce,
nonce,
destDomain,
recipient.address,
message,
@ -275,11 +272,11 @@ describe('Home', async () => {
it('Correctly calculates destinationAndNonce', async () => {
for (let testCase of destinationNonceTestCases) {
let { destination, nonce, expectedDestinationAndNonce } = testCase;
const solidityDestinationAndNonce =
await home.testDestinationAndNonce(destination, nonce);
expect(solidityDestinationAndNonce).to.equal(
expectedDestinationAndNonce,
const solidityDestinationAndNonce = await home.testDestinationAndNonce(
destination,
nonce,
);
expect(solidityDestinationAndNonce).to.equal(expectedDestinationAndNonce);
}
});
});

@ -2,8 +2,12 @@ import { ethers } from 'hardhat';
import { expect } from 'chai';
import { BytesArray } from '../lib/types';
import { TestMerkle, TestMerkle__factory } from '../../typechain/optics-core';
import merkleTestCases from '../../../vectors/merkle.json';
import {
TestMerkle,
TestMerkle__factory,
} from '@optics-xyz/ts-interface/dist/optics-core';
const merkleTestCases = require('../../../vectors/merkle.json');
describe('Merkle', async () => {
for (let testCase of merkleTestCases) {

@ -1,8 +1,11 @@
import { ethers, optics } from 'hardhat';
import { expect } from 'chai';
import { TestMessage, TestMessage__factory } from '../../typechain/optics-core';
import {
TestMessage,
TestMessage__factory,
} from '@optics-xyz/ts-interface/dist/optics-core';
import testCases from '../../../vectors/message.json';
const testCases = require('../../../vectors/message.json');
const remoteDomain = 1000;
const localDomain = 2000;

@ -1,5 +1,5 @@
import { expect } from 'chai';
import { OpticsContext } from '../../optics-provider';
import { OpticsContext } from '@optics-xyz/multi-provider';
describe('optics multi-provider', () => {
it('compiles', () => {

@ -1,6 +1,9 @@
import { ethers } from 'hardhat';
import { expect } from 'chai';
import { TestQueue, TestQueue__factory } from '../../typechain/optics-core';
import {
TestQueue,
TestQueue__factory,
} from '@optics-xyz/ts-interface/dist/optics-core';
// create a proper hex encoded bytes32 filled with number. e.g 0x01010101...
const bytes32 = (num: number) => `0x${Buffer.alloc(32, num).toString('hex')}`;
@ -20,7 +23,7 @@ describe('Queue', async () => {
const items = Array.from(new Array(10).keys()).map((i) => bytes32(i));
for (const [idx, item] of items.entries()) {
for (const [idx, item] of Array.from(items.entries())) {
await queue.enqueue(item);
const length = await queue.length();
expect(length).to.equal(idx + 1);
@ -34,7 +37,7 @@ describe('Queue', async () => {
expect(await queue.contains(bytes32(3))).to.be.true;
expect(await queue.contains(bytes32(0xff))).to.be.false;
for (const [idx, item] of items.entries()) {
for (const [idx, item] of Array.from(items.entries())) {
// peek and dequeue
const dequeued = await queue.peek();
await queue.dequeue();

@ -1,25 +1,24 @@
import { ethers, optics } from 'hardhat';
import { expect } from 'chai';
import { increaseTimestampBy } from './utils';
import { getTestDeploy } from './testChain';
import { Updater, OpticsState, MessageStatus } from '../lib/core';
import { Signer, BytesArray } from '../lib/types';
import * as contracts from '../../typechain/optics-core';
import { CoreDeploy as Deploy } from '../../optics-deploy/src/core/CoreDeploy';
import { CoreDeploy as Deploy } from '@optics-xyz/deploy/dist/src/core/CoreDeploy';
import {
deployUnenrolledReplica,
deployUpgradeBeaconController,
deployUpdaterManager,
} from '../../optics-deploy/src/core';
} from '@optics-xyz/deploy/dist/src/core';
import homeDomainHashTestCases from '../../../vectors/homeDomainHash.json';
import merkleTestCases from '../../../vectors/merkle.json';
import proveAndProcessTestCases from '../../../vectors/proveAndProcess.json';
import * as contracts from '@optics-xyz/ts-interface/dist/optics-core';
const homeDomainHashTestCases = require('../../../vectors/homeDomainHash.json');
const merkleTestCases = require('../../../vectors/merkle.json');
const proveAndProcessTestCases = require('../../../vectors/proveAndProcess.json');
const localDomain = 2000;
const remoteDomain = 1000;
const optimisticSeconds = 3;
describe('Replica', async () => {
const badRecipientFactories = [
@ -86,9 +85,7 @@ describe('Replica', async () => {
expect(await replica.state()).to.equal(OpticsState.FAILED);
const newRoot = ethers.utils.formatBytes32String('new root');
await expect(submitValidUpdate(newRoot)).to.be.revertedWith(
'failed state',
);
await expect(submitValidUpdate(newRoot)).to.be.revertedWith('failed state');
});
it('Calculated domain hash matches Rust-produced domain hash', async () => {
@ -263,7 +260,7 @@ describe('Replica', async () => {
const processTx = replica.process(opticsMessage);
await expect(processTx)
.to.emit(replica, 'Process')
.withArgs(optics.messageHash(opticsMessage), true, "0x");
.withArgs(optics.messageHash(opticsMessage), true, '0x');
});
it('Fails to process an unproved message', async () => {
@ -295,7 +292,7 @@ describe('Replica', async () => {
const opticsMessage = optics.formatMessage(
remoteDomain,
sender.address,
nonce,
nonce,
localDomain,
badRecipient.address,
'0x',
@ -315,7 +312,7 @@ describe('Replica', async () => {
const opticsMessage = optics.formatMessage(
remoteDomain,
sender.address,
nonce,
nonce,
// Wrong destination Domain
localDomain + 5,
recipient.address,
@ -334,7 +331,7 @@ describe('Replica', async () => {
const opticsMessage = optics.formatMessage(
remoteDomain,
opticsMessageSender.address,
nonce,
nonce,
localDomain,
'0x1234567890123456789012345678901234567890', // non-existent contract address
body,
@ -353,7 +350,7 @@ describe('Replica', async () => {
const opticsMessage = optics.formatMessage(
remoteDomain,
sender.address,
nonce,
nonce,
localDomain,
recipient.address,
body,
@ -378,7 +375,7 @@ describe('Replica', async () => {
const opticsMessage = optics.formatMessage(
remoteDomain,
sender.address,
nonce,
nonce,
localDomain,
testRecipient.address,
'0x',
@ -404,7 +401,7 @@ describe('Replica', async () => {
const opticsMessage = optics.formatMessage(
remoteDomain,
sender.address,
nonce,
nonce,
localDomain,
testRecipient.address,
'0x',
@ -445,7 +442,7 @@ describe('Replica', async () => {
const opticsMessage = optics.formatMessage(
remoteDomain,
sender.address,
nonce,
nonce,
localDomain,
recipient.address,
'0x',

@ -1,11 +1,12 @@
import { ethers } from 'hardhat';
import { Chain } from '../../optics-deploy/src/chain';
const { BigNumber } = ethers;
import {
CoreConfig,
CoreDeploy,
} from '../../optics-deploy/src/core/CoreDeploy';
} from '@optics-xyz/deploy/dist/src/core/CoreDeploy';
import { Chain } from '@optics-xyz/deploy/dist/src/chain';
const { BigNumber } = ethers;
export async function getTestChain(
domain: number,

@ -3,7 +3,7 @@ import { ethers } from 'hardhat';
import { getTestDeploy } from './testChain';
import { UpgradeTestHelpers, MysteryMathUpgrade } from './utils';
import { Signer } from '../lib/types';
import * as contracts from '../../typechain/optics-core';
import * as contracts from '@optics-xyz/ts-interface/dist/optics-core';
describe('Upgrade', async () => {
const utils = new UpgradeTestHelpers();

@ -2,12 +2,12 @@ import { expect } from 'chai';
import ethers from 'ethers';
import { Signer } from '../lib/types';
import { CoreDeploy as Deploy } from '../../optics-deploy/src/core/CoreDeploy';
import { CoreDeploy as Deploy } from '@optics-xyz/deploy/dist/src/core/CoreDeploy';
import {
deployUpdaterManager,
deployUpgradeBeaconController,
} from '../../optics-deploy/src/core';
import * as contracts from '../../typechain/optics-core';
} from '@optics-xyz/deploy/dist/src/core';
import * as contracts from '@optics-xyz/ts-interface/dist/optics-core';
export const increaseTimestampBy = async (
provider: ethers.providers.JsonRpcProvider,
@ -94,3 +94,11 @@ export class UpgradeTestHelpers {
expect(stateResult).to.equal(this.stateVar);
}
}
export const stringToBytes32 = (s: string): string => {
const str = Buffer.from(s.slice(0, 32), 'utf-8');
const result = Buffer.alloc(32);
str.copy(result);
return '0x' + result.toString('hex');
};

@ -4,12 +4,11 @@ import { expect } from 'chai';
import { getTestDeploy } from './testChain';
import { Updater } from '../lib/core';
import { Signer } from '../lib/types';
import { CoreDeploy as Deploy } from '../../optics-deploy/src/core/CoreDeploy';
import * as deploys from '../../optics-deploy/src/core';
import { BeaconProxy } from '../../optics-deploy/src/proxyUtils';
import * as contracts from '../../typechain/optics-core';
import { CoreDeploy as Deploy } from '@optics-xyz/deploy/dist/src/core/CoreDeploy';
import * as deploys from '@optics-xyz/deploy/dist/src/core';
import * as contracts from '@optics-xyz/ts-interface/dist/optics-core';
import signedFailureTestCases from '../../../vectors/signedFailure.json';
const signedFailureTestCases = require('../../../vectors/signedFailure.json');
const ONLY_OWNER_REVERT_MSG = 'Ownable: caller is not the owner';
const localDomain = 1000;
@ -19,9 +18,7 @@ describe('XAppConnectionManager', async () => {
let localDeploy: Deploy,
remoteDeploy: Deploy,
connectionManager: contracts.TestXAppConnectionManager,
updaterManager: contracts.UpdaterManager,
enrolledReplica: contracts.TestReplica,
home: BeaconProxy<contracts.Home>,
signer: Signer,
updater: Updater;
@ -48,10 +45,8 @@ describe('XAppConnectionManager', async () => {
// set respective variables
connectionManager = localDeploy.contracts
.xAppConnectionManager! as contracts.TestXAppConnectionManager;
updaterManager = localDeploy.contracts.updaterManager!;
enrolledReplica = localDeploy.contracts.replicas[remoteDomain]
.proxy as contracts.TestReplica;
home = localDeploy.contracts.home!;
});
it('Returns the local domain', async () => {

@ -1,73 +1,15 @@
{
"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": "./",
"resolveJsonModule": true
},
"exclude": ["./node_modules/", "./dist/"],
"extends": "../tsconfig.package.json",
"include": [
"./lib/*.ts",
"./test/*.ts",
"./test/bridge/*.ts",
"./test/cross-chain/*.ts"
]
}

@ -32,10 +32,6 @@ declare module "hardhat/types/runtime" {
name: "Replica",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.Replica__factory>;
getContractFactory(
name: "UpgradeBeacon",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.UpgradeBeacon__factory>;
getContractFactory(
name: "UpgradeBeaconProxy",
signerOrOptions?: ethers.Signer | FactoryOptions

@ -6,7 +6,6 @@ export type { Home } from "./Home";
export type { MerkleTreeManager } from "./MerkleTreeManager";
export type { QueueManager } from "./QueueManager";
export type { Replica } from "./Replica";
export type { UpgradeBeacon } from "./UpgradeBeacon";
export type { UpgradeBeaconProxy } from "./UpgradeBeaconProxy";
export type { Version0 } from "./Version0";
export type { XAppConnectionManager } from "./XAppConnectionManager";
@ -37,7 +36,6 @@ export { Home__factory } from "./factories/Home__factory";
export { MerkleTreeManager__factory } from "./factories/MerkleTreeManager__factory";
export { QueueManager__factory } from "./factories/QueueManager__factory";
export { Replica__factory } from "./factories/Replica__factory";
export { UpgradeBeacon__factory } from "./factories/UpgradeBeacon__factory";
export { UpgradeBeaconProxy__factory } from "./factories/UpgradeBeaconProxy__factory";
export { Version0__factory } from "./factories/Version0__factory";
export { XAppConnectionManager__factory } from "./factories/XAppConnectionManager__factory";

@ -1,12 +1,12 @@
{
"name": "@optics-xyz/ts-interface",
"version": "1.0.5",
"version": "1.0.9",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@optics-xyz/ts-interface",
"version": "1.0.5",
"version": "1.0.9",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@ethersproject/experimental": "^5.3.0"

@ -1,19 +1,20 @@
{
"scripts": {
"build": "tsc",
"check": "tsc --noEmit"
"build": "tsc && npm run copy-files",
"check": "tsc --noEmit",
"copy-files": "cp optics-core/*.d.ts dist/optics-core && cp optics-xapps/*.d.ts dist/optics-xapps"
},
"devDependencies": {
"ethers": "^5.4.4"
},
"name": "@optics-xyz/ts-interface",
"version": "1.0.7",
"version": "1.0.9",
"description": "Optics contract typechain gens",
"main": "index.js",
"types": "index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Celo Labs Inc.",
"license": "MIT OR Apache-2.0",
"prepublish": "tsc",
"prepublish": "npm run build",
"dependencies": {
"@ethersproject/experimental": "^5.3.0"
}

Loading…
Cancel
Save