Skip to content

Commit

Permalink
Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
9inpachi committed May 15, 2024
1 parent e5b1c67 commit 3cc395b
Show file tree
Hide file tree
Showing 17 changed files with 97 additions and 104 deletions.
5 changes: 4 additions & 1 deletion dist/main.cjs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=(e,t)=>e+t;exports.add=d;
'use strict';
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const d = (e, t) => e + t;
exports.add = d;
4 changes: 1 addition & 3 deletions dist/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
const t = (d, o) => d + o;
export {
t as add
};
export { t as add };
7 changes: 6 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ export default [
...tseslint.configs.recommended,
eslintPluginPrettierRecommended,
{
ignores: ['dist'],
ignores: ['dist/'],
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
];
19 changes: 10 additions & 9 deletions lib/config/networks/anvil.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import anvilAddresses from "../addresses/anvil.json";
import anvilAddresses from '../addresses/anvil.json';

const anvilConfig = {
// Siren API base URL
sirenApiBaseUrl: 'http://staging-console-969568480.eu-west-1.elb.amazonaws.com/siren/api/',
// Smart contract addresses
PUFFER_VAULT_CONTRACT_ADDRESS: anvilAddresses.vault,
PUFFER_PROTOCOL_CONTRACT_ADDRESS: anvilAddresses.protocol,
VALIDATOR_TICKET_CONTRACT_ADDRESS: anvilAddresses.validatorTicket,
PUFFER_ORACLE_CONTRACT_ADDRESS: anvilAddresses.oracle,
GUARDIAN_MODULE_ADDRESS: anvilAddresses.guardianModule
// Siren API base URL
sirenApiBaseUrl:
'http://staging-console-969568480.eu-west-1.elb.amazonaws.com/siren/api/',
// Smart contract addresses
PUFFER_VAULT_CONTRACT_ADDRESS: anvilAddresses.vault,
PUFFER_PROTOCOL_CONTRACT_ADDRESS: anvilAddresses.protocol,
VALIDATOR_TICKET_CONTRACT_ADDRESS: anvilAddresses.validatorTicket,
PUFFER_ORACLE_CONTRACT_ADDRESS: anvilAddresses.oracle,
GUARDIAN_MODULE_ADDRESS: anvilAddresses.guardianModule,
};

export default anvilConfig;
18 changes: 9 additions & 9 deletions lib/config/networks/default.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import mainnetAddresses from "../addresses/mainnet.json";
import mainnetAddresses from '../addresses/mainnet.json';

const defaultConfig = {
// Siren API base URL
sirenApiBaseUrl: 'https://api.puffer.fi/siren/api/',
// Siren API base URL
sirenApiBaseUrl: 'https://api.puffer.fi/siren/api/',

// Smart contract addresses
PUFFER_VAULT_CONTRACT_ADDRESS: mainnetAddresses.PufferVault,
PUFFER_PROTOCOL_CONTRACT_ADDRESS: mainnetAddresses.pufferProtocolProxy,
VALIDATOR_TICKET_CONTRACT_ADDRESS: mainnetAddresses.validatorTicketProxy,
PUFFER_ORACLE_CONTRACT_ADDRESS: mainnetAddresses.oracle,
GUARDIAN_MODULE_ADDRESS: mainnetAddresses.guardianModule
// Smart contract addresses
PUFFER_VAULT_CONTRACT_ADDRESS: mainnetAddresses.PufferVault,
PUFFER_PROTOCOL_CONTRACT_ADDRESS: mainnetAddresses.pufferProtocolProxy,
VALIDATOR_TICKET_CONTRACT_ADDRESS: mainnetAddresses.validatorTicketProxy,
PUFFER_ORACLE_CONTRACT_ADDRESS: mainnetAddresses.oracle,
GUARDIAN_MODULE_ADDRESS: mainnetAddresses.guardianModule,
};

export default defaultConfig;
18 changes: 9 additions & 9 deletions lib/config/networks/holesky.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import holeskyAddresses from "../addresses/holesky.json";
import holeskyAddresses from '../addresses/holesky.json';

const testnetConfig = {
// Siren API base URL
sirenApiBaseUrl: 'https://staging-api.puffer.fi/siren/api/',
// Siren API base URL
sirenApiBaseUrl: 'https://staging-api.puffer.fi/siren/api/',

// Smart contract addresses
PUFFER_VAULT_CONTRACT_ADDRESS: holeskyAddresses.vault,
PUFFER_PROTOCOL_CONTRACT_ADDRESS: holeskyAddresses.protocol,
VALIDATOR_TICKET_CONTRACT_ADDRESS: holeskyAddresses.validatorTicket,
PUFFER_ORACLE_CONTRACT_ADDRESS: holeskyAddresses.oracle,
GUARDIAN_MODULE_ADDRESS: holeskyAddresses.guardianModule
// Smart contract addresses
PUFFER_VAULT_CONTRACT_ADDRESS: holeskyAddresses.vault,
PUFFER_PROTOCOL_CONTRACT_ADDRESS: holeskyAddresses.protocol,
VALIDATOR_TICKET_CONTRACT_ADDRESS: holeskyAddresses.validatorTicket,
PUFFER_ORACLE_CONTRACT_ADDRESS: holeskyAddresses.oracle,
GUARDIAN_MODULE_ADDRESS: holeskyAddresses.guardianModule,
};

export default testnetConfig;
20 changes: 10 additions & 10 deletions lib/config/networks/mainnet.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import mainnetAddresses from "../addresses/mainnet.json";
import mainnetAddresses from '../addresses/mainnet.json';

const mainnetConfig = {
// Siren API base URL
sirenApiBaseUrl: 'https://api.puffer.fi/siren/api/',
// Siren API base URL
sirenApiBaseUrl: 'https://api.puffer.fi/siren/api/',

// Smart contract addresses
PUFFER_VAULT_CONTRACT_ADDRESS: mainnetAddresses.PufferVault,
PUFFER_PROTOCOL_CONTRACT_ADDRESS: mainnetAddresses.pufferProtocolProxy,
VALIDATOR_TICKET_CONTRACT_ADDRESS: mainnetAddresses.validatorTicketProxy,
PUFFER_ORACLE_CONTRACT_ADDRESS: mainnetAddresses.oracle,
GUARDIAN_MODULE_ADDRESS: mainnetAddresses.guardianModule
// Smart contract addresses
PUFFER_VAULT_CONTRACT_ADDRESS: mainnetAddresses.PufferVault,
PUFFER_PROTOCOL_CONTRACT_ADDRESS: mainnetAddresses.pufferProtocolProxy,
VALIDATOR_TICKET_CONTRACT_ADDRESS: mainnetAddresses.validatorTicketProxy,
PUFFER_ORACLE_CONTRACT_ADDRESS: mainnetAddresses.oracle,
GUARDIAN_MODULE_ADDRESS: mainnetAddresses.guardianModule,
};

export default mainnetConfig;
export default mainnetConfig;
21 changes: 0 additions & 21 deletions lib/react/context/Web3Context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import React, {
useState,
useEffect,
ReactNode,
useCallback,
} from 'react';
import Web3 from 'web3';

Expand Down Expand Up @@ -108,22 +107,6 @@ export const Web3Provider: React.FC<Web3ProviderProps> = ({
}
};

const switchNetwork = useCallback(
async (chainId: bigint) => {
if (web3) {
try {
await (window as any).ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: web3.utils.toHex(chainId) }],
});
} catch (error: any) {
console.error('Error switching network:', error);
}
}
},
[web3],
);

