Skip to content

Commit

Permalink
Merge pull request #309 from api3dao/bump-eslint-plugin-commons
Browse files Browse the repository at this point in the history
Bump eslint-plugin-commons
  • Loading branch information
bbenligiray authored Dec 31, 2024
2 parents 2418d71 + 4923ecc commit 79cadc5
Show file tree
Hide file tree
Showing 13 changed files with 2,185 additions and 783 deletions.
3 changes: 2 additions & 1 deletion deploy/1_deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import {
import * as managerMultisigMetadata from '../data/manager-multisig-metadata.json';
import type { Api3ReaderProxyV1Factory, OwnableCallForwarder } from '../src/index';

const MAXIMUM_SUBSCRIPTION_QUEUE_LENGTH = 10;

module.exports = async () => {
const { deploy, log } = deployments;
const [deployer] = await ethers.getSigners();
const MAXIMUM_SUBSCRIPTION_QUEUE_LENGTH = 10;

if (chainsSupportedByManagerMultisig.includes(network.name)) {
const gnosisSafeWithoutProxy = await deployments.get('GnosisSafeWithoutProxy').catch(async () => {
Expand Down
6 changes: 3 additions & 3 deletions deploy/2_update_beacon_set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { deployments, ethers, network } from 'hardhat';
import { chainsSupportedByDapis } from '../data/chain-support.json';
import { Api3ServerV1__factory } from '../src/index';

const EXPECTED_DEPLOYER_ADDRESS = ethers.getAddress('0x07b589f06bD0A5324c4E2376d66d2F4F25921DE1');
const BEACON_SET_BEACON_COUNT = 7;

async function signData(
deployer: HardhatEthersSigner,
templateId: BytesLike,
Expand Down Expand Up @@ -42,9 +45,6 @@ module.exports = async () => {
// If the first signer returned by ethers is the expected deployer address, it will do both (1) and (2).
// Otherwise, it will only do (1). In both cases, (1) is done using hardcoded signatures by the expected
// deployer address.
const EXPECTED_DEPLOYER_ADDRESS = ethers.getAddress('0x07b589f06bD0A5324c4E2376d66d2F4F25921DE1');
const BEACON_SET_BEACON_COUNT = 7;

if (!chainsSupportedByDapis.includes(network.name)) {
log(`Skipping Beacon set update for ${network.name}`);
return;
Expand Down
6 changes: 3 additions & 3 deletions deploy/3_verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
} from '../data/chain-support.json';
import { Api3ReaderProxyV1__factory, ERC1967Proxy__factory } from '../src/index';

module.exports = async () => {
const EXPECTED_DEPLOYER_ADDRESS = ethers.getAddress('0x07b589f06bD0A5324c4E2376d66d2F4F25921DE1');
const MAXIMUM_SUBSCRIPTION_QUEUE_LENGTH = 10;
const EXPECTED_DEPLOYER_ADDRESS = ethers.getAddress('0x07b589f06bD0A5324c4E2376d66d2F4F25921DE1');
const MAXIMUM_SUBSCRIPTION_QUEUE_LENGTH = 10;

module.exports = async () => {
if (chainsSupportedByManagerMultisig.includes(network.name)) {
const GnosisSafeWithoutProxy = await deployments.get('GnosisSafeWithoutProxy');
await run('verify:verify', {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"@api3/chains": "^11.4.0",
"@api3/eslint-plugin-commons": "^1.0.1",
"@api3/eslint-plugin-commons": "^3.0.0",
"@api3/promise-utils": "^0.4.0",
"@changesets/cli": "^2.27.10",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.8",
Expand Down
2,152 changes: 1,782 additions & 370 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

688 changes: 339 additions & 349 deletions scripts/validate-deployments.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions test-extended/api3-server-v1/Api3MarketV2.sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { ethers } from 'hardhat';

import { encodeUpdateParameters, updateBeaconSet } from '../../test/test-utils';

describe('Api3MarketV2', function () {
const MAXIMUM_SUBSCRIPTION_QUEUE_LENGTH = 5;
const MAXIMUM_SUBSCRIPTION_QUEUE_LENGTH = 5;

describe('Api3MarketV2', function () {
async function deploy() {
const roleNames = ['deployer', 'api3ServerV1Manager', 'owner', 'randomPerson'];
const accounts = await ethers.getSigners();
Expand Down
5 changes: 3 additions & 2 deletions test/access/GnosisSafeWithoutProxy.sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import type { AddressLike, BigNumberish, BytesLike, HDNodeWallet } from 'ethers'
import { ethers } from 'hardhat';
import type { GnosisSafeWithoutProxy } from 'typechain-types';

// Similar to https://github.com/safe-global/safe-smart-account/blob/v1.3.0/contracts/handler/CompatibilityFallbackHandler.sol#L74
const SENTINEL_MODULES = `0x${'1'.padStart(40, '0')}`;

describe('GnosisSafeWithoutProxy', function () {
const OperationEnum = Object.freeze({ Call: 0, DelegateCall: 1 });

Expand Down Expand Up @@ -110,8 +113,6 @@ describe('GnosisSafeWithoutProxy', function () {
1
)
).to.equal(ethers.ZeroHash);
// Similar to https://github.com/safe-global/safe-smart-account/blob/v1.3.0/contracts/handler/CompatibilityFallbackHandler.sol#L74
const SENTINEL_MODULES = `0x${'1'.padStart(40, '0')}`;
expect(await gnosisSafeWithoutProxy.getModulesPaginated(SENTINEL_MODULES, 10)).to.deep.equal([
[],
SENTINEL_MODULES,
Expand Down
10 changes: 5 additions & 5 deletions test/access/HashRegistry.sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { expect } from 'chai';
import type { BytesLike, HDNodeWallet } from 'ethers';
import { ethers } from 'hardhat';

const SIGNATURE_DELEGATION_HASH_TYPE = ethers.solidityPackedKeccak256(
['string'],
['HashRegistry signature delegation']
);

export async function signHash(
signers: HDNodeWallet[],
hashType: BytesLike,
Expand All @@ -21,11 +26,6 @@ export async function signHash(
}

describe('HashRegistry', function () {
const SIGNATURE_DELEGATION_HASH_TYPE = ethers.solidityPackedKeccak256(
['string'],
['HashRegistry signature delegation']
);

async function signDelegation(
signers: HDNodeWallet[],
delegates: HDNodeWallet[],
Expand Down
8 changes: 4 additions & 4 deletions test/api3-server-v1/AirseekerRegistry.sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import {
updateBeaconSet,
} from '../test-utils';

const MAXIMUM_BEACON_COUNT_IN_SET = 21;
const MAXIMUM_UPDATE_PARAMETERS_LENGTH = 1024;
const MAXIMUM_SIGNED_API_URL_LENGTH = 256;

async function registerBeaconSet(airseekerRegistry: AirseekerRegistry, feedName: string, airnodes: HDNodeWallet[]) {
const beacons = airnodes
.map((airnode) => {
Expand All @@ -34,10 +38,6 @@ async function registerBeaconSet(airseekerRegistry: AirseekerRegistry, feedName:
}

describe('AirseekerRegistry', function () {
const MAXIMUM_BEACON_COUNT_IN_SET = 21;
const MAXIMUM_UPDATE_PARAMETERS_LENGTH = 1024;
const MAXIMUM_SIGNED_API_URL_LENGTH = 256;

async function deploy() {
const roleNames = ['deployer', 'api3ServerV1Manager', 'owner', 'randomPerson'];
const accounts = await ethers.getSigners();
Expand Down
29 changes: 13 additions & 16 deletions test/api3-server-v1/Api3MarketV2.sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@ import { type Api3MarketV2 } from '../../src/index';
import { signHash } from '../access/HashRegistry.sol';
import { updateBeacon, updateBeaconSet, readBeacons, encodeUpdateParameters } from '../test-utils';

describe('Api3MarketV2', function () {
const MAXIMUM_SUBSCRIPTION_QUEUE_LENGTH = 5;
const DAPI_MANAGEMENT_MERKLE_ROOT_HASH_TYPE = ethers.solidityPackedKeccak256(
['string'],
['dAPI management Merkle root']
);
const DAPI_PRICING_MERKLE_ROOT_HASH_TYPE = ethers.solidityPackedKeccak256(['string'], ['dAPI pricing Merkle root']);
const SIGNED_API_URL_MERKLE_ROOT_HASH_TYPE = ethers.solidityPackedKeccak256(
['string'],
['Signed API URL Merkle root']
);
const SIGNATURE_DELEGATION_HASH_TYPE = ethers.solidityPackedKeccak256(
['string'],
['Api3MarketV2 signature delegation']
);
const MAXIMUM_DAPI_UPDATE_AGE = 24 * 60 * 60;
const MAXIMUM_SUBSCRIPTION_QUEUE_LENGTH = 5;
const DAPI_MANAGEMENT_MERKLE_ROOT_HASH_TYPE = ethers.solidityPackedKeccak256(
['string'],
['dAPI management Merkle root']
);
const DAPI_PRICING_MERKLE_ROOT_HASH_TYPE = ethers.solidityPackedKeccak256(['string'], ['dAPI pricing Merkle root']);
const SIGNED_API_URL_MERKLE_ROOT_HASH_TYPE = ethers.solidityPackedKeccak256(['string'], ['Signed API URL Merkle root']);
const SIGNATURE_DELEGATION_HASH_TYPE = ethers.solidityPackedKeccak256(
['string'],
['Api3MarketV2 signature delegation']
);
const MAXIMUM_DAPI_UPDATE_AGE = 24 * 60 * 60;

describe('Api3MarketV2', function () {
async function computeRequiredPaymentAmount(
api3MarketV2: Api3MarketV2,
dapiName: BytesLike,
Expand Down
54 changes: 27 additions & 27 deletions test/api3-server-v1/OevAuctionHouse.sol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@ import { ethers } from 'hardhat';

import type { MockApi3ReaderProxy } from '../../src/index';

const PROXY_SETTER_ROLE_DESCRIPTION = 'Proxy setter';
const WITHDRAWER_ROLE_DESCRIPTION = 'Withdrawer';
const AUCTIONEER_ROLE_DESCRIPTION = 'Auctioneer';
const WITHDRAWAL_WAITING_PERIOD = 15; // 15 seconds
const MAXIMUM_BID_LIFETIME = 24 * 60 * 60; // 1 day
const MINIMUM_BID_LIFETIME = 15; // 15 seconds
const FULFILLMENT_REPORTING_PERIOD = 24 * 60 * 60; // 1 day
// The encoded bid details from `encodeBidDetails()` below is 305 bytes
// A transaction hash is 32 bytes
const MAXIMUM_BIDDER_DATA_LENGTH = 1024;
// `Api3ServerV1.updateOevProxyDataFeedWithSignedData()` calldata for
// a Beacon set of 21 Beacons is 6336 bytes
const MAXIMUM_AUCTIONEER_DATA_LENGTH = 8192;

const HUNDRED_PERCENT_IN_BASIS_POINTS = 100 * 100;
const MAXIMUM_RATE_AGE = 24 * 60 * 60; // 1 day

// Below are example values
const COLLATERAL_AMOUNT_IN_BASIS_POINTS = 7.5 * 100; // 7.5%
const PROTOCOL_FEE_IN_BASIS_POINTS = 5 * 100; // 5%
const CHAIN_ID_TO_PRICE: Record<string, bigint> = {
1: ethers.parseEther('1820'), // ETH/USD is 1,820
97: ethers.parseEther('230'), // BNB/USD is 230
137: ethers.parseEther('0.65'), // MATIC/USD is 0.65
};
const COLLATERAL_RATE = CHAIN_ID_TO_PRICE['1']!; // Using ETH as collateral

describe('OevAuctionHouse', function () {
enum BidConditionType {
LTE = 0,
Expand All @@ -23,33 +50,6 @@ describe('OevAuctionHouse', function () {
FulfillmentContradicted = 5,
}

const PROXY_SETTER_ROLE_DESCRIPTION = 'Proxy setter';
const WITHDRAWER_ROLE_DESCRIPTION = 'Withdrawer';
const AUCTIONEER_ROLE_DESCRIPTION = 'Auctioneer';
const WITHDRAWAL_WAITING_PERIOD = 15; // 15 seconds
const MAXIMUM_BID_LIFETIME = 24 * 60 * 60; // 1 day
const MINIMUM_BID_LIFETIME = 15; // 15 seconds
const FULFILLMENT_REPORTING_PERIOD = 24 * 60 * 60; // 1 day
// The encoded bid details from `encodeBidDetails()` below is 305 bytes
// A transaction hash is 32 bytes
const MAXIMUM_BIDDER_DATA_LENGTH = 1024;
// `Api3ServerV1.updateOevProxyDataFeedWithSignedData()` calldata for
// a Beacon set of 21 Beacons is 6336 bytes
const MAXIMUM_AUCTIONEER_DATA_LENGTH = 8192;

const HUNDRED_PERCENT_IN_BASIS_POINTS = 100 * 100;
const MAXIMUM_RATE_AGE = 24 * 60 * 60; // 1 day

// Below are example values
const COLLATERAL_AMOUNT_IN_BASIS_POINTS = 7.5 * 100; // 7.5%
const PROTOCOL_FEE_IN_BASIS_POINTS = 5 * 100; // 5%
const CHAIN_ID_TO_PRICE: Record<string, bigint> = {
1: ethers.parseEther('1820'), // ETH/USD is 1,820
97: ethers.parseEther('230'), // BNB/USD is 230
137: ethers.parseEther('0.65'), // MATIC/USD is 0.65
};
const COLLATERAL_RATE = CHAIN_ID_TO_PRICE['1']!; // Using ETH as collateral

function deriveRootRole(managerAddress: AddressLike) {
return ethers.solidityPackedKeccak256(['address'], [managerAddress]);
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"noUncheckedIndexedAccess": true,
"noImplicitReturns": true,
"resolveJsonModule": true,
"allowJs": true,

// Disabled because they are covered by Eslint rules
"noUnusedLocals": false,
Expand Down

0 comments on commit 79cadc5

Please sign in to comment.