Skip to content

Commit

Permalink
chore: sdk add checkpointdeployer
Browse files Browse the repository at this point in the history
  • Loading branch information
NOOMA-42 committed Dec 4, 2024
1 parent a6640f1 commit 5b90706
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 10 deletions.
46 changes: 46 additions & 0 deletions typescript/sdk/src/checkpoint/CheckpointDeployer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { rootLogger } from '@hyperlane-xyz/utils';

import { HyperlaneContracts } from '../contracts/types.js';
import { HyperlaneDeployer } from '../deploy/HyperlaneDeployer.js';
import { ContractVerifier } from '../deploy/verify/ContractVerifier.js';
import { MultiProvider } from '../providers/MultiProvider.js';
import { ChainName } from '../types.js';

import {
CheckpointStorageFactories,
checkpointStorageFactories,
} from './contracts.js';
import { CheckpointStorageConfig } from './types.js';

export class CheckpointDeployer extends HyperlaneDeployer<
CheckpointStorageConfig,
CheckpointStorageFactories
> {
constructor(
multiProvider: MultiProvider,
contractVerifier?: ContractVerifier,
concurrentDeploy: boolean = false,
) {
super(multiProvider, checkpointStorageFactories, {
logger: rootLogger.child({ module: 'CheckpointDeployer' }),
contractVerifier,
concurrentDeploy,
});
}

async deployContracts(
chain: ChainName,
_config: CheckpointStorageConfig,
): Promise<HyperlaneContracts<CheckpointStorageFactories>> {
const checkpointStorage = await this.deployContract(
chain,
'checkpointStorage',
[],
);

const contracts = {
checkpointStorage,
};
return contracts;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import { HyperlaneProxyFactoryDeployer } from '../deploy/HyperlaneProxyFactoryDe
import { HyperlaneIsmFactory } from '../ism/HyperlaneIsmFactory.js';
import { MultiProvider } from '../providers/MultiProvider.js';

import { CheckpointModule } from './CheckpointModule.js';
import { EvmCheckpointModule } from './EvmCheckpointModule.js';

describe('CheckpointModule', async () => {
const chain = TestChainName.test1;

let multiProvider: MultiProvider;
let coreAddresses: CoreAddresses;
let signer: Signer;
let checkpointModule: CheckpointModule;
let checkpointModule: EvmCheckpointModule;
let checkpointStorage: CheckpointStorage;

before(async () => {
Expand Down Expand Up @@ -60,8 +60,7 @@ describe('CheckpointModule', async () => {
});

beforeEach(async () => {
// Create a new CheckpointModule before each test
checkpointModule = await CheckpointModule.create({
checkpointModule = await EvmCheckpointModule.create({
chain,
config: { chain },
coreAddresses: { mailbox: coreAddresses.mailbox },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ export type CheckpointModuleAddresses = {
mailbox: string;
};

export class CheckpointModule extends HyperlaneModule<
export class EvmCheckpointModule extends HyperlaneModule<
ProtocolType.Ethereum,
CheckpointStorageConfig,
HyperlaneAddresses<CheckpointStorageFactories> & CheckpointModuleAddresses
> {
protected readonly logger = rootLogger.child({ module: 'CheckpointModule' });
protected readonly logger = rootLogger.child({
module: 'EvmCheckpointModule',
});
protected readonly deployer: EvmModuleDeployer<CheckpointStorageFactories>;

// Adding these to reduce how often we need to grab from MultiProvider
Expand Down Expand Up @@ -72,8 +74,8 @@ export class CheckpointModule extends HyperlaneModule<
coreAddresses: { mailbox: string };
multiProvider: MultiProvider;
contractVerifier?: ContractVerifier;
}): Promise<CheckpointModule> {
const module = new CheckpointModule(
}): Promise<EvmCheckpointModule> {
const module = new EvmCheckpointModule(
multiProvider,
{
addresses: {
Expand Down Expand Up @@ -109,12 +111,10 @@ export class CheckpointModule extends HyperlaneModule<
}

async read(): Promise<CheckpointStorageConfig> {
// Implement reading the current configuration from the deployed contract
throw new Error('Method not implemented.');
}

async update(): Promise<AnnotatedEV5Transaction[]> {
// Implement updating the contract configuration
throw new Error('Method not implemented.');
}
}
2 changes: 2 additions & 0 deletions typescript/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,3 +530,5 @@ export {
} from './deploy/schemas.js';
export { AnnotatedEV5Transaction } from './providers/ProviderType.js';
export { proxyAdmin } from './deploy/proxy.js';
export { CheckpointDeployer } from './checkpoint/CheckpointDeployer.js';
export { EvmCheckpointModule } from './checkpoint/EvmCheckpointModule.js';

0 comments on commit 5b90706

Please sign in to comment.