Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Asset Whitelisting script #6008

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading