Merge ICA package (#1170)

* Merge ICA package

* Remove reference in dockerfile

* Lint

* Rename to hardhat tests
pull/1175/head
Nam Chu Hoai 2 years ago committed by GitHub
parent 525b5f3acb
commit 16374dc2ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      Dockerfile
  2. 0
      solidity/contracts/OwnableMulticall.sol
  3. 4
      solidity/contracts/middleware/InterchainAccountRouter.sol
  4. 4
      solidity/contracts/middleware/InterchainQueryRouter.sol
  5. 8
      solidity/contracts/middleware/README.md
  6. 4
      solidity/contracts/test/TestQuery.sol
  7. 9
      typescript/ica/.gitignore
  8. 26
      typescript/ica/hardhat.config.ts
  9. 16
      typescript/ica/index.ts
  10. 66
      typescript/ica/package.json
  11. 10
      typescript/ica/tsconfig.json
  12. 1
      typescript/infra/package.json
  13. 4
      typescript/infra/scripts/interchain/deploy-queries.ts
  14. 4
      typescript/infra/scripts/interchain/deploy.ts
  15. 1
      typescript/sdk/hardhat.config.ts
  16. 2
      typescript/sdk/package.json
  17. 28
      typescript/sdk/src/deploy/middleware/deploy.ts
  18. 8
      typescript/sdk/src/index.ts
  19. 6
      typescript/sdk/src/middleware.ts
  20. 26
      typescript/sdk/src/middleware/accounts.hardhat-test.ts
  21. 27
      typescript/sdk/src/middleware/queries.hardhat-test.ts
  22. 8
      typescript/sdk/tsconfig.build.json
  23. 1
      typescript/sdk/tsconfig.json
  24. 119
      yarn.lock

@ -14,7 +14,6 @@ COPY .yarn/releases ./.yarn/releases
COPY typescript/utils/package.json ./typescript/utils/
COPY typescript/sdk/package.json ./typescript/sdk/
COPY typescript/helloworld/package.json ./typescript/helloworld/
COPY typescript/ica/package.json ./typescript/ica/
COPY typescript/infra/package.json ./typescript/infra/
COPY solidity/package.json ./solidity/

@ -1,10 +1,10 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.13;
import {OwnableMulticall, Call} from "./OwnableMulticall.sol";
import {OwnableMulticall, Call} from "../OwnableMulticall.sol";
// ============ External Imports ============
import {Router} from "@hyperlane-xyz/core/contracts/Router.sol";
import {Router} from "../Router.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

@ -1,10 +1,10 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.13;
import {OwnableMulticall, Call} from "./OwnableMulticall.sol";
import {OwnableMulticall, Call} from "../OwnableMulticall.sol";
// ============ External Imports ============
import {Router} from "@hyperlane-xyz/core/contracts/Router.sol";
import {Router} from "../Router.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

@ -1,9 +1,13 @@
# Interchain Accounts
# Middleware Contracts
This package provides smart contracts with "sovereignty" on remote Hyperlane chains via operating interchain accounts.
## Interchain Accounts
An interchain account is a smart contract that is deployed on a remote chain and is controlled exclusively by the deploying local account.
Interchain accounts provide developers with a [transparent multicall API](./contracts/OwnableMulticall.sol) to remote smart contracts.
This avoids the need to deploy application specific smart contracts on remote chains while simultaneously enabling cross-chain composability.
See [IBC Interchain Accounts](https://github.com/cosmos/ibc/blob/main/spec/app/ics-027-interchain-accounts/README.md) for the Cosmos ecosystem equivalent.
## Interchain Query System
TBD

@ -1,9 +1,9 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.13;
import {InterchainQueryRouter} from "../InterchainQueryRouter.sol";
import {InterchainQueryRouter} from "../middleware/InterchainQueryRouter.sol";
import {Call} from "../OwnableMulticall.sol";
import {TypeCasts} from "@hyperlane-xyz/core/contracts/libs/TypeCasts.sol";
import {TypeCasts} from "../libs/TypeCasts.sol";
contract TestQuery {
InterchainQueryRouter public router;

@ -1,9 +0,0 @@
artifacts/
cache/
coverage/
coverage.json
dist/
node_modules/
types/
*.swp
.yarn/install-state.gz

@ -1,26 +0,0 @@
import '@nomiclabs/hardhat-ethers';
import '@nomiclabs/hardhat-waffle';
import '@typechain/hardhat';
import 'hardhat-gas-reporter';
import 'solidity-coverage';
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: {
compilers: [
{
version: '0.8.16',
},
],
},
gasReporter: {
currency: 'USD',
},
typechain: {
outDir: './types',
target: 'ethers-v5',
alwaysGenerateOverloads: false, // should overloads with full signatures like deposit(uint256) be generated always, even if there are no overloads?
},
};

@ -1,16 +0,0 @@
export {
InterchainAccountConfig,
InterchainAccountDeployer,
} from './src/deploy';
export {
InterchainAccountContracts,
InterchainAccountFactories,
interchainAccountFactories,
} from './src/contracts';
export { InterchainQueryConfig, InterchainQueryDeployer } from './src/deploy';
export {
InterchainQueryContracts,
InterchainQueryFactories,
interchainQueryFactories,
} from './src/contracts';
export * as types from './types';

@ -1,66 +0,0 @@
{
"name": "@hyperlane-xyz/interchain-accounts",
"description": "A router middleware for interchain accounts",
"version": "0.5.1",
"dependencies": {
"@hyperlane-xyz/core": "0.5.1",
"@hyperlane-xyz/sdk": "0.5.1",
"@hyperlane-xyz/utils": "0.5.1",
"@openzeppelin/contracts-upgradeable": "^4.6.0",
"ethers": "^5.6.8"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^1.0.3",
"@nomicfoundation/hardhat-toolbox": "^1.0.2",
"@nomiclabs/hardhat-ethers": "^2.0.5",
"@nomiclabs/hardhat-waffle": "^2.0.2",
"@trivago/prettier-plugin-sort-imports": "^3.2.0",
"@typechain/ethers-v5": "10.0.0",
"@typechain/hardhat": "^6.0.0",
"@types/mocha": "^9.1.0",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"chai": "^4.3.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"ethereum-waffle": "^3.4.4",
"hardhat": "^2.8.4",
"hardhat-gas-reporter": "^1.0.7",
"prettier": "^2.4.1",
"prettier-plugin-solidity": "^1.0.0-beta.5",
"solhint": "^3.3.2",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.14",
"ts-node": "^10.8.0",
"typechain": "8.0.0",
"typescript": "^4.7.2"
},
"files": [
"/dist",
"/contracts"
],
"homepage": "https://www.hyperlane-xyz",
"keywords": [
"Hyperlane",
"Interchain Accounts",
"Solidity",
"Typescript"
],
"license": "Apache-2.0",
"main": "dist/index.js",
"packageManager": "yarn@3.2.0",
"repository": {
"type": "git",
"url": "https://github.com/hyperlane-xyz/hyperlane-monorepo"
},
"private": true,
"scripts": {
"build": "hardhat compile && tsc",
"clean": "hardhat clean && rm -rf dist cache src/types",
"coverage": "hardhat coverage",
"lint": "eslint . --ext .ts",
"prettier": "prettier --write ./contracts ./src",
"test": "hardhat test ./test/*.test.ts"
},
"types": "dist/src/index.d.ts"
}

@ -1,10 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/",
"rootDir": "./"
},
"exclude": ["./node_modules/", "./dist/", "./types/hardhat.d.ts"],
"include": ["./src/", "./test", "./scripts", "index.ts"],
"files": ["hardhat.config.ts"]
}

