Rename DomainConnection to ChainConnection (#435)

* Rename DomainConnection to ChainConnection

* Lint

* Lint
pull/459/head
Nam Chu Hoai 2 years ago committed by GitHub
parent 16f1b44256
commit ac808a8641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      typescript/deploy/src/check.ts
  2. 24
      typescript/deploy/src/core/deploy.ts
  3. 14
      typescript/deploy/src/deploy.ts
  4. 2
      typescript/deploy/src/router/deploy.ts
  5. 2
      typescript/deploy/src/utils.ts
  6. 2
      typescript/infra/scripts/set-validator.ts
  7. 4
      typescript/infra/src/controller/deploy.ts
  8. 2
      typescript/infra/src/core/control.ts
  9. 2
      typescript/sdk/src/app.ts
  10. 26
      typescript/sdk/src/chains.ts
  11. 6
      typescript/sdk/src/core/message.ts
  12. 4
      typescript/sdk/src/events.ts
  13. 5
      typescript/sdk/src/gas/calculator.ts
  14. 2
      typescript/sdk/src/index.ts
  15. 16
      typescript/sdk/src/provider.ts

@ -56,7 +56,7 @@ export abstract class AbacusAppChecker<
name: string,
proxiedAddress: ProxiedAddress,
) {
const dc = this.multiProvider.getDomainConnection(network);
const dc = this.multiProvider.getChainConnection(network);
const implementation = await upgradeBeaconImplementation(
dc.provider!,
proxiedAddress.beacon,

@ -12,11 +12,11 @@ import {
} from '@abacus-network/core';
import {
AbacusCore,
ChainConnection,
ChainMap,
ChainName,
CoreContractAddresses,
CoreContracts,
DomainConnection,
InboxContracts,
MailboxAddresses,
MultiProvider,
@ -68,7 +68,7 @@ export class AbacusCoreDeployer<
network: Local,
config: CoreConfig,
): Promise<CoreContractAddresses<Networks, Local>> {
const dc = this.multiProvider.getDomainConnection(network);
const dc = this.multiProvider.getChainConnection(network);
const signer = dc.signer!;
const provider = dc.provider!;
@ -221,11 +221,11 @@ export class AbacusCoreDeployer<
return promiseObjAll(
objMap(core.contractsMap, async (network, coreContracts) => {
const owner = owners[network];
const domainConnection = multiProvider.getDomainConnection(network);
const chainConnection = multiProvider.getChainConnection(network);
return AbacusCoreDeployer.transferOwnershipOfDomain(
coreContracts,
owner,
domainConnection,
chainConnection,
);
}),
);
@ -237,19 +237,19 @@ export class AbacusCoreDeployer<
>(
core: CoreContracts<CoreNetworks, Local>,
owner: types.Address,
domainConnection: DomainConnection,
chainConnection: ChainConnection,
): Promise<ethers.ContractReceipt> {
await core.contracts.outbox.validatorManager.transferOwnership(
owner,
domainConnection.overrides,
chainConnection.overrides,
);
await core.contracts.abacusConnectionManager.transferOwnership(
owner,
domainConnection.overrides,
chainConnection.overrides,
);
await core.contracts.upgradeBeaconController.transferOwnership(
owner,
domainConnection.overrides,
chainConnection.overrides,
);
const inboxContracts: InboxContracts[] = Object.values(
core.contracts.inboxes,
@ -258,16 +258,16 @@ export class AbacusCoreDeployer<
inboxContracts.map(async (inbox) => {
await inbox.validatorManager.transferOwnership(
owner,
domainConnection.overrides,
chainConnection.overrides,
);
await inbox.inbox.transferOwnership(owner, domainConnection.overrides);
await inbox.inbox.transferOwnership(owner, chainConnection.overrides);
}),
);
const tx = await core.contracts.outbox.outbox.transferOwnership(
owner,
domainConnection.overrides,
chainConnection.overrides,
);
return tx.wait(domainConnection.confirmations);
return tx.wait(chainConnection.confirmations);
}
}

@ -54,9 +54,9 @@ export abstract class AbacusAppDeployer<Networks extends ChainName, C, A> {
factory: F,
args: Parameters<F['deploy']>,
): Promise<ReturnType<F['deploy']>> {
const domainConnection = this.multiProvider.getDomainConnection(network);
const contract = await factory.deploy(...args, domainConnection.overrides);
await contract.deployTransaction.wait(domainConnection.confirmations);
const chainConnection = this.multiProvider.getChainConnection(network);
const contract = await factory.deploy(...args, chainConnection.overrides);
await contract.deployTransaction.wait(chainConnection.confirmations);
const verificationInput = getContractVerificationInput(
contractName,
contract,
@ -81,8 +81,8 @@ export abstract class AbacusAppDeployer<Networks extends ChainName, C, A> {
ubcAddress: types.Address,
initArgs: Parameters<C['initialize']>,
) {
const domainConnection = this.multiProvider.getDomainConnection(network);
const signer = domainConnection.signer;
const chainConnection = this.multiProvider.getChainConnection(network);
const signer = chainConnection.signer;
const implementation = await this.deployContract(
network,
`${contractName} Implementation`,
@ -125,7 +125,7 @@ export abstract class AbacusAppDeployer<Networks extends ChainName, C, A> {
proxy: ProxiedContract<C>,
initArgs: Parameters<C['initialize']>,
) {
const domainConnection = this.multiProvider.getDomainConnection(network);
const chainConnection = this.multiProvider.getChainConnection(network);
const initData = proxy.contract.interface.encodeFunctionData(
'initialize',
initArgs,
@ -133,7 +133,7 @@ export abstract class AbacusAppDeployer<Networks extends ChainName, C, A> {
const newProxy = await this.deployContract(
network,
`${contractName} Proxy`,
new UpgradeBeaconProxy__factory(domainConnection.signer!),
new UpgradeBeaconProxy__factory(chainConnection.signer!),
[proxy.addresses.beacon, initData],
);

@ -61,7 +61,7 @@ export abstract class AbacusRouterDeployer<
async deployConnectionManagerIfNotConfigured(
network: Networks,
): Promise<AbacusConnectionManager> {
const dc = this.multiProvider.getDomainConnection(network);
const dc = this.multiProvider.getChainConnection(network);
const signer = dc.signer!;
const config = this.configMap[network];
if (config.abacusConnectionManager) {

@ -71,7 +71,7 @@ export const registerSigners = <Networks extends ChainName>(
signers: ChainMap<Networks, ethers.Signer>,
) =>
objMap(signers, (network, signer) =>
multiProvider.getDomainConnection(network).registerSigner(signer),
multiProvider.getChainConnection(network).registerSigner(signer),
);
export const registerSigner = <Networks extends ChainName>(

@ -37,7 +37,7 @@ async function main() {
// Change to `batch.execute` in order to run.
const controllerActor = await controllerApp.controller();
const provider = multiProvider.getDomainConnection(controllerActor.network)
const provider = multiProvider.getChainConnection(controllerActor.network)
.provider!;
const receipts = await checker.controllerApp.estimateGas(provider);
console.log(receipts);

@ -23,7 +23,7 @@ export class ControllerDeployer<
network: Networks,
config: ControllerConfig,
): Promise<ControllerAddresses> {
const dc = this.multiProvider.getDomainConnection(network);
const dc = this.multiProvider.getChainConnection(network);
const signer = dc.signer!;
const abacusConnectionManager =
@ -85,7 +85,7 @@ export class ControllerDeployer<
mustGetRouter(network: Networks, addresses: ControllerAddresses) {
return ControllerRouter__factory.connect(
addresses.router.proxy,
this.multiProvider.getDomainConnection(network).signer!,
this.multiProvider.getChainConnection(network).signer!,
);
}
}

@ -93,7 +93,7 @@ export class AbacusCoreControllerChecker<
async handleValidatorViolation(
violation: ValidatorViolation,
): Promise<DomainedCall> {
const dc = this.multiProvider.getDomainConnection(
const dc = this.multiProvider.getChainConnection(
violation.network as Networks,
);
const provider = dc.provider!;

@ -18,7 +18,7 @@ export class AbacusApp<
(network, addresses) =>
new builder(
addresses,
multiProvider.getDomainConnection(network).getConnection()!,
multiProvider.getChainConnection(network).getConnection()!,
),
),
);

@ -1,10 +1,10 @@
import { StaticCeloJsonRpcProvider } from 'celo-ethers-provider';
import { ethers } from 'ethers';
import { IDomainConnection } from './provider';
import { IChainConnection } from './provider';
import { ChainMap, ChainName } from './types';
export const alfajores: IDomainConnection = {
export const alfajores: IChainConnection = {
provider: new StaticCeloJsonRpcProvider(
'https://alfajores-forno.celo.org',
44787,
@ -12,7 +12,7 @@ export const alfajores: IDomainConnection = {
confirmations: 1,
};
export const fuji: IDomainConnection = {
export const fuji: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'https://api.avax-test.network/ext/bc/C/rpc',
43113,
@ -20,7 +20,7 @@ export const fuji: IDomainConnection = {
confirmations: 1,
};
export const kovan: IDomainConnection = {
export const kovan: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'https://kovan.poa.network',
42,
@ -28,7 +28,7 @@ export const kovan: IDomainConnection = {
confirmations: 1,
};
export const mumbai: IDomainConnection = {
export const mumbai: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'https://rpc-mumbai.maticvigil.com',
80001,
@ -36,7 +36,7 @@ export const mumbai: IDomainConnection = {
confirmations: 30,
};
export const bsctestnet: IDomainConnection = {
export const bsctestnet: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'https://data-seed-prebsc-1-s3.binance.org:8545',
97,
@ -44,7 +44,7 @@ export const bsctestnet: IDomainConnection = {
confirmations: 1,
};
export const arbitrumrinkeby: IDomainConnection = {
export const arbitrumrinkeby: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'https://rinkeby.arbitrum.io/rpc',
421611,
@ -52,7 +52,7 @@ export const arbitrumrinkeby: IDomainConnection = {
confirmations: 1,
};
export const optimismkovan: IDomainConnection = {
export const optimismkovan: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'https://kovan.optimism.io',
69,
@ -60,7 +60,7 @@ export const optimismkovan: IDomainConnection = {
confirmations: 1,
};
export const test1: IDomainConnection = {
export const test1: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'http://localhost:8545',
31337,
@ -68,7 +68,7 @@ export const test1: IDomainConnection = {
confirmations: 1,
};
export const test2: IDomainConnection = {
export const test2: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'http://localhost:8545',
31337,
@ -76,7 +76,7 @@ export const test2: IDomainConnection = {
confirmations: 1,
};
export const test3: IDomainConnection = {
export const test3: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'http://localhost:8545',
31337,
@ -99,12 +99,12 @@ const _configs = {
export const addSignerToConnection =
<Networks extends ChainName>(signer: ethers.Signer) =>
(_chain: Networks, connection: IDomainConnection) => ({
(_chain: Networks, connection: IChainConnection) => ({
...connection,
signer,
});
export const chainConnectionConfigs: ChainMap<
keyof typeof _configs,
IDomainConnection
IChainConnection
> = _configs;

@ -155,7 +155,7 @@ export class AbacusMessage {
const messages: AbacusMessage[] = [];
const outbox = new Outbox__factory().interface;
const network = resolveDomain(nameOrDomain);
const provider = multiProvider.getDomainConnection(network).provider!;
const provider = multiProvider.getChainConnection(network).provider!;
for (const log of receipt.logs) {
try {
@ -228,7 +228,7 @@ export class AbacusMessage {
nameOrDomain: NameOrDomain,
transactionHash: string,
): Promise<AbacusMessage[]> {
const provider = multiProvider.getDomainConnection(
const provider = multiProvider.getChainConnection(
resolveDomain(nameOrDomain),
).provider!;
const receipt = await provider.getTransactionReceipt(transactionHash);
@ -259,7 +259,7 @@ export class AbacusMessage {
nameOrDomain: NameOrDomain,
transactionHash: string,
): Promise<AbacusMessage> {
const provider = multiProvider.getDomainConnection(
const provider = multiProvider.getChainConnection(
resolveDomain(nameOrDomain),
).provider!;
const receipt = await provider.getTransactionReceipt(transactionHash);

@ -179,7 +179,7 @@ async function getPaginatedEvents<T extends Result, U>(
// or current block number
let lastBlock;
if (!endBlock) {
const provider = multiprovider.getDomainConnection(network).provider!;
const provider = multiprovider.getChainConnection(network).provider!;
lastBlock = await provider.getBlockNumber();
} else {
lastBlock = endBlock;
@ -226,7 +226,7 @@ async function findFromPaginatedEvents<T extends Result, U>(
// or current block number
let lastBlock;
if (!endBlock) {
const provider = multiprovider.getDomainConnection(network).provider!;
const provider = multiprovider.getChainConnection(network).provider!;
lastBlock = await provider.getBlockNumber();
} else {
lastBlock = endBlock;

@ -253,8 +253,7 @@ export class InterchainGasCalculator<Networks extends ChainName> {
* @returns The suggested gas price in wei on the destination chain.
*/
async suggestedGasPrice(chainName: Networks): Promise<BigNumber> {
const provider =
this.multiProvider.getDomainConnection(chainName).provider!;
const provider = this.multiProvider.getChainConnection(chainName).provider!;
return provider.getGasPrice();
}
@ -284,7 +283,7 @@ export class InterchainGasCalculator<Networks extends ChainName> {
async estimateHandleGasForMessage<Local extends Networks>(
message: ParsedMessage<Networks, Local>,
): Promise<BigNumber> {
const provider = this.multiProvider.getDomainConnection(message.destination)
const provider = this.multiProvider.getChainConnection(message.destination)
.provider!;
const { inbox } = this.core.getMailboxPair<Local>(

@ -44,7 +44,7 @@ export {
ControllerContracts,
controllerEnvironments,
} from './controller';
export { DomainConnection, IDomainConnection, MultiProvider } from './provider';
export { ChainConnection, IChainConnection, MultiProvider } from './provider';
export {
AllChains,
ChainMap,

@ -3,20 +3,20 @@ import { ethers } from 'ethers';
import { ChainMap, ChainName } from './types';
import { MultiGeneric } from './utils';
export interface IDomainConnection {
export interface IChainConnection {
provider?: ethers.providers.Provider;
signer?: ethers.Signer;
overrides?: ethers.Overrides;
confirmations?: number;
}
export class DomainConnection {
export class ChainConnection {
provider?: ethers.providers.Provider;
signer?: ethers.Signer;
overrides: ethers.Overrides;
confirmations: number;
constructor(dc: IDomainConnection = {}) {
constructor(dc: IChainConnection = {}) {
this.provider = dc.provider;
this.signer = dc.signer;
this.overrides = dc.overrides ?? {};
@ -57,18 +57,18 @@ export class DomainConnection {
export class MultiProvider<
Networks extends ChainName = ChainName,
> extends MultiGeneric<Networks, DomainConnection> {
constructor(networks: ChainMap<Networks, IDomainConnection> | Networks[]) {
> extends MultiGeneric<Networks, ChainConnection> {
constructor(networks: ChainMap<Networks, IChainConnection> | Networks[]) {
const params = Array.isArray(networks)
? networks.map((v) => [v, {}])
: (Object.entries(networks) as [Networks, IDomainConnection][]);
: (Object.entries(networks) as [Networks, IChainConnection][]);
const providerEntries = params.map(([network, v]) => [
network,
new DomainConnection(v),
new ChainConnection(v),
]);
super(Object.fromEntries(providerEntries));
}
getDomainConnection(network: Networks) {
getChainConnection(network: Networks) {
return this.get(network);
}
// This doesn't work on hardhat providers so we skip for now

Loading…
Cancel
Save