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 0.0.1 to 0.1.0

12

dist/getHardhatConfigNetworks.d.ts

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

interface Config {
[key: string]: {
accounts: string[];
chainId: number;
gas: number;
gasPrice: number;
url: string;
};
}
export declare const networks: any;
export declare const getHardhatConfigNetworks: (accounts: string[]) => 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) {

@@ -7,2 +30,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.chainNameById = exports.getHardhatConfigNetworks = exports.networks = void 0;
const dotenv = __importStar(require("dotenv"));
const fs_1 = __importDefault(require("fs"));

@@ -13,5 +37,20 @@ const path_1 = __importDefault(require("path"));

.toString());
const getHardhatConfigNetworks = (accounts) => {
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 exports.networks) {

@@ -35,9 +74,9 @@ let apiUrls = exports.networks[network].api;

return {
1001: "klaytn-baobab",
5: "goerli",
7001: "athens",
80001: "polygon-mumbai",
97: "bsc-testnet",
5: "goerli",
1001: "klaytn-baobab",
80001: "polygon-mumbai",
}[chainId];
};
exports.chainNameById = chainNameById;
{
"name": "@zetachain/networks",
"version": "0.0.1",
"version": "0.1.0",
"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 @@

.github/workflows/publish-npm.yaml
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