@ -13,7 +13,6 @@
"@gnosis.pm/safe-service-client": "^1.2.0",
"@hyperlane-xyz/celo-ethers-provider": "^0.1.1",
"@hyperlane-xyz/helloworld": "0.5.1",
"@hyperlane-xyz/interchain-accounts": "0.5.1",
"@hyperlane-xyz/sdk": "0.5.1",
"@hyperlane-xyz/utils": "0.5.1",
"@nomiclabs/hardhat-etherscan": "^3.0.3",

@ -1,10 +1,10 @@
import path from 'path';
import {
HyperlaneCore,
InterchainQueryDeployer,
interchainQueryFactories,
} from '@hyperlane-xyz/interchain-accounts';
import { HyperlaneCore } from '@hyperlane-xyz/sdk';
} from '@hyperlane-xyz/sdk';
import { deployWithArtifacts } from '../../src/deploy';
import { getConfiguration } from '../helloworld/utils';

@ -1,10 +1,10 @@
import path from 'path';
import {
HyperlaneCore,
InterchainAccountDeployer,
interchainAccountFactories,
} from '@hyperlane-xyz/interchain-accounts';
import { HyperlaneCore } from '@hyperlane-xyz/sdk';
} from '@hyperlane-xyz/sdk';
import { deployWithArtifacts } from '../../src/deploy';
import { getConfiguration } from '../helloworld/utils';

