-
Notifications
You must be signed in to change notification settings - Fork 361
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
c4b7ad3
commit 2db77f1
Showing
17 changed files
with
270 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@hyperlane-xyz/sdk': minor | ||
--- | ||
|
||
Added RPC `concurrency` property to `ChainMetadata`. | ||
Added `CrudModule` abstraction and related types. | ||
Removed `Fuel` ProtocolType. |
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Logger } from 'pino'; | ||
|
||
import { Address, Annotated, ProtocolType } from '@hyperlane-xyz/utils'; | ||
|
||
import { ChainMetadataManager } from '../metadata/ChainMetadataManager.js'; | ||
import { | ||
ProtocolTypedProvider, | ||
ProtocolTypedTransaction, | ||
} from '../providers/ProviderType.js'; | ||
import { ChainNameOrId } from '../types.js'; | ||
|
||
export type CrudModuleArgs< | ||
TProtocol extends ProtocolType, | ||
TConfig, | ||
TAddressMap extends Record<string, Address>, | ||
> = { | ||
addresses: TAddressMap; | ||
chain: ChainNameOrId; | ||
chainMetadataManager: ChainMetadataManager; | ||
config: TConfig; | ||
provider: ProtocolTypedProvider<TProtocol>['provider']; | ||
}; | ||
|
||
export abstract class CrudModule< | ||
TProtocol extends ProtocolType, | ||
TConfig, | ||
TAddressMap extends Record<string, Address>, | ||
> { | ||
protected abstract readonly logger: Logger; | ||
|
||
protected constructor( | ||
protected readonly args: CrudModuleArgs<TProtocol, TConfig, TAddressMap>, | ||
) {} | ||
|
||
public serialize(): TAddressMap { | ||
return this.args.addresses; | ||
} | ||
|
||
public abstract read(address: Address): Promise<TConfig>; | ||
public abstract update( | ||
config: TConfig, | ||
): Promise<Annotated<ProtocolTypedTransaction<TProtocol>[]>>; | ||
|
||
// /* | ||
// Types and static methods can be challenging. Ensure each implementation includes a static create function. | ||
// Currently, include TConfig to maintain the structure for ISM/Hook configurations. | ||
// If found to be unnecessary, we may consider revisiting and potentially removing these config requirements later. | ||
// */ | ||
// public static create< | ||
// TConfig extends CrudConfig, | ||
// TProtocol extends ProtocolType, | ||
// TAddress extends Record<string, any>, | ||
// TModule extends CrudModule<TProtocol, TConfig, TAddress>, | ||
// >(_config: TConfig): Promise<TModule> { | ||
// throw new Error('not implemented'); | ||
// } | ||
} |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Address, ProtocolType, rootLogger } from '@hyperlane-xyz/utils'; | ||
|
||
import { HyperlaneAddresses } from '../contracts/types.js'; | ||
import { HookFactories } from '../hook/contracts.js'; | ||
import { EvmHookReader } from '../hook/read.js'; | ||
import { HookConfig } from '../hook/types.js'; | ||
import { MultiProvider } from '../providers/MultiProvider.js'; | ||
import { EthersV5Transaction } from '../providers/ProviderType.js'; | ||
|
||
import { CrudModule, CrudModuleArgs } from './AbstractCrudModule.js'; | ||
|
||
// WIP example implementation of EvmHookModule | ||
export class EvmHookModule extends CrudModule< | ||
ProtocolType.Ethereum, | ||
HookConfig, | ||
HyperlaneAddresses<HookFactories> | ||
> { | ||
protected logger = rootLogger.child({ module: 'EvmHookModule' }); | ||
protected reader: EvmHookReader; | ||
|
||
protected constructor( | ||
protected readonly multiProvider: MultiProvider, | ||
args: Omit< | ||
CrudModuleArgs< | ||
ProtocolType.Ethereum, | ||
HookConfig, | ||
HyperlaneAddresses<HookFactories> | ||
>, | ||
'provider' | ||
>, | ||
) { | ||
super({ | ||
...args, | ||
provider: multiProvider.getProvider(args.chain), | ||
}); | ||
|
||
this.reader = new EvmHookReader(multiProvider, args.chain); | ||
} | ||
|
||
public async read(address: Address): Promise<HookConfig> { | ||
return await this.reader.deriveHookConfig(address); | ||
} | ||
|
||
public async update(_config: HookConfig): Promise<EthersV5Transaction[]> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
// manually write static create function | ||
public static create(_config: HookConfig): Promise<EvmHookModule> { | ||
throw new Error('not implemented'); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Address, ProtocolType, rootLogger } from '@hyperlane-xyz/utils'; | ||
|
||
import { HyperlaneAddresses } from '../contracts/types.js'; | ||
import { ProxyFactoryFactories } from '../deploy/contracts.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 { CrudModule, CrudModuleArgs } from './AbstractCrudModule.js'; | ||
|
||
// WIP example implementation of EvmIsmModule | ||
export class EvmIsmModule extends CrudModule< | ||
ProtocolType.Ethereum, | ||
IsmConfig, | ||
HyperlaneAddresses<ProxyFactoryFactories> | ||
> { | ||
protected logger = rootLogger.child({ module: 'EvmIsmModule' }); | ||
protected reader: EvmIsmReader; | ||
|
||
protected constructor( | ||
protected readonly multiProvider: MultiProvider, | ||
args: Omit< | ||
CrudModuleArgs< | ||
ProtocolType.Ethereum, | ||
IsmConfig, | ||
HyperlaneAddresses<ProxyFactoryFactories> | ||
>, | ||
'provider' | ||
>, | ||
) { | ||
super({ | ||
...args, | ||
provider: multiProvider.getProvider(args.chain), | ||
}); | ||
|
||
this.reader = new EvmIsmReader(multiProvider, args.chain); | ||
} | ||
|
||
public async read(address: Address): Promise<IsmConfig> { | ||
return await this.reader.deriveIsmConfig(address); | ||
} | ||
|
||
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'); | ||
} | ||
} |
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
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
Oops, something went wrong.