Skip to content

Commit

Permalink
fix: added pseudo canonical domain
Browse files Browse the repository at this point in the history
  • Loading branch information
prathmeshkhandelwal1 committed Apr 9, 2024
1 parent 2a25d9e commit 2e582c7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 24 deletions.
45 changes: 24 additions & 21 deletions packages/deployments/contracts/src/cli/init/helpers/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,31 @@ export const setupAsset = async (args: {
throw new Error(`Unable to find canonical decimals in config for ${asset.name}`);
}

await updateIfNeeded({
apply,
deployment: home.deployments.Connext,
desired: asset.canonical.address,
read: { method: "canonicalToAdopted(bytes32)", args: [key] },
auth: [
{ method: "owner", eval: (ret: string) => ret.toLowerCase() === home.signerAddress },
{ method: "queryRole", args: [home.signerAddress], eval: (ret) => ret === 3 },
],
write: {
method: "setupAsset",
args: [
[canonical.domain, canonical.id],
canonicalDecimals,
tokenName,
tokenSymbol,
asset.canonical.address,
constants.AddressZero,
asset.canonical.cap ?? "0", // 0-cap allowed on testnet only
// Note: bypassing in case of pseudo canonical domain
if (home.domain !== "11111") {
await updateIfNeeded({
apply,
deployment: home.deployments.Connext,
desired: asset.canonical.address,
read: { method: "canonicalToAdopted(bytes32)", args: [key] },
auth: [
{ method: "owner", eval: (ret: string) => ret.toLowerCase() === home.signerAddress },
{ method: "queryRole", args: [home.signerAddress], eval: (ret) => ret === 3 },
],
},
});
write: {
method: "setupAsset",
args: [
[canonical.domain, canonical.id],
canonicalDecimals,
tokenName,
tokenSymbol,
asset.canonical.address,
constants.AddressZero,
asset.canonical.cap ?? "0", // 0-cap allowed on testnet only
],
},
});
}

// Set up all the representational assets on their respective domains.
for (const [domain, representation] of Object.entries(asset.representations)) {
Expand Down
19 changes: 16 additions & 3 deletions packages/deployments/contracts/src/cli/init/init.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as fs from "fs";

import { providers, Wallet, utils, constants } from "ethers";
import { providers, Wallet, utils, constants, ethers } from "ethers";
import * as zk from "zksync-ethers";
import commandLineArgs from "command-line-args";
import { ajv, domainToChainId, getGelatoRelayerAddress, getChainData } from "@connext/nxtp-utils";
import { ajv, domainToChainId, getGelatoRelayerAddress, getChainData, mkAddress } from "@connext/nxtp-utils";
import { HttpNetworkUserConfig } from "hardhat/types";

import { canonizeId } from "../../domain";
Expand All @@ -21,6 +21,7 @@ import {
SpokeMessagingDeployments,
setupAsset,
setupMessaging,
DomainDeployments,
} from "./helpers";
import { DEFAULT_INIT_CONFIG } from "./config";

Expand Down Expand Up @@ -164,6 +165,7 @@ export const sanitizeAndInit = async () => {
}
}

let deployer;
// Get deployments for each domain if not specified in the config.
for (const domain of domains) {
const chainId = domainToChainId(Number(domain));
Expand All @@ -177,7 +179,7 @@ export const sanitizeAndInit = async () => {
}

// Convert deployer from mnemonic to Wallet.
let deployer;

if (privateKey) {
deployer = chainConfig.zksync ? new zk.Wallet(privateKey) : new Wallet(privateKey);
} else {
Expand Down Expand Up @@ -210,6 +212,17 @@ export const sanitizeAndInit = async () => {
});
}

// adding pseudo domain config in networks

networks.push({
signerAddress: mkAddress("pseudo"),
chain: "11111",
domain: "11111",
rpc: new providers.JsonRpcProvider("https://dummmy.com"),
deployments: {} as DomainDeployments,
relayerFeeVault: mkAddress("pseudo"),
});

const sanitized = {
hub: hubDomain,
networks,
Expand Down

0 comments on commit 2e582c7

Please sign in to comment.