@ -1,5 +1,6 @@
import '@nomiclabs/hardhat-ethers';
import '@nomiclabs/hardhat-waffle';
import '@typechain/hardhat';
/**
* @type import('hardhat/config').HardhatUserConfig

@ -41,7 +41,7 @@
"main": "dist/index.js",
"repository": "https://github.com/hyperlane-xyz/hyperlane-monorepo",
"scripts": {
"build": "tsc",
"build": "tsc --project tsconfig.build.json",
"check": "tsc --noEmit",
"clean": "rm -rf ./dist ./cache",
"prepublishOnly": "yarn build",

@ -1,17 +1,9 @@
import {
ChainMap,
ChainName,
HyperlaneCore,
HyperlaneRouterDeployer,
MultiProvider,
RouterConfig,
} from '@hyperlane-xyz/sdk';
import {
InterchainAccountRouter__factory,
InterchainQueryRouter__factory,
} from '../types';
} from '@hyperlane-xyz/core';
import { HyperlaneCore } from '../../core/HyperlaneCore';
import {
InterchainAccountContracts,
InterchainAccountFactories,
@ -19,7 +11,11 @@ import {
InterchainQueryFactories,
interchainAccountFactories,
interchainQueryFactories,
} from './contracts';
} from '../../middleware';
import { MultiProvider } from '../../providers/MultiProvider';
import { ChainMap, ChainName } from '../../types';
import { HyperlaneRouterDeployer } from '../router/HyperlaneRouterDeployer';
import { RouterConfig } from '../router/types';
export type InterchainAccountConfig = RouterConfig;
@ -41,7 +37,10 @@ export class InterchainAccountDeployer<
// Custom contract deployment logic can go here
// If no custom logic is needed, call deployContract for the router
async deployContracts(chain: Chain, config: InterchainAccountConfig) {
async deployContracts(
chain: Chain,
config: InterchainAccountConfig,
): Promise<InterchainAccountContracts> {
const initCalldata =
InterchainAccountRouter__factory.createInterface().encodeFunctionData(
'initialize',
@ -78,7 +77,10 @@ export class InterchainQueryDeployer<
// Custom contract deployment logic can go here
// If no custom logic is needed, call deployContract for the router
async deployContracts(chain: Chain, config: InterchainQueryConfig) {
async deployContracts(
chain: Chain,
config: InterchainQueryConfig,
): Promise<InterchainQueryContracts> {
const initCalldata =
InterchainQueryRouter__factory.createInterface().encodeFunctionData(
'initialize',

@ -111,6 +111,14 @@ export { HyperlaneDeployer } from './deploy/HyperlaneDeployer';
export { UpgradeBeaconViolation } from './deploy/proxy';
export { HyperlaneRouterDeployer } from './deploy/router/HyperlaneRouterDeployer';
export { HyperlaneRouterChecker } from './deploy/router/HyperlaneRouterChecker';
export {
InterchainAccountDeployer,
InterchainQueryDeployer,
} from './deploy/middleware/deploy';
export {
interchainAccountFactories,
interchainQueryFactories,
} from './middleware';
export { RouterConfig } from './deploy/router/types';
export { getTestMultiProvider, getChainToOwnerMap } from './deploy/utils';
export { ContractVerifier } from './deploy/verify/ContractVerifier';

@ -1,11 +1,11 @@
import { RouterContracts, RouterFactories } from '@hyperlane-xyz/sdk';
import {
InterchainAccountRouter,
InterchainAccountRouter__factory,
InterchainQueryRouter,
InterchainQueryRouter__factory,
} from '../types';
} from '@hyperlane-xyz/core';
import { RouterContracts, RouterFactories } from './router';
export type InterchainAccountFactories =
RouterFactories<InterchainAccountRouter>;

@ -2,22 +2,20 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { expect } from 'chai';
import { ethers } from 'hardhat';
import { TestRecipient__factory } from '@hyperlane-xyz/core';
import {
ChainMap,
ChainNameToDomainId,
MultiProvider,
RouterConfig,
TestChainNames,
TestCoreApp,
TestCoreDeployer,
getChainToOwnerMap,
getTestMultiProvider,
testChainConnectionConfigs,
} from '@hyperlane-xyz/sdk';
InterchainAccountRouter,
TestRecipient__factory,
} from '@hyperlane-xyz/core';
import { InterchainAccountDeployer } from '../src/deploy';
import { InterchainAccountRouter } from '../types';
import { testChainConnectionConfigs } from '../consts/chainConnectionConfigs';
import { TestCoreApp } from '../core/TestCoreApp';
import { TestCoreDeployer } from '../core/TestCoreDeployer';
import { InterchainAccountDeployer } from '../deploy/middleware/deploy';
import { RouterConfig } from '../deploy/router/types';
import { getChainToOwnerMap, getTestMultiProvider } from '../deploy/utils';
import { ChainNameToDomainId } from '../domains';
import { MultiProvider } from '../providers/MultiProvider';
import { ChainMap, TestChainNames } from '../types';
describe('InterchainAccountRouter', async () => {
const localChain = 'test1';

@ -3,21 +3,20 @@ import { expect } from 'chai';
import { ethers } from 'hardhat';
import {
ChainMap,
ChainNameToDomainId,
MultiProvider,
RouterConfig,
TestChainNames,
TestCoreApp,
TestCoreDeployer,
getChainToOwnerMap,
getTestMultiProvider,
testChainConnectionConfigs,
} from '@hyperlane-xyz/sdk';
InterchainQueryRouter,
TestQuery,
TestQuery__factory,
} from '@hyperlane-xyz/core';
import { InterchainQueryDeployer } from '../src/deploy';
import { InterchainQueryRouter } from '../types';
import { TestQuery, TestQuery__factory } from '../types';
import { testChainConnectionConfigs } from '../consts/chainConnectionConfigs';
import { TestCoreApp } from '../core/TestCoreApp';
import { TestCoreDeployer } from '../core/TestCoreDeployer';
import { InterchainQueryDeployer } from '../deploy/middleware/deploy';
import { RouterConfig } from '../deploy/router/types';
import { getChainToOwnerMap, getTestMultiProvider } from '../deploy/utils';
import { ChainNameToDomainId } from '../domains';
import { MultiProvider } from '../providers/MultiProvider';
import { ChainMap, TestChainNames } from '../types';
describe('InterchainQueryRouter', async () => {
const localChain = 'test1';

@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/",
"rootDir": "./src/"
},
"include": ["./src/**/*.ts", "./src/*.d.ts"],
}

@ -5,4 +5,5 @@
"rootDir": "./src/"
},
"include": ["./src/**/*.ts", "./src/*.d.ts"],
"files": ["hardhat.config.ts"]
}

@ -3760,7 +3760,6 @@ __metadata:
"@gnosis.pm/safe-service-client": ^1.2.0
"@hyperlane-xyz/celo-ethers-provider": ^0.1.1
"@hyperlane-xyz/helloworld": 0.5.1
"@hyperlane-xyz/interchain-accounts": 0.5.1
"@hyperlane-xyz/sdk": 0.5.1
"@hyperlane-xyz/utils": 0.5.1
"@nomiclabs/hardhat-ethers": ^2.0.5
@ -3787,42 +3786,6 @@ __metadata:
languageName: unknown
linkType: soft
"@hyperlane-xyz/interchain-accounts@0.5.1, @hyperlane-xyz/interchain-accounts@workspace:typescript/ica":
version: 0.0.0-use.local
resolution: "@hyperlane-xyz/interchain-accounts@workspace:typescript/ica"
dependencies:
"@hyperlane-xyz/core": 0.5.1
"@hyperlane-xyz/sdk": 0.5.1
"@hyperlane-xyz/utils": 0.5.1
"@nomicfoundation/hardhat-chai-matchers": ^1.0.3
"@nomicfoundation/hardhat-toolbox": ^1.0.2
"@nomiclabs/hardhat-ethers": ^2.0.5
"@nomiclabs/hardhat-waffle": ^2.0.2
"@openzeppelin/contracts-upgradeable": ^4.6.0
"@trivago/prettier-plugin-sort-imports": ^3.2.0
"@typechain/ethers-v5": 10.0.0
"@typechain/hardhat": ^6.0.0
"@types/mocha": ^9.1.0
"@typescript-eslint/eslint-plugin": ^5.27.0
"@typescript-eslint/parser": ^5.27.0
chai: ^4.3.0
eslint: ^8.16.0
eslint-config-prettier: ^8.5.0
ethereum-waffle: ^3.4.4
ethers: ^5.6.8
hardhat: ^2.8.4
hardhat-gas-reporter: ^1.0.7
prettier: ^2.4.1
prettier-plugin-solidity: ^1.0.0-beta.5
solhint: ^3.3.2
solhint-plugin-prettier: ^0.0.5
solidity-coverage: ^0.7.14
ts-node: ^10.8.0
typechain: 8.0.0
typescript: ^4.7.2
languageName: unknown
linkType: soft
"@hyperlane-xyz/monorepo@workspace:.":
version: 0.0.0-use.local
resolution: "@hyperlane-xyz/monorepo@workspace:."
@ -4095,52 +4058,6 @@ __metadata:
languageName: node
linkType: hard
"@nomicfoundation/hardhat-chai-matchers@npm:^1.0.3":
version: 1.0.3
resolution: "@nomicfoundation/hardhat-chai-matchers@npm:1.0.3"
dependencies:
"@ethersproject/abi": ^5.1.2
"@types/chai-as-promised": ^7.1.3
chai-as-promised: ^7.1.1
chalk: ^2.4.2
deep-eql: ^4.0.1
ordinal: ^1.0.3
peerDependencies:
"@nomiclabs/hardhat-ethers": ^2.0.0
chai: ^4.2.0
ethers: ^5.0.0
hardhat: ^2.9.4
checksum: bee445e7ed53d6ee00b85c5c76ca79b7cd1792487481803a29357803b09f92b626b6429a50522a8398c8010ad4fd1f0106c79416dc8c01aea644e7360ea9c203
languageName: node
linkType: hard
"@nomicfoundation/hardhat-toolbox@npm:^1.0.2":
version: 1.0.2
resolution: "@nomicfoundation/hardhat-toolbox@npm:1.0.2"
peerDependencies:
"@ethersproject/abi": ^5.4.7
"@ethersproject/providers": ^5.4.7
"@nomicfoundation/hardhat-chai-matchers": ^1.0.0
"@nomicfoundation/hardhat-network-helpers": ^1.0.0
"@nomiclabs/hardhat-ethers": ^2.0.0
"@nomiclabs/hardhat-etherscan": ^3.0.0
"@typechain/ethers-v5": ^10.1.0
"@typechain/hardhat": ^6.1.2
"@types/chai": ^4.2.0
"@types/mocha": ^9.1.0
"@types/node": ">=12.0.0"
chai: ^4.2.0
ethers: ^5.4.7
hardhat: ^2.9.9
hardhat-gas-reporter: ^1.0.8
solidity-coverage: ^0.7.21
ts-node: ">=8.0.0"
typechain: ^8.1.0
typescript: ">=4.5.0"
checksum: d13b3e9f08d8be5f72a25872b6a9d3609fdb34f46b47dbf10963a6fb5003ac1cd0d0c107ef6d91807b864a8766d9e5092518f21db3116902ee5a8ae73fdcaaa2
languageName: node
linkType: hard
"@nomiclabs/hardhat-ethers@npm:^2.0.5":
version: 2.0.6
resolution: "@nomiclabs/hardhat-ethers@npm:2.0.6"
@ -4588,15 +4505,6 @@ __metadata:
languageName: node
linkType: hard
"@types/chai-as-promised@npm:^7.1.3":
version: 7.1.5
resolution: "@types/chai-as-promised@npm:7.1.5"
dependencies:
"@types/chai": "*"
checksum: 7c1345c6e32513d52d8e562ec173c23161648d6b792046525f18803a9932d7b3ad3dca8f0181e3c529ec42b106099f174e34edeb184d61dc93e32c98b5132fd4
languageName: node
linkType: hard
"@types/chai@npm:*, @types/chai@npm:^4.2.21":
version: 4.3.1
resolution: "@types/chai@npm:4.3.1"
@ -6919,17 +6827,6 @@ __metadata:
languageName: node
linkType: hard
"chai-as-promised@npm:^7.1.1":
version: 7.1.1
resolution: "chai-as-promised@npm:7.1.1"
dependencies:
check-error: ^1.0.2
peerDependencies:
chai: ">= 2.1.2 < 5"
checksum: 7262868a5b51a12af4e432838ddf97a893109266a505808e1868ba63a12de7ee1166e9d43b5c501a190c377c1b11ecb9ff8e093c89f097ad96c397e8ec0f8d6a
languageName: node
linkType: hard
"chai@npm:^4.3.0, chai@npm:^4.3.4, chai@npm:^4.3.6":
version: 4.3.6
resolution: "chai@npm:4.3.6"
@ -7779,15 +7676,6 @@ __metadata:
languageName: node
linkType: hard
"deep-eql@npm:^4.0.1":
version: 4.1.0
resolution: "deep-eql@npm:4.1.0"
dependencies:
type-detect: ^4.0.0
checksum: 2fccd527df9a70a92a1dfa8c771d139753625938e137b09fc946af8577d22360ef28d3c74f0e9c5aaa399bab20542d0899da1529c71db76f280a30147cd2a110
languageName: node
linkType: hard
"deep-equal@npm:~1.1.1":
version: 1.1.1
resolution: "deep-equal@npm:1.1.1"
@ -13696,13 +13584,6 @@ __metadata:
languageName: node
linkType: hard
"ordinal@npm:^1.0.3":
version: 1.0.3
resolution: "ordinal@npm:1.0.3"
checksum: 6761c5b7606b6c4b0c22b4097dab4fe7ffcddacc49238eedf9c0ced877f5d4e4ad3f4fd43fefa1cc3f167cc54c7149267441b2ae85b81ccf13f45cf4b7947164
languageName: node
linkType: hard
"os-homedir@npm:^1.0.0":
version: 1.0.2
resolution: "os-homedir@npm:1.0.2"

Loading…
Cancel
Save