Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ jobs:

steps:
- name: Checkout the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/cache@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
node-version: '22'
cache: 'yarn'

- name: Install Yarn dependencies
run: yarn install
Expand Down
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ node_modules
/artifacts

# TypeChain files
/typechain
/typechain-types
/types

# solidity-coverage files
/coverage
/coverage.json

# Hardhat Ignition default folder for deployments against a local node
ignition/deployments/chain-31337

# Local deployments
deployments/localhost.json

4 changes: 0 additions & 4 deletions contracts/core/test/chainlink/CLContractImports0.8.sol

This file was deleted.

53 changes: 36 additions & 17 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { HardhatUserConfig } from 'hardhat/config'
import '@nomicfoundation/hardhat-toolbox'
import '@nomicfoundation/hardhat-ledger'
import '@openzeppelin/hardhat-upgrades'
import { defineConfig, configVariable } from 'hardhat/config'
import hardhatLedger from '@nomicfoundation/hardhat-ledger'
import hardhatVerify from '@nomicfoundation/hardhat-verify'
import hardhatTypechain from '@nomicfoundation/hardhat-typechain'
import hardhatNetworkHelpers from '@nomicfoundation/hardhat-network-helpers'
import hardhatEthers from '@nomicfoundation/hardhat-ethers'
import hardhatChaiMatchers from '@nomicfoundation/hardhat-ethers-chai-matchers'
import hardhatMocha from '@nomicfoundation/hardhat-mocha'
import hardhatUpgrades from '@openzeppelin/hardhat-upgrades'

const balance = '100000000000000000000000'
const accounts = [
Expand All @@ -28,24 +33,30 @@ const ledgerConfig = {
},
}

