Skip to content

Commit

Permalink
Fix typescript linter execution (#442)
Browse files Browse the repository at this point in the history
* Fix typescript linter execution

* Remove --fix
  • Loading branch information
vtleonardo committed Oct 27, 2022
1 parent 84be644 commit 2db0b57
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 129 deletions.
1 change: 1 addition & 0 deletions bridge/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ module.exports = {
},
],
"node/no-unpublished-import": ["off"],
"node/no-unpublished-require": ["off"],
},
};
2 changes: 1 addition & 1 deletion bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"typechain": "hardhat typechain",
"lint-solidity": "solhint 'contracts/**/*.sol' 'test/**/*.sol'",
"lint": "eslint test/**/*.ts scripts/**/*.ts",
"lint": "eslint 'test/**/*.ts' 'scripts/**/*.ts'",
"test": "hardhat test --show-stack-traces",
"test-parallel": "npm run test -- --parallel",
"format": "prettier --write ../",
Expand Down
16 changes: 8 additions & 8 deletions bridge/scripts/generateImmutableAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ task("generate-immutable-auth-contract", "Generate contracts")
undefined
)
.setAction(async ({ input, output }, hre) => {
let contractNameSaltMap = [];
const contractNameSaltMap = [];
let immutableContract = "";
let contracts;

if (input === undefined) {
const allContracts = await getAllContracts(hre.artifacts);
let deploymentList = await getSortedDeployList(
const deploymentList = await getSortedDeployList(
allContracts,
hre.artifacts
);
Expand All @@ -37,23 +37,23 @@ task("generate-immutable-auth-contract", "Generate contracts")

for (let i = 0; i < contracts.length; i++) {
const fullyQualifiedName = contracts[i];
let contractName = fullyQualifiedName.split(":")[1];
let salt = await getSalt(contractName, hre);
const contractName = fullyQualifiedName.split(":")[1];
const salt = await getSalt(contractName, hre);
contractNameSaltMap.push([contractName, salt]);
}

immutableContract += templateImmutableFactory;
for (const contractNameSalt of contractNameSaltMap) {
let name = contractNameSalt[0];
let salt = contractNameSalt[1];
let c = new Contract(name, salt);
const name = contractNameSalt[0];
const salt = contractNameSalt[1];
const c = new Contract(name, salt);
immutableContract += templateContract(c);
}

if (output === undefined) {
output = "contracts/utils/";
} else {
checkUserDirPath(output);
await checkUserDirPath(output);
}
fs.writeFileSync(output + "ImmutableAuth.sol", immutableContract);
});
Expand Down
109 changes: 51 additions & 58 deletions bridge/scripts/lib/deployment/deploymentUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
UPGRADE_PROXY,
} from "../constants";
import { readDeploymentArgs } from "./deploymentConfigUtil";
import { ProxyData } from "./factoryStateUtil";

type Ethers = typeof import("../../../node_modules/ethers/lib/ethers") &
HardhatEthersHelpers;
Expand Down Expand Up @@ -106,8 +105,8 @@ export async function getContractDescriptor(
10
),
deployType: await getDeployType(fullyQualifiedName, hre.artifacts),
constructorArgs: constructorArgs,
initializerArgs: initializerArgs,
constructorArgs,
initializerArgs,
};
}
// function to deploy the factory
Expand Down Expand Up @@ -140,12 +139,12 @@ export async function getDeployMetaArgs(
: undefined;
return {
contractName: extractName(fullyQualifiedName),
waitConfirmation: waitConfirmation,
factoryAddress: factoryAddress,
initCallData: initCallData,
constructorArgs: constructorArgs,
outputFolder: outputFolder,
verify: verify,
waitConfirmation,
factoryAddress,
initCallData,
constructorArgs,
outputFolder,
verify,
};
}
export async function getFactoryDeploymentArgs(
Expand Down Expand Up @@ -186,12 +185,12 @@ export async function getDeployUpgradeableProxyArgs(
: undefined;
return {
contractName: extractName(fullyQualifiedName),
waitConfirmation: waitConfirmation,
factoryAddress: factoryAddress,
initCallData: initCallData,
constructorArgs: constructorArgs,
outputFolder: outputFolder,
verify: verify,
waitConfirmation,
factoryAddress,
initCallData,
constructorArgs,
outputFolder,
verify,
};
}

Expand Down Expand Up @@ -411,7 +410,7 @@ export async function getDeployUpgradeableMultiCallArgs(
const nonce = await hre.ethers.provider.getTransactionCount(factory.address);
const logicAddress = hre.ethers.utils.getContractAddress({
from: factory.address,
nonce: nonce,
nonce,
});

// encode deploy create
Expand Down Expand Up @@ -449,55 +448,49 @@ export async function getDeployUpgradeableMultiCallArgs(
export async function deployContractsMulticall(
contracts: ContractDescriptor[],
hre: HardhatRuntimeEnvironment,
factoryAddr: string,
txCount: number,
inputFolder?: string,
outputFolder?: string
factoryAddr: string
) {
const factoryBase = await hre.ethers.getContractFactory(ALICENET_FACTORY);
const factory = factoryBase.attach(factoryAddr);
let proxyData: ProxyData;
let multiCallArgsArray = Array();
const multiCallArgsArray = [];

for (let i = 0; i < contracts.length; i++) {
const contract = contracts[i];
if (true) {
const deployType = contract.deployType;
switch (deployType) {
case UPGRADEABLE_DEPLOYMENT: {
let multiCallArgsArray = Array();
let [deployCreate, deployProxy, upgradeProxy] =
await getDeployUpgradeableMultiCallArgs(
contract,
hre,
factory.address
);
multiCallArgsArray.push(deployCreate);
multiCallArgsArray.push(deployProxy);
multiCallArgsArray.push(upgradeProxy);
const txResponse = await factory.multiCall(multiCallArgsArray);
const receipt = await txResponse.wait();
const address = getEventVar(receipt, DEPLOYED_PROXY, CONTRACT_ADDR);
console.log(contract.name, "deployed at:", address);
break;
}
case ONLY_PROXY: {
const name = extractName(contract.fullyQualifiedName);
const salt: BytesLike = await getBytes32Salt(
name,
hre.artifacts,
hre.ethers

const deployType = contract.deployType;
switch (deployType) {
case UPGRADEABLE_DEPLOYMENT: {
const [deployCreate, deployProxy, upgradeProxy] =
await getDeployUpgradeableMultiCallArgs(
contract,
hre,
factory.address
);
const factoryAddress = factory.address;
proxyData = await hre.run(TASK_DEPLOY_PROXY, {
factoryAddress,
salt,
});
break;
}
default: {
break;
}
multiCallArgsArray.push(deployCreate);
multiCallArgsArray.push(deployProxy);
multiCallArgsArray.push(upgradeProxy);
const txResponse = await factory.multiCall(multiCallArgsArray);
const receipt = await txResponse.wait();
const address = getEventVar(receipt, DEPLOYED_PROXY, CONTRACT_ADDR);
console.log(contract.name, "deployed at:", address);
break;
}
case ONLY_PROXY: {
const name = extractName(contract.fullyQualifiedName);
const salt: BytesLike = await getBytes32Salt(
name,
hre.artifacts,
hre.ethers
);
const factoryAddress = factory.address;
await hre.run(TASK_DEPLOY_PROXY, {
factoryAddress,
salt,
});
break;
}
default: {
break;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions bridge/scripts/lib/deployment/factoryStateUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ export async function updateList(
export async function getATokenMinterAddress(network: string) {
// fetch whats in the factory config file
const config = await readFactoryState(FACTORY_STATE_PATH);
let proxies = config[network].proxies;
const proxies = config[network].proxies;
for (let i = 0; i < proxies.length; i++) {
let name = proxies[i].logicName;
const name = proxies[i].logicName;
if (name === "ATokenMinter") {
return proxies[i].proxyAddress;
}
Expand All @@ -175,9 +175,9 @@ export async function getATokenMinterAddress(network: string) {

export async function getBTokenAddress(network: string) {
const config = await readFactoryState(FACTORY_STATE_PATH);
let staticContracts = config[network].staticContracts;
const staticContracts = config[network].staticContracts;
for (let i = 0; i < staticContracts.length; i++) {
let name = staticContracts[i].templateName;
const name = staticContracts[i].templateName;
if (name === "BToken") {
return staticContracts[i].metaAddress;
}
Expand All @@ -186,9 +186,9 @@ export async function getBTokenAddress(network: string) {

export async function getATokenAddress(network: string) {
const config = await readFactoryState(FACTORY_STATE_PATH);
let staticContracts = config[network].staticContracts;
const staticContracts = config[network].staticContracts;
for (let i = 0; i < staticContracts.length; i++) {
let name = staticContracts[i].templateName;
const name = staticContracts[i].templateName;
if (name === "AToken") {
return staticContracts[i].metaAddress;
}
Expand Down
41 changes: 22 additions & 19 deletions bridge/test/publicStaking/business-logic/accumulator-slush.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("PublicStaking: Accumulator and slush invariance", async () => {
credits += 1000n;
for (let i = 0; i < numberUsers; i++) {
// Perform slushSkim
let deltaAccum = ethStateSlush / totalShares;
const deltaAccum = ethStateSlush / totalShares;
ethStateSlush -= deltaAccum * totalShares;
ethStateAccum += deltaAccum;
// compute payout
Expand All @@ -74,7 +74,8 @@ describe("PublicStaking: Accumulator and slush invariance", async () => {
[tokensID[i]]
);
// compute payout
let diffAccum = ethStateAccum - userPosition.accumulatorEth.toBigInt();
const diffAccum =
ethStateAccum - userPosition.accumulatorEth.toBigInt();
let payoutEst = diffAccum * sharesPerUser;
let payoutRem = payoutEst;
payoutEst /= scaleFactor;
Expand Down Expand Up @@ -120,7 +121,7 @@ describe("PublicStaking: Accumulator and slush invariance", async () => {
);
for (let i = 0; i < numberUsers; i++) {
// Perform slushSkim
let deltaAccum = ethStateSlush / totalShares;
const deltaAccum = ethStateSlush / totalShares;
ethStateSlush -= deltaAccum * totalShares;
ethStateAccum += deltaAccum;
// compute payout
Expand All @@ -131,7 +132,7 @@ describe("PublicStaking: Accumulator and slush invariance", async () => {
[tokensID[i]]
);
// compute payout
let diffAccum = ethStateAccum - userPosition.accumulatorEth.toBigInt();
const diffAccum = ethStateAccum - userPosition.accumulatorEth.toBigInt();
let payoutEst = diffAccum * sharesPerUser;
let payoutRem = payoutEst;
payoutEst /= scaleFactor;
Expand Down Expand Up @@ -198,20 +199,21 @@ describe("PublicStaking: Accumulator and slush invariance", async () => {
ethStateSlush += 7n * scaleFactor;
for (let i = 0; i < numberUsers; i++) {
// Prep for collect
let deltaAccum = ethStateSlush / totalShares;
const deltaAccum = ethStateSlush / totalShares;
ethStateSlush -= deltaAccum * totalShares;
ethStateAccum += deltaAccum;
// get position info
let [userPosition] = await callFunctionAndGetReturnValues(
const [userPosition] = await callFunctionAndGetReturnValues(
fixture.publicStaking,
"getPosition",
users[i] as SignerWithAddress,
[tokensID[i]]
);
// compute payout eth
let diffAccum = ethStateAccum - userPosition.accumulatorEth.toBigInt();
const diffAccum =
ethStateAccum - userPosition.accumulatorEth.toBigInt();
let payoutEst = diffAccum * userPosition.shares.toBigInt();
if (totalShares == userPosition.shares.toBigInt()) {
if (totalShares === userPosition.shares.toBigInt()) {
payoutEst += ethStateSlush;
ethStateSlush = 0n;
}
Expand Down Expand Up @@ -257,20 +259,21 @@ describe("PublicStaking: Accumulator and slush invariance", async () => {

for (let i = 0; i < numberUsers; i++) {
// Prep for collect
let deltaAccum = ethStateSlush / totalShares;
const deltaAccum = ethStateSlush / totalShares;
ethStateSlush -= deltaAccum * totalShares;
ethStateAccum += deltaAccum;
// get position info
let [userPosition] = await callFunctionAndGetReturnValues(
const [userPosition] = await callFunctionAndGetReturnValues(
fixture.publicStaking,
"getPosition",
users[i] as SignerWithAddress,
[tokensID[i]]
);
// compute payout eth
let diffAccum = ethStateAccum - userPosition.accumulatorEth.toBigInt();
const diffAccum =
ethStateAccum - userPosition.accumulatorEth.toBigInt();
let payoutEst = diffAccum * userPosition.shares.toBigInt();
if (totalShares == userPosition.shares.toBigInt()) {
if (totalShares === userPosition.shares.toBigInt()) {
payoutEst += ethStateSlush;
ethStateSlush = 0n;
}
Expand Down Expand Up @@ -320,7 +323,7 @@ describe("PublicStaking: Accumulator and slush invariance", async () => {
// compute payout eth
let diffAccum = ethStateAccum - userPosition.accumulatorEth.toBigInt();
let payoutEst = diffAccum * userPosition.shares.toBigInt();
if (totalShares == userPosition.shares.toBigInt()) {
if (totalShares === userPosition.shares.toBigInt()) {
payoutEst += ethStateSlush;
ethStateSlush = 0n;
}
Expand All @@ -347,7 +350,7 @@ describe("PublicStaking: Accumulator and slush invariance", async () => {
// compute payout eth
diffAccum = ethStateAccum - userPosition.accumulatorEth.toBigInt();
payoutEst = diffAccum * userPosition.shares.toBigInt();
if (totalShares == userPosition.shares.toBigInt()) {
if (totalShares === userPosition.shares.toBigInt()) {
payoutEst += ethStateSlush;
ethStateSlush = 0n;
}
Expand Down Expand Up @@ -380,7 +383,7 @@ describe("PublicStaking: Accumulator and slush invariance", async () => {
// compute payout eth
diffAccum = ethStateAccum - userPosition.accumulatorEth.toBigInt();
payoutEst = diffAccum * userPosition.shares.toBigInt();
if (totalShares == userPosition.shares.toBigInt()) {
if (totalShares === userPosition.shares.toBigInt()) {
payoutEst += ethStateSlush;
ethStateSlush = 0n;
}
Expand All @@ -400,20 +403,20 @@ describe("PublicStaking: Accumulator and slush invariance", async () => {
credits += depositAmount;
for (let i = 0; i < numberUsers; i++) {
// Prep for collect
let deltaAccum = ethStateSlush / totalShares;
const deltaAccum = ethStateSlush / totalShares;
ethStateSlush -= deltaAccum * totalShares;
ethStateAccum += deltaAccum;
// get position info
let [userPosition] = await callFunctionAndGetReturnValues(
const [userPosition] = await callFunctionAndGetReturnValues(
fixture.publicStaking,
"getPosition",
users[i] as SignerWithAddress,
[tokensID[i]]
);
// compute payout eth
let diffAccum = ethStateAccum - userPosition.accumulatorEth.toBigInt();
const diffAccum = ethStateAccum - userPosition.accumulatorEth.toBigInt();
let payoutEst = diffAccum * userPosition.shares.toBigInt();
if (totalShares == userPosition.shares.toBigInt()) {
if (totalShares === userPosition.shares.toBigInt()) {
payoutEst += ethStateSlush;
ethStateSlush = 0n;
}
Expand Down
Loading

0 comments on commit 2db0b57

Please sign in to comment.