Skip to content

Commit

Permalink
chore: reverted & removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
ljankovic-txfusion committed Oct 9, 2024
1 parent 4273265 commit d0fb3c8
Show file tree
Hide file tree
Showing 45 changed files with 291 additions and 607 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[submodule "solidity/lib/fx-portal"]
path = solidity/lib/fx-portal
url = https://github.com/0xPolygon/fx-portal
[submodule "solidity/solidity/lib/foundry-zksync"]
path = solidity/solidity/lib/foundry-zksync
url = https://github.com/matter-labs/foundry-zksync
40 changes: 6 additions & 34 deletions solidity/generate-artifact-exports.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@ import { fileURLToPath } from 'url';
const cwd = process.cwd();

const zksyncArtifacts = glob(cwd, [
`!./artifacts-zk/contracts/interfaces/**/*`,
`!./artifacts-zk/contracts/**/*.dbg.json`,
`!./artifacts-zk/@openzeppelin/**/*.dbg.json`,
`./artifacts-zk/contracts/**/+([a-zA-Z0-9_]).json`,
`./artifacts-zk/@openzeppelin/**/+([a-zA-Z0-9_]).json`,
]);
const evmArtifacts = glob(cwd, [
`!./artifacts/contracts/interfaces/**/*`,
`!./artifacts/contracts/**/*.dbg.json`,
`!./artifacts/@openzeppelin/**/*.dbg.json`,
`./artifacts/contracts/**/+([a-zA-Z0-9_]).json`,
`./artifacts/@openzeppelin/**/+([a-zA-Z0-9_]).json`,
]);

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand All @@ -28,41 +20,25 @@ const outputFile = join(__dirname, 'types/zksync/artifacts/index.ts');
const outputDir = join(__dirname, 'types/zksync/artifacts');

const zkSyncFileNames = new Set();
const evmFileNames = new Set();

let zkSyncArtifactMap = {};

// Start building the TypeScript export string
let exportStatements = zksyncArtifacts
.map((file) => {
let fileName = `${basename(file, '.json')}__artifact`;

const fileContent = readFileSync(file, 'utf-8');
const jsonObject = JSON.parse(fileContent);
const contractName = jsonObject.contractName;
let fileName = `${basename(file, '.json')}__artifact`;

if (zkSyncFileNames.has(fileName)) {
return;
}
zkSyncFileNames.add(fileName);

// Create a TypeScript object export statement
return `export const ${fileName} = ${JSON.stringify(
jsonObject,
null,
2,
)} as const;`;
})
.join('\n\n');

