Skip to content
This repository has been archived by the owner on Feb 24, 2025. It is now read-only.

v2.0.0

Compare
Choose a tag to compare
@andreogle andreogle released this 15 Apr 09:13
· 907 commits to main since this release

Version 2.0.0

BREAKING CHANGES

The following functions have been replaced.

getChains()

getChains has been replaced with a static list of Chain objects. This change removes the need for fs and path dependencies, allowing the list of CHAINS to be used in any environment.

-    import { getChains } from '@api3/chains';
-    console.log(getChains());
+    import { CHAINS } from '@api3/chains';
+    console.log(CHAINS);

getChain()

getChain has been renamed to the more descriptive getChainByAlias function. This function throws if the Chain is not found for the given alias.

-    import { getChain } from '@api3/chains';
-    console.log(getChain('ethereum'));
+    import { getChainByAlias } from '@api3/chains';
+    console.log(getChainByAlias('ethereum'));

writeEnvFile

writeEnvFile has has been replaced with a function that simply returns the list of expected environment variable keys (string[]). This was also required to remove the dependency on Node libraries, specifically fs and path.

-    import { writeEnvFile } from '@api3/chains';
-    writeEnvFile('.env');
+    import { getEnvVariables } from '@api3/chains';
+    console.log(getEnvVariables());

The old functionality to write to a given file has been extracted to a script. This script uses getEnvVariables under the hood and can be run with

yarn env:write --path .env

Features

Types

Types are now exported. These types are generated from zod schemas, which are also used to valid each chain conforms to the required structure. Types can be imported from the package as

import { Chain } from '@api3/chains';

See src/types for the full list of types and zod schemas.