-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from zeta-chain/feat/release
ci: publish to npm workflow
- Loading branch information
Showing
4 changed files
with
59 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Publish to NPM | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16" | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- name: Install Dependencies | ||
run: yarn install | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Publish to NPM | ||
run: yarn publish --new-version ${GITHUB_REF#refs/tags/v} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GITHUB_REF: ${{ github.ref }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/src | ||
/scripts | ||
/networks.schema.json | ||
/tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
export const getHardhatConfigNetworks = (accounts: string[]): any => { | ||
// Read and parse the JSON file | ||
const dataBuffer = fs.readFileSync( | ||
path.resolve(__dirname, "..", "data", "networks.json") | ||
); | ||
const dataJson: any = JSON.parse(dataBuffer.toString()); | ||
export const networks = JSON.parse( | ||
fs | ||
.readFileSync(path.resolve(__dirname, "..", "data", "networks.json")) | ||
.toString() | ||
); | ||
|
||
export const getHardhatConfigNetworks = (accounts: string[]): any => { | ||
const config: any = {}; | ||
|
||
// Loop through the JSON object and create the required structure | ||
for (const network in dataJson) { | ||
let apiUrls = dataJson[network].api; | ||
for (const network in networks) { | ||
let apiUrls = networks[network].api; | ||
let evmApi = apiUrls?.find((api: any) => 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: networks[network].chain_id, | ||
gas: networks[network].fees.assets[0].gas, | ||
gasPrice: networks[network].fees.assets[0].gas_price, | ||
url: evmApi?.url || "", | ||
}; | ||
} | ||
|
||
return config; | ||
}; | ||
|
||
// Temporary function that maps chain IDs to the old chain names | ||
// used by @zetachain/addresses | ||
export const chainNameById = (chainId: number): any => { | ||
return { | ||
7001: "athens", | ||
97: "bsc-testnet", | ||
5: "goerli", | ||
1001: "klaytn-baobab", | ||
80001: "polygon-mumbai", | ||
}[chainId]; | ||
}; |