const config: HardhatUserConfig = {
defaultNetwork: 'localhost',
export default defineConfig({
networks: {
localhost: {
type: 'http',
url: 'http://127.0.0.1:8545',
gas: 'auto',
...ledgerConfig,
},
mainnet: {
url: '',
type: 'http',
url: configVariable('MAINNET_RPC_URL'),
gasMultiplier: 1.3,
...ledgerConfig,
},
polygon: {
url: '',
accounts,
type: 'http',
url: configVariable('POLYGON_RPC_URL'),
gasMultiplier: 1.3,
...ledgerConfig,
},
hardhat: {
type: 'edr-simulated',
chainId: 1337,
hardfork: 'cancun', // required to bypass EIP-7825 when running pre EIP-7825 contract tests (new contracts should adhere to the gas limit)
accounts: accounts.map((acct) => ({ privateKey: acct, balance })),
mining: {
auto: true,
Expand All @@ -54,13 +65,23 @@ const config: HardhatUserConfig = {
gas: 'auto',
},
},
etherscan: {
apiKey: '',
},
sourcify: {
enabled: false,
verify: {
etherscan: {
apiKey: '',
},
},
plugins: [
hardhatLedger,
hardhatVerify,
hardhatTypechain,
hardhatNetworkHelpers,
hardhatEthers,
hardhatChaiMatchers,
hardhatMocha,
hardhatUpgrades,
],
solidity: {
npmFilesToBuild: ['@chainlink/contracts/src/v0.8/operatorforwarder/Operator.sol'],
compilers: [
{
version: '0.8.22',
Expand Down Expand Up @@ -100,6 +121,4 @@ const config: HardhatUserConfig = {
},
],
},
}

export default config
})
26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"repository": "git@github.com:stakedotlink/contracts.git",
"license": "MIT",
"type": "module",
"scripts": {
"start": "npx hardhat node --network hardhat",
"test": "npx hardhat test --network hardhat",
Expand All @@ -17,21 +18,19 @@
"solhint": "solhint contracts/**/*.sol"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.0",
"@nomicfoundation/hardhat-ignition": "^0.15.0",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
"@nomicfoundation/hardhat-ledger": "^1.0.3",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-verify": "2.1.1",
"@openzeppelin/hardhat-upgrades": "^3.2.0",
"@nomicfoundation/hardhat-ethers": "^4.0.4",
"@nomicfoundation/hardhat-ethers-chai-matchers": "^3.0.2",
"@nomicfoundation/hardhat-ledger": "^3.0.1",
"@nomicfoundation/hardhat-mocha": "^3.0.9",
"@nomicfoundation/hardhat-network-helpers": "^3.0.3",
"@nomicfoundation/hardhat-typechain": "^3.0.1",
"@nomicfoundation/hardhat-verify": "^3.0.8",
"@openzeppelin/hardhat-upgrades": "4.0.0-alpha.0",
"@openzeppelin/merkle-tree": "^1.0.6",
"@safe-global/api-kit": "^4.0.1",
"@safe-global/protocol-kit": "^6.1.2",
"@safe-global/types-kit": "^3.0.0",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
"@types/fs-extra": "^11.0.4",
"@types/mocha": ">=9.1.0",
Expand All @@ -40,11 +39,10 @@
"chai": "^4.2.0",
"ethers": "^6.4.0",
"fs-extra": "^11.2.0",
"hardhat": "^2.22.19",
"hardhat-gas-reporter": "^1.0.8",
"hardhat": "^3.1.5",
"mocha": "^11.7.5",
"prettier-plugin-solidity": "^1.3.1",
"solhint": "^5.0.1",
"solidity-coverage": "^0.8.0",
"solhint": "^6.0.3",
"ts-node": ">=8.0.0",
"typechain": "^8.3.0",
"typescript": ">=4.5.0"
Expand Down
34 changes: 19 additions & 15 deletions scripts/utils/deployment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Addressable } from 'ethers'
import fse from 'fs-extra'
import { ethers, upgrades, network } from 'hardhat'
import { getLedgerSigner } from './helpers'
import { getConnection, getLedgerSigner } from './helpers'

const { connection, ethers, upgradesApi } = await getConnection()

export const deploy = async (contractName: string, args: any[] = []): Promise<any> => {
const ledgerSigner = await getLedgerSigner()
Expand All @@ -11,13 +12,13 @@ export const deploy = async (contractName: string, args: any[] = []): Promise<an
export const deployUpgradeable = async (contractName: string, args: any[] = [], options = {}) => {
const ledgerSigner = await getLedgerSigner()
const Contract = await ethers.getContractFactory(contractName, ledgerSigner)
return upgrades.deployProxy(Contract, args, { kind: 'uups', ...options }) as any
return upgradesApi.deployProxy(Contract, args, { kind: 'uups', ...options }) as any
}

export const deployImplementation = async (contractName: string) => {
const ledgerSigner = await getLedgerSigner()
const Contract = await ethers.getContractFactory(contractName, ledgerSigner)
return upgrades.deployImplementation(Contract, { kind: 'uups' })
return upgradesApi.deployImplementation(Contract, { kind: 'uups' })
}

export const upgradeProxy = async (
Expand All @@ -28,20 +29,21 @@ export const upgradeProxy = async (
) => {
const ledgerSigner = await getLedgerSigner()
const Contract = await ethers.getContractFactory(implementationContractName, ledgerSigner)
const contract = await upgrades.upgradeProxy(proxyAddress, Contract, {
return upgradesApi.upgradeProxy(proxyAddress, Contract, {
useDeployedImplementation,
call,
kind: 'uups',
})
await contract.deployed()
return contract
}) as any
}

export const getDeployments = (networkName?: string) => {
fse.ensureFileSync(`deployments/${networkName || network.name}.json`)
const deployments = fse.readJSONSync(`deployments/${networkName || network.name}.json`, {
throws: false,
})
fse.ensureFileSync(`deployments/${networkName || connection.networkName}.json`)
const deployments = fse.readJSONSync(
`deployments/${networkName || connection.networkName}.json`,
{
throws: false,
}
)

if (!deployments) {
return {}
Expand All @@ -65,7 +67,7 @@ export const updateDeployments = (
)

fse.outputJSONSync(
`deployments/${network.name}.json`,
`deployments/${connection.networkName}.json`,
{ ...deployments, ...newDeploymentsWithArtifacts },
{ spaces: 2 }
)
Expand All @@ -86,8 +88,10 @@ export const getContract = async (contractName: string, networkName?: string): P
}

export const printDeployments = () => {
fse.ensureFileSync(`deployments/${network.name}.json`)
const deployments = fse.readJSONSync(`deployments/${network.name}.json`, { throws: false })
fse.ensureFileSync(`deployments/${connection.networkName}.json`)
const deployments = fse.readJSONSync(`deployments/${connection.networkName}.json`, {
throws: false,
})

if (!deployments) {
console.log('Deployments: Nothing to print')
Expand Down
16 changes: 12 additions & 4 deletions scripts/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import { ethers } from 'hardhat'
import hre, { network } from 'hardhat'
import { parseEther, formatEther } from 'ethers'
import { upgrades } from '@openzeppelin/hardhat-upgrades'
import axios from 'axios'

const connection = await network.connect(hre.globalOptions.network)
const ethers = (connection as any).ethers
const upgradesApi = await upgrades(hre, connection)

export const getConnection = async () => ({ connection, ethers, upgradesApi })

export const toEther = (amount: string | number) => {
return ethers.parseEther(amount.toString())
return parseEther(amount.toString())
}

export const fromEther = (amount: bigint) => {
return Number(ethers.formatEther(amount))
return Number(formatEther(amount))
}

export const getAccounts = async (): Promise<any> => {
const signers = await ethers.getSigners()
const accounts = await Promise.all(signers.map(async (signer) => signer.getAddress()))
const accounts = await Promise.all(signers.map(async (signer: any) => signer.getAddress()))
return { signers, accounts }
}

Expand Down
21 changes: 10 additions & 11 deletions test/core/curveGaugeDistributor/curve-gauge-ccip-receiver.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'
import { assert, expect } from 'chai'
import { ethers } from 'hardhat'
import { id, AbiCoder } from 'ethers'
import {
import type {
CCIPCurveGaugeReceiver,
CurveGaugeDistributorMock,
MockCCIPRouter,
} from '../../../typechain-types'
import { deploy, fromEther, getAccounts, toEther } from '../../utils/helpers'
import { ERC677 } from '../../../typechain-types/contracts/core/tokens/base'
ERC677,
} from '../../../types/ethers-contracts'
import { deploy, fromEther, getAccounts, getConnection, toEther } from '../../utils/helpers'

const { ethers, loadFixture } = getConnection()

const chainSelector = 7777n

Expand Down Expand Up @@ -66,8 +65,8 @@ describe('CCIPCurveGaugeReceiver', function () {
]

const gasLimit = 200000
const functionSelector = id('CCIP EVMExtraArgsV1').slice(0, 10)
const defaultAbiCoder = AbiCoder.defaultAbiCoder()
const functionSelector = ethers.id('CCIP EVMExtraArgsV1').slice(0, 10)
const defaultAbiCoder = ethers.AbiCoder.defaultAbiCoder()
const extraArgs = defaultAbiCoder.encode(['uint256'], [gasLimit])
const encodedExtraArgs = `${functionSelector}${extraArgs.slice(2)}`

Expand All @@ -79,10 +78,10 @@ describe('CCIPCurveGaugeReceiver', function () {
extraArgs: encodedExtraArgs,
}

await expect(ccipRouter.connect(signers[1]).ccipSend(chainSelector, message)).to.be.reverted
await expect(ccipRouter.connect(signers[1]).ccipSend(chainSelector, message)).to.revert(ethers)
await expect(
ccipRouter.connect(signers[1]).ccipSend(chainSelector, { ...message, tokenAmounts: [] })
).to.be.reverted
).to.revert(ethers)

await ccipRouter.ccipSend(chainSelector, message)

Expand Down
24 changes: 15 additions & 9 deletions test/core/curveGaugeDistributor/curve-gauge-ccip-sender.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'
import { assert, expect } from 'chai'
import { ethers } from 'hardhat'
import { id, AbiCoder } from 'ethers'
import {
import type {
CCIPCurveGaugeReceiver,
CCIPCurveGaugeSender,
CurveGaugeDistributorMock,
MockCCIPRouter,
StakingPool,
WrappedSDToken,
} from '../../../typechain-types'
import { deploy, deployUpgradeable, fromEther, getAccounts, toEther } from '../../utils/helpers'
import { ERC677 } from '../../../typechain-types/contracts/core/tokens/base'
ERC677,
} from '../../../types/ethers-contracts'
import {
deploy,
deployUpgradeable,
fromEther,
getAccounts,
getConnection,
toEther,
} from '../../utils/helpers'

const { ethers, loadFixture } = getConnection()

const sourceChainSelector = 7777n
const destChainSelector = 8888n

const gasLimit = 200000
const functionSelector = id('CCIP EVMExtraArgsV1').slice(0, 10)
const extraArgs = AbiCoder.defaultAbiCoder().encode(['uint256'], [gasLimit])
const functionSelector = ethers.id('CCIP EVMExtraArgsV1').slice(0, 10)
const extraArgs = ethers.AbiCoder.defaultAbiCoder().encode(['uint256'], [gasLimit])
const encodedExtraArgs = `${functionSelector}${extraArgs.slice(2)}`

describe('CCIPCurveGaugeSender', function () {
Expand Down
Loading
Loading