Skip to content

Commit

Permalink
fix: linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Luisfc68 committed Dec 20, 2024
1 parent 206fa50 commit d4fff91
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 15 deletions.
17 changes: 16 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default [
{ languageOptions: { globals: globals.node } },
{
ignores: [
"eslint.config.mjs",
"typechain-types/*",
"node_modules/*",
"artifacts/*",
Expand All @@ -24,5 +25,19 @@ export default [
],
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
},
},
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
];
9 changes: 7 additions & 2 deletions scripts/deployment-utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { readFileSync, writeFileSync } from "fs";
* Layout of the addresses.json file. Consist of a map of networks, each network has a map of
* contracts and the value of that contract has the structure defined in {@link DeployedContractInfo}.
*/
/* eslint-disable @typescript-eslint/consistent-indexed-object-style */
export interface DeploymentConfig {
[network: string]: {
[contract: string]: DeployedContractInfo;
};
}
/* eslint-enable @typescript-eslint/consistent-indexed-object-style */

/**
* This interface holds the information of a deployed contract in the addresses.json file.
Expand Down Expand Up @@ -44,7 +46,7 @@ const testConfig: DeploymentConfig = { [UNIT_TEST_NETWORK]: {} };
export const read: () => DeploymentConfig = () =>
Object.keys(testConfig[UNIT_TEST_NETWORK]).length > 0
? testConfig
: JSON.parse(readFileSync(ADDRESSES_FILE).toString());
: (JSON.parse(readFileSync(ADDRESSES_FILE).toString()) as DeploymentConfig);

const write = (newConfig: DeploymentConfig) => {
const oldConfig = read();
Expand Down Expand Up @@ -72,10 +74,12 @@ export const deploy: deployFunction = async (
) => {
const oldConfig = read();

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!oldConfig[network]) {
oldConfig[network] = {};
}

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!oldConfig[network][name]) {
oldConfig[network][name] = { deployed: false };
}
Expand All @@ -93,7 +97,8 @@ export const deploy: deployFunction = async (
write(oldConfig);
} else {
console.warn(
`${name} has already be deployed [address: ${oldConfig[network][name].address}]. If you want to deploy it, please set deployed attribute to false on addresses.json file.`
`${name} has already be deployed [address: ${oldConfig[network][name]
.address!}]. If you want to deploy it, please set deployed attribute to false on addresses.json file.`
);
}
return read()[network][name];
Expand Down
2 changes: 1 addition & 1 deletion scripts/deployment/deploy-lbc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function main() {
);
}

main().catch((error) => {
main().catch((error: unknown) => {
console.error(error);
process.exitCode = 1;
});
2 changes: 1 addition & 1 deletion scripts/deployment/upgrade-lbc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async function main() {
console.info("LiquidityBridgeContract proxy upgraded successfully");
}

main().catch((error) => {
main().catch((error: unknown) => {
console.error(error);
process.exitCode = 1;
});
5 changes: 3 additions & 2 deletions test/discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ describe("LiquidityBridgeContractV2 provider discovery should", () => {
for (const lp of newLps) {
lbc = lbc.connect(lp.signer);
const params: RegisterLpParams = [...REGISTER_LP_PARAMS];
params[0] = `LP account ${lp.accountIdx}`;
params[1] = `${params[1]}-account${lp.accountIdx}`;
params[0] = `LP account ${lp.accountIdx.toString()}`;
// eslint-disable-next-line @typescript-eslint/no-base-to-string
params[1] = `${params[1].toString()}-account${lp.accountIdx.toString()}`;
const registerTx = await lbc.register(...params);
await expect(registerTx).to.emit(lbc, "Register");
}
Expand Down
4 changes: 2 additions & 2 deletions test/pegin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,15 +639,15 @@ describe("LiquidityBridgeContractV2 pegin process should", () => {
const lp = fixtureResult.liquidityProviders[0];
const lbc = fixtureResult.lbc.connect(lp.signer);
const bridgeMock = fixtureResult.bridgeMock;
type testCase = {
interface testCase {
quote: QuotesV2.PeginQuoteStruct;
quoteHash: string;
signature: string;
btcRawTx: string;
pmt: string;
height: number;
refundAmount: string;
};
}
const cases: testCase[] = [
{
quote: {
Expand Down
4 changes: 2 additions & 2 deletions test/pegout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ describe("LiquidityBridgeContractV2 pegout process should", () => {
});

it("parse raw btc transaction p2pkh script", async () => {
const btcUtilsAddress = await read()[hre.network.name]["BtcUtils"];
const btcUtilsAddress = read()[hre.network.name].BtcUtils;
const BtcUtils = await ethers.getContractAt(
"BtcUtils",
btcUtilsAddress.address!
Expand Down Expand Up @@ -981,7 +981,7 @@ describe("LiquidityBridgeContractV2 pegout process should", () => {
});

it("parse btc raw transaction outputs correctly", async () => {
const btcUtilsAddress = await read()[hre.network.name]["BtcUtils"];
const btcUtilsAddress = read()[hre.network.name].BtcUtils;
const BtcUtils = await ethers.getContractAt(
"BtcUtils",
btcUtilsAddress.address!
Expand Down
4 changes: 2 additions & 2 deletions test/registration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ describe("LiquidityBridgeContractV2 registration process should", () => {
const tx = await lbc.register(...REGISTER_LP_PARAMS);
await tx.wait();

mockContract = await mockContract.connect(lpSigner);
mockContract = mockContract.connect(lpSigner);
await expect(
mockContract.callRegister(lbcAddress, { value: LP_COLLATERAL })
).to.revertedWith("LBC003");

mockContract = await mockContract.connect(notLpSigner);
mockContract = mockContract.connect(notLpSigner);
await expect(
mockContract.callRegister(lbcAddress, { value: LP_COLLATERAL })
).to.revertedWith("LBC003");
Expand Down
2 changes: 1 addition & 1 deletion test/utils/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function createBalanceUpdateAssertion(args: {
source: LiquidityBridgeContractV2 | Provider;
address: string;
message: string;
}): Promise<(balanceUpdate: bigint) => void> {
}): Promise<(balanceUpdate: bigint) => Promise<void>> {
const { source, address, message } = args;
const balanceNow = await source.getBalance(address);
return async function (balanceUpdate: BigNumberish) {
Expand Down
2 changes: 1 addition & 1 deletion test/utils/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export async function deployLbcWithProvidersFixture() {
];

for (const provider of liquidityProviders) {
lbc = await lbc.connect(provider.signer);
lbc = lbc.connect(provider.signer);
const registerTx = await lbc.register(...provider.registerParams);
await registerTx.wait();
}
Expand Down

0 comments on commit d4fff91

Please sign in to comment.