Skip to content

Commit

Permalink
rm isOwner
Browse files Browse the repository at this point in the history
  • Loading branch information
aroralanuk committed Dec 13, 2023
1 parent 50722e4 commit 3b838c8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 51 deletions.
40 changes: 0 additions & 40 deletions solidity/test/testSendReceiver.test.ts

This file was deleted.

24 changes: 18 additions & 6 deletions typescript/sdk/src/ism/HyperlaneIsmFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,22 @@ export class HyperlaneIsmFactory extends HyperlaneApp<ProxyFactoryFactories> {
mailbox,
)
: {
isOwner: false,
domainsToUnenroll: [],
domainsToEnroll: Object.keys(config.domains),
};

const signer = this.multiProvider.getSigner(destination);
const provider = this.multiProvider.getProvider(destination);
let isOwner = false;
if (existingIsmAddress) {
const owner = await DomainRoutingIsm__factory.connect(
existingIsmAddress,
provider,
).owner();
isOwner = eqAddress(await signer.getAddress(), owner);
}
// reconfiguring existing routing ISM
if (existingIsmAddress && delta.isOwner && !delta.mailbox) {
if (existingIsmAddress && isOwner && !delta.mailbox) {
const isms: ChainMap<Address> = {};
routingIsm = DomainRoutingIsm__factory.connect(
existingIsmAddress,
Expand Down Expand Up @@ -320,6 +330,9 @@ export class HyperlaneIsmFactory extends HyperlaneApp<ProxyFactoryFactories> {
(log): log is ethers.utils.LogDescription =>
!!log && log.name === 'ModuleDeployed',
);
if (dispatchLogs.length === 0) {
throw new Error('No ModuleDeployed event found');
}
const moduleAddress = dispatchLogs[0].args['module'];
routingIsm = DomainRoutingIsm__factory.connect(
moduleAddress,
Expand Down Expand Up @@ -672,7 +685,6 @@ export async function routingModuleDelta(
contracts: HyperlaneContracts<ProxyFactoryFactories>,
mailbox?: Address,
): Promise<RoutingIsmDelta> {
const signer = multiProvider.getSigner(destination);
const provider = multiProvider.getProvider(destination);
const routingIsm = DomainRoutingIsm__factory.connect(moduleAddress, provider);
const owner = await routingIsm.owner();
Expand All @@ -681,7 +693,6 @@ export async function routingModuleDelta(
);

const delta: RoutingIsmDelta = {
isOwner: eqAddress(await signer.getAddress(), owner),
domainsToUnenroll: [],
domainsToEnroll: [],
};
Expand All @@ -700,8 +711,9 @@ export async function routingModuleDelta(
);
// check for inclusion of domains in the config
for (const [origin, subConfig] of Object.entries(config.domains)) {
if (!deployedDomains.includes(origin)) delta.domainsToEnroll.push(origin);
else {
if (!deployedDomains.includes(origin)) {
delta.domainsToEnroll.push(origin);
} else {
const subModule = await routingIsm.module(
multiProvider.getDomainId(origin),
);
Expand Down
10 changes: 5 additions & 5 deletions typescript/sdk/src/ism/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ export type DeployedIsmType = {

export type DeployedIsm = ValueOf<DeployedIsmType>;

// for finding the difference between the onchain deployment and the config provided
export type RoutingIsmDelta = {
domainsToUnenroll: ChainName[];
domainsToEnroll: ChainName[];
owner?: Address;
mailbox?: Address;
isOwner: boolean;
domainsToUnenroll: ChainName[]; // new or updated isms for the domain
domainsToEnroll: ChainName[]; // isms to remove
owner?: Address; // is the owner different
mailbox?: Address; // is the mailbox different (only for fallback routing)
};

0 comments on commit 3b838c8

Please sign in to comment.