-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3528b28
commit cc7206a
Showing
4 changed files
with
510 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,77 @@ | ||
import { Address, ProtocolType, rootLogger } from '@hyperlane-xyz/utils'; | ||
|
||
import { HyperlaneAddresses } from '../contracts/types.js'; | ||
import { HyperlaneContracts } from '../contracts/types.js'; | ||
import { HyperlaneDeployer } from '../deploy/HyperlaneDeployer.js'; | ||
import { ProxyFactoryFactories } from '../deploy/contracts.js'; | ||
import { EvmIsmCreator } from '../ism/EvmIsmCreator.js'; | ||
import { EvmIsmReader } from '../ism/read.js'; | ||
import { IsmConfig } from '../ism/types.js'; | ||
import { MultiProvider } from '../providers/MultiProvider.js'; | ||
import { EthersV5Transaction } from '../providers/ProviderType.js'; | ||
import { ChainNameOrId } from '../types.js'; | ||
|
||
import { CrudModule, CrudModuleArgs } from './AbstractCrudModule.js'; | ||
|
||
// WIP example implementation of EvmIsmModule | ||
export class EvmIsmModule extends CrudModule< | ||
ProtocolType.Ethereum, | ||
IsmConfig, | ||
HyperlaneAddresses<ProxyFactoryFactories> | ||
HyperlaneContracts<ProxyFactoryFactories> & { | ||
deployedIsm: Address; | ||
} | ||
> { | ||
protected logger = rootLogger.child({ module: 'EvmIsmModule' }); | ||
protected reader: EvmIsmReader; | ||
|
||
protected constructor( | ||
protected readonly multiProvider: MultiProvider, | ||
args: Omit< | ||
CrudModuleArgs< | ||
ProtocolType.Ethereum, | ||
IsmConfig, | ||
HyperlaneAddresses<ProxyFactoryFactories> | ||
>, | ||
'provider' | ||
args: CrudModuleArgs< | ||
IsmConfig, | ||
HyperlaneContracts<ProxyFactoryFactories> & { | ||
deployedIsm: Address; | ||
} | ||
>, | ||
) { | ||
super({ | ||
...args, | ||
provider: multiProvider.getProvider(args.chain), | ||
}); | ||
super(args); | ||
|
||
this.reader = new EvmIsmReader(multiProvider, args.chain); | ||
} | ||
|
||
public async read(address: Address): Promise<IsmConfig> { | ||
return await this.reader.deriveIsmConfig(address); | ||
public async read(): Promise<IsmConfig> { | ||
return await this.reader.deriveIsmConfig(this.args.addresses.deployedIsm); | ||
} | ||
|
||
public async update(_config: IsmConfig): Promise<EthersV5Transaction[]> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
// manually write static create function | ||
public static create(_config: IsmConfig): Promise<EvmIsmModule> { | ||
throw new Error('not implemented'); | ||
public static async create({ | ||
chain, | ||
config, | ||
deployer, | ||
factories, | ||
multiProvider, | ||
}: { | ||
chain: ChainNameOrId; | ||
config: IsmConfig; | ||
deployer: HyperlaneDeployer<any, any>; | ||
factories: HyperlaneContracts<ProxyFactoryFactories>; | ||
multiProvider: MultiProvider; | ||
}): Promise<EvmIsmModule> { | ||
const destination = multiProvider.getChainName(chain); | ||
const ismCreator = new EvmIsmCreator(deployer, multiProvider, factories); | ||
const deployedIsm = await ismCreator.deploy({ | ||
config, | ||
destination, | ||
}); | ||
return new EvmIsmModule(multiProvider, { | ||
addresses: { | ||
...factories, | ||
deployedIsm: deployedIsm.address, | ||
}, | ||
chain, | ||
config, | ||
}); | ||
} | ||
} |
Oops, something went wrong.