exportStatements += evmArtifacts
.map((file) => {
let fileName = `${basename(file, '.json')}__evm_artifact`;
// Add to artifact map
zkSyncArtifactMap[contractName] = fileName;

const fileContent = readFileSync(file, 'utf-8');
const jsonObject = JSON.parse(fileContent);

if (evmFileNames.has(fileName)) {
return;
}
evmFileNames.add(fileName);
// Create a TypeScript object export statement
return `export const ${fileName} = ${JSON.stringify(
jsonObject,
Expand All @@ -76,10 +52,6 @@ exportStatements += `\n\nexport const zksyncArtifacts : any[] = [\n${Array.from(
zkSyncFileNames,
).join(',\n')}\n] as const;`;

exportStatements += `\n\nexport const evmArtifacts: any[] = [\n${Array.from(
evmFileNames,
).join(',\n')}\n] as const;`;

if (!existsSync(outputDir)) {
mkdirSync(outputDir, { recursive: true });
}
Expand Down
2 changes: 1 addition & 1 deletion solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
],
"license": "Apache-2.0",
"scripts": {
"build": "yarn hardhat-esm compile && yarn hardhat-zk compile && tsc && ts-node generate-artifact-exports.mjs && ./exportBuildArtifact.sh",
"build": "yarn hardhat-esm compile && yarn hardhat-zk compile && ts-node generate-artifact-exports.mjs && tsc && ./exportBuildArtifact.sh",
"lint": "solhint contracts/**/*.sol",
"clean": "yarn hardhat-esm clean && yarn hardhat-zk clean && rm -rf ./dist ./cache ./cache-zk ./types ./coverage ./out ./forge-cache ./fixtures",
"coverage": "yarn fixtures && ./coverage.sh",
Expand Down
18 changes: 4 additions & 14 deletions solidity/test/merkle.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Deployer } from '@matterlabs/hardhat-zksync-deploy';
import { expect } from 'chai';
import { utils } from 'ethers';
import hre from 'hardhat';
import { Provider, Wallet } from 'zksync-ethers';

import merkleTestCases from '../../vectors/merkle.json' assert { type: 'json' };
import { TestMerkle, TestMerkle__factory } from '../types';
Expand All @@ -14,20 +11,13 @@ describe('Merkle', async () => {
const { testName, leaves, expectedRoot, proofs } = testCase;

describe(testName, async () => {
let merkle: any;
let merkle: TestMerkle;

before(async () => {
// const signer = await getSigner();
const signer = await getSigner();

const provider = new Provider('http://127.0.0.1:8011');

const deployerWallet = new Wallet(
'0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e',
provider,
);
const deployer = new Deployer(hre, deployerWallet);
const artifact = await deployer.loadArtifact('TestMerkle');
merkle = await deployer.deploy(artifact, []);
const merkleFactory = new TestMerkle__factory(signer);
merkle = await merkleFactory.deploy();

//insert the leaves
for (const leaf of leaves) {
Expand Down
22 changes: 7 additions & 15 deletions solidity/test/message.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Deployer } from '@matterlabs/hardhat-zksync-deploy';
import { expect } from 'chai';
import { utils } from 'ethers';
import hre from 'hardhat';
import { Provider, Wallet } from 'zksync-ethers';

import {
addressToBytes32,
Expand All @@ -20,23 +17,18 @@ const localDomain = 2000;
const nonce = 11;

describe('Message', async () => {
let messageLib: any;
let messageLib: TestMessage;
let version: number;

before(async () => {
const provider = new Provider('http://127.0.0.1:8011');
const signer = await getSigner();

const deployerWallet = new Wallet(
'0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e',
provider,
);
const deployer = new Deployer(hre, deployerWallet);
let artifact = await deployer.loadArtifact('TestMessage');
messageLib = await deployer.deploy(artifact, []);

artifact = await deployer.loadArtifact('Mailbox');
const mailbox = await deployer.deploy(artifact, [localDomain]);
const Message = new TestMessage__factory(signer);
messageLib = await Message.deploy();

// For consistency with the Mailbox version
const Mailbox = new Mailbox__factory(signer);
const mailbox = await Mailbox.deploy(localDomain);
version = await mailbox.VERSION();
});

Expand Down
27 changes: 6 additions & 21 deletions solidity/test/mockMailbox.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Deployer } from '@matterlabs/hardhat-zksync-deploy';
import { expect } from 'chai';
import { utils } from 'ethers';
import hre from 'hardhat';
import { Provider, Wallet } from 'zksync-ethers';

import { addressToBytes32 } from '@hyperlane-xyz/utils';

Expand All @@ -15,28 +12,16 @@ const DESTINATION_DOMAIN = 2000;

describe('MockMailbox', function () {
it('should be able to mock sending and receiving a message', async function () {
const provider = new Provider('http://127.0.0.1:8011');

const deployerWallet = new Wallet(
'0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e',
provider,
);

const deployer = new Deployer(hre, deployerWallet);

let artifact = await deployer.loadArtifact('MockMailbox');
const originMailbox = await deployer.deploy(artifact, [ORIGIN_DOMAIN]);
const destinationMailbox = await deployer.deploy(artifact, [
DESTINATION_DOMAIN,
]);

const signer = await getSigner();
const mailboxFactory = new MockMailbox__factory(signer);
const testRecipientFactory = new TestRecipient__factory(signer);
const originMailbox = await mailboxFactory.deploy(ORIGIN_DOMAIN);
const destinationMailbox = await mailboxFactory.deploy(DESTINATION_DOMAIN);
await originMailbox.addRemoteMailbox(
DESTINATION_DOMAIN,
destinationMailbox.address,
);

artifact = await deployer.loadArtifact('TestRecipient');
const recipient = await deployer.deploy(artifact, []);
const recipient = await testRecipientFactory.deploy();

const body = utils.toUtf8Bytes('This is a test message');

Expand Down
20 changes: 5 additions & 15 deletions solidity/test/testrecipient.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Deployer } from '@matterlabs/hardhat-zksync-deploy';
import { expect } from 'chai';
import { utils } from 'ethers';
import hre from 'hardhat';
import { Provider, Wallet } from 'zksync-ethers';

import { addressToBytes32 } from '@hyperlane-xyz/utils';

Expand All @@ -12,27 +9,20 @@ import { getSigner } from './signer';

const testData = utils.hexlify(utils.toUtf8Bytes('test'));
describe('TestRecipient', () => {
let recipient: any;
let recipient: TestRecipient;
let signerAddress: string;

before(async () => {
const provider = new Provider('http://127.0.0.1:8011');

const deployerWallet = new Wallet(
'0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e',
provider,
);
const deployer = new Deployer(hre, deployerWallet);

let artifact = await deployer.loadArtifact('TestRecipient');
recipient = await deployer.deploy(artifact, []);
const signer = await getSigner();
signerAddress = await signer.getAddress();
const recipientFactory = new TestRecipient__factory(signer);
recipient = await recipientFactory.deploy();
});

it('handles a message', async () => {
await expect(
recipient.handle(0, addressToBytes32(signerAddress), testData),
).to.emit(recipient, 'ReceivedMessage');

expect(await recipient.lastSender()).to.eql(
addressToBytes32(signerAddress),
);
Expand Down
14 changes: 12 additions & 2 deletions typescript/cli/src/config/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,18 @@ export function readWarpCoreConfig(filePath: string): WarpCoreConfig {
*/
function createDefaultWarpIsmConfig(owner: Address): IsmConfig {
return {
type: IsmType.STORAGE_MERKLE_ROOT_MULTISIG,
validators: [owner],
type: IsmType.AGGREGATION,
modules: [
{
type: IsmType.TRUSTED_RELAYER,
relayer: owner,
},
{
type: IsmType.FALLBACK_ROUTING,
domains: {},
owner,
},
],
threshold: 1,
};
}
9 changes: 3 additions & 6 deletions typescript/cli/src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import {
import { isHttpsUrl, isNullish, rootLogger } from '@hyperlane-xyz/utils';

import { isSignCommand } from '../commands/signCommands.js';
import {
// forkNetworkToMultiProvider,
verifyAnvil,
} from '../deploy/dry-run.js';
import { forkNetworkToMultiProvider, verifyAnvil } from '../deploy/dry-run.js';
import { logBlue } from '../logger.js';
import { runSingleChainSelectionStep } from '../utils/chains.js';
import { detectAndConfirmOrPrompt } from '../utils/input.js';
Expand Down Expand Up @@ -110,13 +107,13 @@ export async function getDryRunContext(
await verifyAnvil();

let multiProvider = await getMultiProvider(registry);
// multiProvider = await forkNetworkToMultiProvider(multiProvider, chain);
multiProvider = await forkNetworkToMultiProvider(multiProvider, chain);
const { impersonatedKey, impersonatedSigner } = await getImpersonatedSigner({
fromAddress,
key,
skipConfirmation,
});
// multiProvider.setSharedSigner(impersonatedSigner);
multiProvider.setSharedSigner(impersonatedSigner);

return {
registry,
Expand Down
27 changes: 0 additions & 27 deletions typescript/sdk/src/app/typechain.test.ts

This file was deleted.

25 changes: 10 additions & 15 deletions typescript/sdk/src/consts/testChains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ export const test1: ChainMetadata = {
blocks: {
confirmations: 1,
estimateBlockTime: 3,
reorgPeriod: 1,
reorgPeriod: 0,
},
chainId: 260,
chainId: 9913371,
displayName: 'Test 1',
domainId: 260,
domainId: 9913371,
isTestnet: true,
name: 'test1',
nativeToken: { decimals: 18, name: 'Ether', symbol: 'ETH' },
protocol: ProtocolType.Ethereum,
rpcUrls: [{ http: 'http://127.0.0.1:8011' }],
rpcUrls: [{ http: 'http://127.0.0.1:8545' }],
};

export const test2: ChainMetadata = {
Expand All @@ -47,9 +47,9 @@ export const test2: ChainMetadata = {
estimateBlockTime: 3,
reorgPeriod: 1,
},
chainId: 260,
chainId: 9913372,
displayName: 'Test 2',
domainId: 260,
domainId: 9913372,
name: 'test2',
};

Expand All @@ -60,22 +60,17 @@ export const test3: ChainMetadata = {
estimateBlockTime: 3,
reorgPeriod: 2,
},
chainId: 260,
chainId: 9913373,
displayName: 'Test 3',
domainId: 260,
domainId: 9913373,
name: 'test3',
};

export const test4: ChainMetadata = {
...test1,
blocks: {
confirmations: 1,
estimateBlockTime: 3,
reorgPeriod: 2,
},
chainId: 260,
chainId: 31337,
displayName: 'Test 4',
domainId: 260,
domainId: 31337,
name: 'test4',
};

Expand Down
Loading

0 comments on commit d0fb3c8

Please sign in to comment.