Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify deploy and app abstractions #507

Merged
merged 18 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify SDK deploy abstraction
  • Loading branch information
yorhodes committed May 27, 2022
commit 85e62d0f69083ae9fa984164e7f457f87c864bcf
13 changes: 6 additions & 7 deletions typescript/deploy/src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import {
UpgradeBeacon__factory,
} from '@abacus-network/core';
import {
AbacusContracts,
AbacusFactories,
ChainMap,
ChainName,
MultiProvider,
ProxiedAddress,
objMap,
} from '@abacus-network/sdk';
import { types } from '@abacus-network/utils';
Expand All @@ -27,6 +28,7 @@ export abstract class AbacusDeployer<
Chain extends ChainName,
Config,
Factories extends AbacusFactories,
Contracts extends AbacusContracts,
> {
verificationInputs: ChainMap<Chain, ContractVerificationInput[]>;
protected logger: Debugger;
Expand All @@ -41,22 +43,19 @@ export abstract class AbacusDeployer<
this.logger = options?.logger || debug('abacus:AppDeployer');
}

abstract deployContracts(
chain: Chain,
config: Config,
): Promise<AbacusContracts>;
abstract deployContracts(chain: Chain, config: Config): Promise<Contracts>;

async deploy() {
this.logger('Start Deploy');
this.verificationInputs = objMap(this.configMap, () => []);
const chains = this.multiProvider.chains();
const entries: [Chain, AbacusContracts][] = [];
const entries: [Chain, Contracts][] = [];
for (const chain of chains) {
this.logger(`Deploying to ${chain}...`);
const result = await this.deployContracts(chain, this.configMap[chain]);
entries.push([chain, result]);
}
return Object.fromEntries(entries) as Record<Chain, AbacusContracts>;
return Object.fromEntries(entries) as Record<Chain, Contracts>;
}

async deployContract<K extends keyof Factories>(
Expand Down
2 changes: 1 addition & 1 deletion typescript/deploy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export {
CoreConfig,
ValidatorManagerConfig,
} from './core/deploy';
export { AbacusAppDeployer } from './deploy';
export { AbacusDeployer } from './deploy';
export {
ProxiedContract,
ProxyViolationType,
Expand Down
16 changes: 9 additions & 7 deletions typescript/sdk/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ export class AbacusApp<
Contracts extends AbacusContracts,
Chain extends ChainName = ChainName,
> extends MultiGeneric<Chain, Contracts> {
constructor(
constructor(contractsMap: ChainMap<Chain, Contracts>) {
super(contractsMap);
}

static build<Contracts extends AbacusContracts, Chain extends ChainName>(
addressesMap: ChainMap<Chain, AbacusAddresses>,
factories: AbacusFactories,
) {
super(
objMap(
addressesMap,
(_, addresses) => attach(addresses, factories) as Contracts,
),
): ChainMap<Chain, Contracts> {
return objMap(
addressesMap,
(_, addresses) => attach(addresses, factories) as Contracts,
);
}

Expand Down