Skip to content

Commit

Permalink
Merge pull request #25 from gnosis/feat/custom-json-rpc-urls-hardhat-…
Browse files Browse the repository at this point in the history
…config

feat: use your own rpc node within hardhat.config.js
  • Loading branch information
allemanfredi authored Oct 18, 2023
2 parents 4fe1154 + e026c8f commit 5e3cadb
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 51 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: "CI"

env:
DOTENV_CONFIG_PATH: "./.env.example"

on:
workflow_dispatch:
pull_request:
Expand All @@ -27,6 +24,10 @@ jobs:
- name: "Install the dependencies"
run: "yarn install --immutable"

- name: 'Create env file'
run: |
echo "${{ secrets.CI_ENV_FILE }}" > ./packages/evm/.env
- name: "Lint the code"
run: "yarn lint"

Expand Down
3 changes: 3 additions & 0 deletions packages/evm/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
INFURA_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
MNEMONIC="here is where your twelve words mnemonic should be put my friend"

# Json rpc urls (If you wanted to use your own node)
NETWORK_NAME_JSON_RPC_URL="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

# Block explorer API keys
ARBISCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
BSCSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
Expand Down
3 changes: 1 addition & 2 deletions packages/evm/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"code-complexity": ["error", 9],
"compiler-version": ["error", ">=0.8.4"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"max-line-length": ["error", 120],
"not-rely-on-time": "off",
"avoid-low-level-calls": "off",
"prettier/prettier": [
Expand Down
11 changes: 6 additions & 5 deletions packages/evm/contracts/adapters/axiom/AxiomV02.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ function calcMerkleRoot(bytes32[HISTORICAL_NUM_ROOTS] calldata leaves) pure retu
contract AxiomV02 is IAxiomV0, Ownable {
string public constant VERSION = "0.2";

/// @notice The address of the snark verifier contract.
/// @notice The address of the snark verifier contract. */
address public verifierAddress;
/// @dev The address of AxiomV0 version "0.1". We will read from the storage of the old contract for old block hashes.
/** @dev The address of AxiomV0 version "0.1". We will read from the storage of the old contract for old block hashes. */
address public oldAxiomAddress;
/// @notice The block the contract was created at.
/// @notice The block the contract was created at
uint256 public creationBlockNumber;

// historicalRoots[startBlockNumber] is 0 unless (startBlockNumber % NUM_LEAVES == 0)
Expand All @@ -56,7 +56,7 @@ contract AxiomV02 is IAxiomV0, Ownable {

event UpdateSnarkVerifierAddress(address newAddress);

/// @dev We do not re-import all historical blockhashes in this v0.2 contract, so we use the old v0.1 contract for older block numbers
/** @dev We do not re-import all historical blockhashes in this v0.2 contract, so we use the old v0.1 contract for older block numbers */
function historicalRoots(uint32 startBlockNumber) public view returns (bytes32) {
if (startBlockNumber < creationBlockNumber) {
return IAxiomV0(oldAxiomAddress).historicalRoots(startBlockNumber);
Expand Down Expand Up @@ -98,7 +98,8 @@ contract AxiomV02 is IAxiomV0, Ownable {
return emptyHashes[depth];
}

// The ZKP has block headers for [startBlockNumber, endBlockNumber] blocks. We extract some common information from the calldata.
// The ZKP has block headers for [startBlockNumber, endBlockNumber] blocks.
// We extract some common information from the calldata.
function getBoundaryBlockData(
bytes calldata proofData
)
Expand Down
4 changes: 2 additions & 2 deletions packages/evm/contracts/adapters/axiom/Ownable.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;
pragma solidity ^0.8.4;

import "./utils/Context.sol";
import { Context } from "./utils/Context.sol";

/**
* @dev Contract module which provides a basic access control mechanism, where
Expand Down
2 changes: 1 addition & 1 deletion packages/evm/contracts/adapters/axiom/utils/Context.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
pragma solidity ^0.8.4;

/**
* @dev Provides information about the current execution context, including the
Expand Down
38 changes: 22 additions & 16 deletions packages/evm/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,29 @@ const chainIds = {
}

function getChainConfig(chain: keyof typeof chainIds): NetworkUserConfig {
let jsonRpcUrl: string
switch (chain) {
case "avalanche":
jsonRpcUrl = "https://api.avax.network/ext/bc/C/rpc"
break
case "bsc":
jsonRpcUrl = "https://bsc-dataseed1.binance.org"
break
case "gnosis":
jsonRpcUrl = "https://rpc.gnosis.gateway.fm"
break
case "chiado":
jsonRpcUrl = "https://rpc.chiadochain.net/"
break
default:
jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + infuraApiKey
let jsonRpcUrl: string = process.env[`${chain.toUpperCase()}_JSON_RPC_URL`] as string
if (!jsonRpcUrl) {
switch (chain) {
case "mainnet":
jsonRpcUrl = "https://ethereum.publicnode.com"
break
case "avalanche":
jsonRpcUrl = "https://api.avax.network/ext/bc/C/rpc"
break
case "bsc":
jsonRpcUrl = "https://bsc-dataseed1.binance.org"
break
case "gnosis":
jsonRpcUrl = "https://rpc.gnosis.gateway.fm"
break
case "chiado":
jsonRpcUrl = "https://rpc.chiadochain.net/"
break
default:
jsonRpcUrl = `https://${chain}.infura.io/v3/${infuraApiKey}`
}
}

return {
accounts: {
count: 10,
Expand Down
56 changes: 34 additions & 22 deletions packages/evm/test/adapters/axiom/00_Play.spec.ts

Large diffs are not rendered by default.

0 comments on commit 5e3cadb

Please sign in to comment.