@hyperlane-xyz/sdk
Version:
The official SDK for the Hyperlane Network
58 lines • 2.85 kB
JavaScript
import { z } from 'zod';
import { ProxyAdmin__factory, TimelockController__factory, } from '@hyperlane-xyz/core';
import { isNumeric } from '@hyperlane-xyz/utils';
import { TokenFeeConfigInputSchema } from '../fee/types.js';
import { HookConfigSchema } from '../hook/types.js';
import { IsmConfigSchema } from '../ism/types.js';
import { ZHash } from '../metadata/customZodTypes.js';
import { DeployedOwnableSchema, OwnableSchema } from '../types.js';
export const proxiedFactories = {
proxyAdmin: new ProxyAdmin__factory(),
timelockController: new TimelockController__factory(),
};
export var ClientViolationType;
(function (ClientViolationType) {
ClientViolationType["InterchainSecurityModule"] = "ClientIsm";
ClientViolationType["Mailbox"] = "ClientMailbox";
ClientViolationType["Hook"] = "ClientHook";
})(ClientViolationType || (ClientViolationType = {}));
export var RouterViolationType;
(function (RouterViolationType) {
RouterViolationType["MisconfiguredEnrolledRouter"] = "MisconfiguredEnrolledRouter";
RouterViolationType["MissingEnrolledRouter"] = "MissingEnrolledRouter";
RouterViolationType["MissingRouter"] = "MissingRouter";
})(RouterViolationType || (RouterViolationType = {}));
export const MailboxClientConfigSchema = OwnableSchema.extend({
mailbox: ZHash,
hook: HookConfigSchema.optional(),
interchainSecurityModule: IsmConfigSchema.optional(),
});
export const ForeignDeploymentConfigSchema = z.object({
foreignDeployment: z.string().optional(),
});
export const RemoteRouterDomainOrChainNameSchema = z.string().or(z.number());
export function resolveRouterMapConfig(multiProvider, routerMap) {
return Object.fromEntries(Object.entries(routerMap).map(([domainIdOrChainName, value]) => {
if (isNumeric(domainIdOrChainName)) {
return [parseInt(domainIdOrChainName), value];
}
const meta = multiProvider.getChainMetadata(domainIdOrChainName);
return [meta.domainId, value];
}));
}
export const RemoteRouterRouter = z.object({
address: z.string().startsWith('0x'),
});
export const RemoteRoutersSchema = z.record(RemoteRouterDomainOrChainNameSchema, RemoteRouterRouter);
export const RouterConfigSchema = MailboxClientConfigSchema.merge(ForeignDeploymentConfigSchema).merge(z.object({
remoteRouters: RemoteRoutersSchema.optional(),
proxyAdmin: DeployedOwnableSchema.optional(),
tokenFee: TokenFeeConfigInputSchema.optional(),
}));
const DestinationGasAmount = z.string(); // This must be a string type to match Ether's type
export const DestinationGasSchema = z.record(RemoteRouterDomainOrChainNameSchema, DestinationGasAmount);
export const GasRouterConfigSchema = RouterConfigSchema.extend({
gas: z.number().optional(),
destinationGas: DestinationGasSchema.optional(),
});
//# sourceMappingURL=types.js.map