const connectWallet = async () => {
if (web3) {
try {
Expand All @@ -150,10 +133,6 @@ export const Web3Provider: React.FC<Web3ProviderProps> = ({
setIsConnected(false);
};

const handleReload = () => {
switchNetwork(BigInt(17000));
};

return (
<Web3Context.Provider
value={{
Expand Down
4 changes: 2 additions & 2 deletions lib/react/hooks/useContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Network, networkEnumToString } from '../../config/networks';
import { useNetworkConfig } from '../context/NetworkConfig';
import { useWeb3 } from '../context/Web3Context';

const useContracts = (web3: Web3, selector: Network) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const useContracts = (web3: Web3, _selector: Network) => {
const { networkName } = useWeb3();
const config = useNetworkConfig();

Expand All @@ -19,7 +20,6 @@ const useContracts = (web3: Web3, selector: Network) => {
const path = `../constants/abis/${network}/${contractName}.json`;

try {
// eslint-disable-next-line @next/next/no-assign-module-variable
const module = await import(
`../constants/abis/${network}/${contractName}.json`
);
Expand Down
6 changes: 3 additions & 3 deletions lib/react/hooks/usePufETHModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const usePufETHModule = (web3: Web3, selector: Network) => {
const canAffordPufETH = async (
walletAddress: any,
ethDeposit: bigint,
): Promise<[boolean, BigInt]> => {
): Promise<[boolean, bigint]> => {
setLoading(true);
try {
const ethBalance = await web3.eth.getBalance(walletAddress);
Expand Down Expand Up @@ -126,7 +126,7 @@ const usePufETHModule = (web3: Web3, selector: Network) => {
.convertToShares(enclaveValidatorEthBond)
.call(),
);
const scaledBondInPufETH: BigInt = bondInPufETH;
const scaledBondInPufETH: bigint = bondInPufETH;
const balance = await getPufETHBalance(walletAddress);
return balance >= scaledBondInPufETH;
} catch (error) {
Expand All @@ -143,7 +143,7 @@ const usePufETHModule = (web3: Web3, selector: Network) => {

const purchasePufETH = async (
walletAddress: any,
ethAmount: BigInt,
ethAmount: bigint,
): Promise<any> => {
setLoading(true);
try {
Expand Down
13 changes: 6 additions & 7 deletions lib/react/hooks/usePufferProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useNetworkConfig } from '../context/NetworkConfig';
import { ErrorProps } from '../../types/error';
import { NodeInfo } from '../../types/node';
import { ValidatorKeyData } from '../../types/registration';
import { ValidatorProp, findValidatorStatus } from '../../types/validator';
import { getPermitSignature } from '../../utils/ERC20Permit';
import { shortenString } from '../../utils/ErrorPrepration';
import { add0xPrefix } from '../../utils/Key';
Expand Down Expand Up @@ -77,7 +76,7 @@ const usePufferProtocol = (
> => {
try {
// Returns the index of the next PufferModule to be provisioned
const nextModuleSelect: BigInt = await (
const nextModuleSelect: bigint = await (
await pufferProtocolContract()
).methods
.getModuleSelectIndex()
Expand All @@ -91,7 +90,7 @@ const usePufferProtocol = (
.call();

// Get the moduleName
var moduleName: string = '';
let moduleName: string = '';
if (moduleWeights.length > 0) {
moduleName =
moduleWeights[Number(nextModuleSelect) % moduleWeights.length];
Expand Down Expand Up @@ -130,7 +129,7 @@ const usePufferProtocol = (

const getValidatorTicketBalanceInProtocol = async (
walletAddress: any,
): Promise<BigInt | null> => {
): Promise<bigint | null> => {
try {
return (await pufferProtocolContract()).methods
.getValidatorTicketsBalance(walletAddress)
Expand Down Expand Up @@ -243,7 +242,7 @@ const usePufferProtocol = (
);

// Construct pufETH permit
let { signature, deadline } = await getPermitSignature(
const { signature, deadline } = await getPermitSignature(
web3,
ethersProvider,
await pufETHContract(),
Expand Down Expand Up @@ -284,7 +283,7 @@ const usePufferProtocol = (
const vtAmount = BigInt(numDays) * BigInt(1e18);

// Construct VT permit
let { signature: vtSignatureString, deadline: vtDeadline } =
const { signature: vtSignatureString, deadline: vtDeadline } =
await getPermitSignature(
web3,
ethersProvider,
Expand Down Expand Up @@ -316,7 +315,7 @@ const usePufferProtocol = (
}
};

const nodeRequiredVTAmount = async (walletAddress: any): Promise<BigInt> => {
const nodeRequiredVTAmount = async (walletAddress: any): Promise<bigint> => {
const minVTPerValidator: bigint = await (
await pufferProtocolContract()
).methods
Expand Down
12 changes: 7 additions & 5 deletions lib/react/hooks/useVTModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const useVTModule = (web3: Web3, selector: Network) => {
};

// ETH cost paid mint VTs
const getValidatorTicketPrice = async (): Promise<BigInt | null> => {
const getValidatorTicketPrice = async (): Promise<bigint | null> => {
setLoading(true);
try {
return BigInt(
Expand All @@ -40,7 +40,9 @@ const useVTModule = (web3: Web3, selector: Network) => {
};

// Amount of gas to call mint VT tx
const getValidatorTicketGas = async (walletAddress: any): Promise<BigInt | null> => {
const getValidatorTicketGas = async (
walletAddress: any,
): Promise<bigint | null> => {
setLoading(true);
try {
return await (await validatorTicketContract()).methods
Expand All @@ -61,7 +63,7 @@ const useVTModule = (web3: Web3, selector: Network) => {
// The requesting wallet addresses's ValidatorTicket ERC20 balance (18 decimals)
const getValidatorTicketBalance = async (
walletAddress: any,
): Promise<BigInt | null> => {
): Promise<bigint | null> => {
setLoading(true);
try {
return (await validatorTicketContract()).methods
Expand Down Expand Up @@ -112,10 +114,10 @@ const useVTModule = (web3: Web3, selector: Network) => {
): Promise<boolean | null> => {
setLoading(true);
try {
const balance: BigInt = await (await validatorTicketContract()).methods
const balance: bigint = await (await validatorTicketContract()).methods
.balanceOf(walletAddress)
.call();
const required: BigInt = BigInt(numDays) * BigInt(1e18);
const required: bigint = BigInt(numDays) * BigInt(1e18);
return balance >= required;
} catch (error) {
let errorMessage = `Can not calculate if user has enough VTs: Unknown error`;
Expand Down
Loading

0 comments on commit 3cc395b

Please sign in to comment.