New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@zetachain/networks

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zetachain/networks - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0-athens3

24

data/networks.json

@@ -93,32 +93,28 @@ {

{
"url": "https://rpc.ankr.com/zetachain_evm_testnet",
"url": "https://zetachain-athens-evm.blockpi.network/v1/rpc/public",
"type": "evm"
},
{
"url": "https://rpc.ankr.com/zetachain_tendermint_testnet",
"url": "https://zetachain-athens.blockpi.network/rpc/v1/public",
"type": "tendermint-rpc"
},
{
"url": "https://rpc.ankr.com/http/zetachain_testnet",
"url": "https://zetachain-athens.blockpi.network/lcd/v1/public",
"type": "cosmos-http"
},
{
"url": "https://api.athens2.zetachain.com/evm",
"type": "evm-rpc"
"url": "wss://zetachain-athens.blockpi.network/rpc/v1/public/websocket",
"type": "tendermint-ws"
},
{
"url": "https://api.athens2.zetachain.com/tendermint",
"url": "https://zetachain-testnet.nodejumper.io:443",
"type": "tendermint-rpc"
},
{
"url": "https://api.athens2.zetachain.com/tendermint",
"type": "tendermint-http"
"url": "https://zetachain-testnet.nodejumper.io:1317",
"type": "cosmos-http"
},
{
"url": "wss://api-lb.athens2.zetachain.com:26657/websocket",
"type": "tendermint-ws"
},
{
"url": "https://api.athens2.zetachain.com/",
"type": "cosmos-http"
"url": "https://zetachain-testnet.nodejumper.io:9090",
"type": "cosmos-grpc"
}

@@ -125,0 +121,0 @@ ]

@@ -1,1 +0,13 @@

export declare const getHardhatConfigNetworks: (accounts: string[]) => any;
interface Config {
[key: string]: {
accounts: string[];
chainId: number;
gas: number;
gasPrice: number;
url: string;
};
}
export declare const networks: any;
export declare const getHardhatConfigNetworks: () => Config;
export declare const chainNameById: (chainId: number) => any;
export {};
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,19 +29,35 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.getHardhatConfigNetworks = void 0;
exports.chainNameById = exports.getHardhatConfigNetworks = exports.networks = void 0;
const dotenv = __importStar(require("dotenv"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const getHardhatConfigNetworks = (accounts) => {
// Read and parse the JSON file
const dataBuffer = fs_1.default.readFileSync(path_1.default.resolve(__dirname, "..", "data", "networks.json"));
const dataJson = JSON.parse(dataBuffer.toString());
exports.networks = JSON.parse(fs_1.default
.readFileSync(path_1.default.resolve(__dirname, "..", "data", "networks.json"))
.toString());
const getHardhatConfigNetworks = () => {
const validatePrivateKey = (privateKey) => {
if (!privateKey) {
return [];
}
else if (privateKey.startsWith("0x")) {
throw new Error("PRIVATE_KEY env variable should not start with 0x");
}
else if (!/^(0x)?[0-9a-fA-F]{64}$/.test(privateKey)) {
throw new Error("PRIVATE_KEY env variable is not a valid private key");
}
else {
return [`0x${privateKey}`];
}
};
dotenv.config();
const accounts = validatePrivateKey(process.env.PRIVATE_KEY);
const config = {};
// Loop through the JSON object and create the required structure
for (const network in dataJson) {
let apiUrls = dataJson[network].api;
for (const network in exports.networks) {
let apiUrls = exports.networks[network].api;
let evmApi = apiUrls?.find((api) => api.type === "evm");
config[network] = {
accounts,
chainId: dataJson[network].chain_id,
gas: dataJson[network].fees.assets[0].gas,
gasPrice: dataJson[network].fees.assets[0].gas_price,
chainId: exports.networks[network].chain_id,
gas: exports.networks[network].fees.assets[0].gas,
gasPrice: exports.networks[network].fees.assets[0].gas_price,
url: evmApi?.url || "",

@@ -30,1 +69,13 @@ };

exports.getHardhatConfigNetworks = getHardhatConfigNetworks;
// Temporary function that maps chain IDs to the old chain names
// used by @zetachain/addresses
const chainNameById = (chainId) => {
return {
1001: "klaytn-baobab",
5: "goerli",
7001: "athens",
80001: "polygon-mumbai",
97: "bsc-testnet",
}[chainId];
};
exports.chainNameById = chainNameById;
{
"name": "@zetachain/networks",
"version": "1.0.0",
"version": "2.0.0-athens3",
"description": "",

@@ -10,2 +10,4 @@ "main": "dist/index.js",

"build": "rm -rf dist && tsc",
"lint:fix": "npx eslint . --ext .js,.ts --fix",
"lint": "npx eslint . --ext .js,.ts",
"prepublishOnly": "npm run build"

@@ -18,6 +20,24 @@ },

"@types/node": "^20.2.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"ajv": "^8.12.0",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-typescript-sort-keys": "^2.3.0",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
}
}
},
"dependencies": {
"dotenv": "^16.1.4"
},
"files": [
"dist",
"data"
]
}

@@ -5,2 +5,40 @@ # ZetaChain Blockchain Networks Registry

## Building a dapp on ZetaChain
If you're looking to build a dapp on ZetaChain, we recommend using the Hardhat
[template](https://github.com/zeta-chain/template). This template has all the
networks preconfigured, so you don't need to install this package manually.
## Installation
To install this package in Hardhat project, add it as a development dependency:
```
yarn add --dev @zetachain/networks
```
## Usage
In your `hardhat.config.ts` file, import the `getHardhatConfigNetworks` function
from `@zetachain/networks`:
```ts
import { getHardhatConfigNetworks } from "@zetachain/networks";
const config: HardhatUserConfig = {
networks: {
...getHardhatConfigNetworks(),
},
};
```
In this configuration, the `getHardhatConfigNetworks` function returns all
available networks from ZetaChain and spreads them into the `networks` object.
This way, the Hardhat environment is configured to interact with all the
networks connected to ZetaChain.
`getHardhatConfigNetworks` reads the private key from `PRIVATE_KEY` environment
variable and defaults to an empty account array if the variable not set, and
throws an error if the private key is invalid.
## Prerequisites

@@ -7,0 +45,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc