Update to 1.3.0 (#50)

* Update for igp refactor

* Adapt to new router shapes
pull/2435/head
Asa Oines 2 years ago committed by GitHub
parent 761e528215
commit 6b36d7f196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      package.json
  2. 32
      src/app/app.ts
  3. 10
      src/app/contracts.ts
  4. 6
      src/deploy/check.ts
  5. 13
      src/deploy/deploy.ts
  6. 8
      src/index.ts
  7. 19
      src/scripts/check.ts
  8. 14
      src/scripts/deploy.ts
  9. 13
      src/test/deploy.test.ts
  10. 8
      src/test/helloworld.test.ts
  11. 32
      yarn.lock

@ -1,9 +1,9 @@
{
"name": "@hyperlane-xyz/helloworld",
"description": "A basic skeleton of an Hyperlane app",
"version": "1.2.3",
"version": "1.3.0",
"dependencies": {
"@hyperlane-xyz/sdk": "1.2.3",
"@hyperlane-xyz/sdk": "1.3.0",
"@openzeppelin/contracts-upgradeable": "^4.8.0",
"ethers": "^5.7.2"
},

@ -3,29 +3,36 @@ import { BigNumber, ethers } from 'ethers';
import {
ChainMap,
ChainName,
HyperlaneApp,
HyperlaneContracts,
HyperlaneContractsMap,
HyperlaneCore,
InterchainGasCalculator,
MultiProvider,
RouterApp,
} from '@hyperlane-xyz/sdk';
import { debug } from '@hyperlane-xyz/utils';
import { HelloWorldContracts } from './contracts';
import { HelloWorld } from '../types';
import { HelloWorldFactories } from './contracts';
type Counts = {
sent: number;
received: number;
};
export class HelloWorldApp extends HyperlaneApp<HelloWorldContracts> {
export class HelloWorldApp extends RouterApp<HelloWorldFactories> {
constructor(
public readonly core: HyperlaneCore,
contractsMap: ChainMap<HelloWorldContracts>,
contractsMap: HyperlaneContractsMap<HelloWorldFactories>,
multiProvider: MultiProvider,
) {
super(contractsMap, multiProvider);
}
router(contracts: HyperlaneContracts<HelloWorldFactories>): HelloWorld {
return contracts.router;
}
async sendHelloWorld(
from: ChainName,
to: ChainName,
@ -59,21 +66,6 @@ export class HelloWorldApp extends HyperlaneApp<HelloWorldContracts> {
return tx.wait(blocks?.confirmations || 1);
}
async quoteGasPayment(from: ChainName, to: ChainName): Promise<BigNumber> {
const sender = this.getContracts(from).router;
const handleGasAmount = await sender.HANDLE_GAS_AMOUNT();
const calculator = new InterchainGasCalculator(
this.multiProvider,
this.core,
);
return calculator.quoteGasPaymentForDefaultIsmIgp(
from,
to,
handleGasAmount,
);
}
async waitForMessageReceipt(
receipt: ethers.ContractReceipt,
): Promise<ethers.ContractReceipt[]> {

@ -1,11 +1,7 @@
import { RouterContracts, RouterFactories } from '@hyperlane-xyz/sdk';
import { HelloWorld__factory } from '../types';
import { HelloWorld, HelloWorld__factory } from '../types';
export type HelloWorldFactories = RouterFactories<HelloWorld>;
export const helloWorldFactories: HelloWorldFactories = {
export const helloWorldFactories = {
router: new HelloWorld__factory(),
};
export type HelloWorldContracts = RouterContracts<HelloWorld>;
export type HelloWorldFactories = typeof helloWorldFactories;

@ -1,12 +1,12 @@
import { HyperlaneRouterChecker } from '@hyperlane-xyz/sdk';
import { HelloWorldApp } from '../app/app';
import { HelloWorldContracts } from '../app/contracts';
import { HelloWorldFactories } from '../app/contracts';
import { HelloWorldConfig } from './config';
export class HelloWorldChecker extends HyperlaneRouterChecker<
HelloWorldFactories,
HelloWorldApp,
HelloWorldConfig,
HelloWorldContracts
HelloWorldConfig
> {}

@ -1,22 +1,19 @@
import {
ChainMap,
ChainName,
HyperlaneContracts,
HyperlaneCore,
HyperlaneRouterDeployer,
MultiProvider,
} from '@hyperlane-xyz/sdk';
import {
HelloWorldContracts,
HelloWorldFactories,
helloWorldFactories,
} from '../app/contracts';
import { HelloWorldFactories, helloWorldFactories } from '../app/contracts';
import { HelloWorld } from '../types';
import { HelloWorldConfig } from './config';
export class HelloWorldDeployer extends HyperlaneRouterDeployer<
HelloWorldConfig,
HelloWorldContracts,
HelloWorldFactories
> {
constructor(
@ -27,6 +24,10 @@ export class HelloWorldDeployer extends HyperlaneRouterDeployer<
super(multiProvider, configMap, helloWorldFactories, {});
}
router(contracts: HyperlaneContracts<HelloWorldFactories>): HelloWorld {
return contracts.router;
}
// Custom contract deployment logic can go here
// If no custom logic is needed, call deployContract for the router
async deployContracts(chain: ChainName, config: HelloWorldConfig) {

@ -1,10 +1,6 @@
export { HelloWorldApp } from './app/app';
export { HelloWorldFactories, helloWorldFactories } from './app/contracts';
export { HelloWorldChecker } from './deploy/check';
export { HelloWorldConfig } from './deploy/config';
export { HelloWorldDeployer } from './deploy/deploy';
export { HelloWorldApp } from './app/app';
export {
HelloWorldContracts,
HelloWorldFactories,
helloWorldFactories,
} from './app/contracts';
export * as types from './types';

@ -1,13 +1,13 @@
import {
ChainMap,
HyperlaneCore,
HyperlaneIgp,
MultiProvider,
buildContracts,
getChainToOwnerMap,
attachContractsMap,
createRouterConfigMap,
} from '@hyperlane-xyz/sdk';
import { HelloWorldApp } from '../app/app';
import { HelloWorldContracts, helloWorldFactories } from '../app/contracts';
import { helloWorldFactories } from '../app/contracts';
import { HelloWorldChecker } from '../deploy/check';
import { prodConfigs } from '../deploy/config';
@ -21,15 +21,18 @@ async function check() {
console.info('Preparing utilities');
const multiProvider = new MultiProvider(prodConfigs);
const contractsMap = buildContracts(
const contractsMap = attachContractsMap(
deploymentAddresses,
helloWorldFactories,
) as ChainMap<HelloWorldContracts>;
);
const core = HyperlaneCore.fromEnvironment('testnet', multiProvider);
const igp = HyperlaneIgp.fromEnvironment('testnet', multiProvider);
const app = new HelloWorldApp(core, contractsMap, multiProvider);
const config = core.extendWithConnectionClientConfig(
getChainToOwnerMap(prodConfigs, ownerAddress),
const config = createRouterConfigMap(
ownerAddress,
core.contractsMap,
igp.contractsMap,
);
console.info('Starting check');

@ -2,9 +2,10 @@ import { Wallet } from 'ethers';
import {
HyperlaneCore,
HyperlaneIgp,
MultiProvider,
getChainToOwnerMap,
serializeContracts,
createRouterConfigMap,
serializeContractsMap,
} from '@hyperlane-xyz/sdk';
import { prodConfigs } from '../deploy/config';
@ -19,13 +20,16 @@ async function main() {
multiProvider.setSharedSigner(signer);
const core = HyperlaneCore.fromEnvironment('testnet', multiProvider);
const config = core.extendWithConnectionClientConfig(
getChainToOwnerMap(prodConfigs, signer.address),
const igp = HyperlaneIgp.fromEnvironment('testnet', multiProvider);
const config = createRouterConfigMap(
signer.address,
core.contractsMap,
igp.contractsMap,
);
const deployer = new HelloWorldDeployer(multiProvider, config, core);
const chainToContracts = await deployer.deploy();
const addresses = serializeContracts(chainToContracts);
const addresses = serializeContractsMap(chainToContracts);
console.info('===Contract Addresses===');
console.info(JSON.stringify(addresses));
}

@ -3,14 +3,15 @@ import { ethers } from 'hardhat';
import {
ChainMap,
HyperlaneContractsMap,
MultiProvider,
TestCoreApp,
TestCoreDeployer,
getTestOwnerConfig,
deployTestIgpsAndGetRouterConfig,
} from '@hyperlane-xyz/sdk';
import { HelloWorldApp } from '../app/app';
import { HelloWorldContracts } from '../app/contracts';
import { HelloWorldFactories } from '../app/contracts';
import { HelloWorldChecker } from '../deploy/check';
import { HelloWorldConfig } from '../deploy/config';
import { HelloWorldDeployer } from '../deploy/deploy';
@ -20,7 +21,7 @@ describe('deploy', async () => {
let core: TestCoreApp;
let config: ChainMap<HelloWorldConfig>;
let deployer: HelloWorldDeployer;
let contracts: ChainMap<HelloWorldContracts>;
let contracts: HyperlaneContractsMap<HelloWorldFactories>;
let app: HelloWorldApp;
before(async () => {
@ -30,8 +31,10 @@ describe('deploy', async () => {
const coreDeployer = new TestCoreDeployer(multiProvider);
const coreContractsMaps = await coreDeployer.deploy();
core = new TestCoreApp(coreContractsMaps, multiProvider);
config = core.extendWithConnectionClientConfig(
getTestOwnerConfig(signer.address),
config = await deployTestIgpsAndGetRouterConfig(
multiProvider,
signer.address,
core.contractsMap,
);
deployer = new HelloWorldDeployer(multiProvider, config, core);
});

@ -8,7 +8,7 @@ import {
MultiProvider,
TestCoreApp,
TestCoreDeployer,
getTestOwnerConfig,
deployTestIgpsAndGetRouterConfig,
} from '@hyperlane-xyz/sdk';
import { HelloWorldConfig } from '../deploy/config';
@ -43,8 +43,10 @@ describe('HelloWorld', async () => {
const coreDeployer = new TestCoreDeployer(multiProvider);
const coreContractsMaps = await coreDeployer.deploy();
coreApp = new TestCoreApp(coreContractsMaps, multiProvider);
config = coreApp.extendWithConnectionClientConfig(
getTestOwnerConfig(signer.address),
config = await deployTestIgpsAndGetRouterConfig(
multiProvider,
signer.address,
coreContractsMaps,
);
});

@ -1350,14 +1350,14 @@ __metadata:
languageName: node
linkType: hard
"@hyperlane-xyz/core@npm:1.2.3":
version: 1.2.3
resolution: "@hyperlane-xyz/core@npm:1.2.3"
"@hyperlane-xyz/core@npm:1.3.0":
version: 1.3.0
resolution: "@hyperlane-xyz/core@npm:1.3.0"
dependencies:
"@hyperlane-xyz/utils": 1.2.3
"@hyperlane-xyz/utils": 1.3.0
"@openzeppelin/contracts": ^4.8.0
"@openzeppelin/contracts-upgradeable": ^4.8.0
checksum: c7e8f5c37d2e6874b6ca5f16024a4ea8b413393a2a4bb770a467ca7cc031b51a89fbe6989598c171de38acafcd2e990525be0274f793742faafc832a0db359fa
checksum: 8e4c8e72dee2ff2705697f802de06d29fcbdb8789883f051977bbb82748d842647d6274691d918edafa03fa18e9e2fb0359c6af4d8d7f7f99cbe2167a2aef1f4
languageName: node
linkType: hard
@ -1365,7 +1365,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@hyperlane-xyz/helloworld@workspace:."
dependencies:
"@hyperlane-xyz/sdk": 1.2.3
"@hyperlane-xyz/sdk": 1.3.0
"@nomiclabs/hardhat-ethers": ^2.2.1
"@nomiclabs/hardhat-waffle": ^2.0.3
"@openzeppelin/contracts-upgradeable": ^4.8.0
@ -1393,28 +1393,28 @@ __metadata:
languageName: unknown
linkType: soft
"@hyperlane-xyz/sdk@npm:1.2.3":
version: 1.2.3
resolution: "@hyperlane-xyz/sdk@npm:1.2.3"
"@hyperlane-xyz/sdk@npm:1.3.0":
version: 1.3.0
resolution: "@hyperlane-xyz/sdk@npm:1.3.0"
dependencies:
"@hyperlane-xyz/core": 1.2.3
"@hyperlane-xyz/utils": 1.2.3
"@hyperlane-xyz/core": 1.3.0
"@hyperlane-xyz/utils": 1.3.0
"@wagmi/chains": ^0.2.6
coingecko-api: ^1.0.10
cross-fetch: ^3.1.5
debug: ^4.3.4
ethers: ^5.7.2
zod: ^3.21.2
checksum: a1afc8bdfe64916fdc6623c1df06bbe1393359fe6b29cefe3f25bb5ded16108e1bac037da9a29df7f0d61cc84940e571d148e41c7fd8539964a87e9a95c03c35
checksum: ef8f964b58cf16bd514ed09b8f22c484dcd08385510aa67bbcb896b7a95c103b7f029d66ef676807b07a9be1aaf816d937fce7d5848f9f38529373d2f276be3d
languageName: node
linkType: hard
"@hyperlane-xyz/utils@npm:1.2.3":
version: 1.2.3
resolution: "@hyperlane-xyz/utils@npm:1.2.3"
"@hyperlane-xyz/utils@npm:1.3.0":
version: 1.3.0
resolution: "@hyperlane-xyz/utils@npm:1.3.0"
dependencies:
ethers: ^5.7.2
checksum: 14222632d7ef2419f6b698afa0c4c466302dd0eb6f97d3c9031b7d42c033418547bf4092d480cc4346331f0233d4076caae75b86ffa2b7beed79741a146d3325
checksum: 22008ac00bc37f23387b5988fa22c9066796dfa5bcc115a1cd51087b160115279cb3fa57061545fa3053de660750a27bbdb94ef8daa47abbfdf0cef8013dc787
languageName: node
linkType: hard

Loading…
Cancel
Save