forked from zeta-chain/app-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix npm packages to be used externally (zeta-chain#47)
* Fix npm packages to be used in external * add babel and type files * update readme file * Update packages/addresses/README.md Co-authored-by: Lucas <[email protected]> * Update packages/addresses/README.md Co-authored-by: Lucas <[email protected]> * update readme * move to vite * update version * Update packages/addresses/.npmignore Co-authored-by: Lucas <[email protected]> * Update packages/addresses/.npmignore Co-authored-by: Lucas <[email protected]> * Update packages/addresses/tsconfig.json Co-authored-by: Lucas <[email protected]> * update errors * Update packages/addresses/package.json Co-authored-by: Lucas <[email protected]> Co-authored-by: Lucas <[email protected]>
- Loading branch information
1 parent
cc3bbc1
commit fbc563d
Showing
45 changed files
with
1,007 additions
and
216 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,24 @@ | ||
# source code | ||
src | ||
index.html | ||
|
||
# compiler | ||
tsconfig.json | ||
|
||
# files | ||
*.log | ||
cypress.json | ||
*.code-workspace | ||
|
||
# tests | ||
test | ||
|
||
# lint | ||
.eslintrc.js | ||
.prettierrc | ||
|
||
# IDE - VSCode | ||
.vscode | ||
|
||
# git | ||
.git |
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,3 +1,26 @@ | ||
# ZetaChain addresses | ||
|
||
This package includes the addresses and networks to use Zetachain. | ||
|
||
## Usage | ||
|
||
```js | ||
import { getAddress } from "@zetachain/addresses"; | ||
|
||
const address = getAddress({ address: "zetaToken", networkName: "goerli", zetaNetwork:"athens" }); | ||
``` | ||
|
||
## API | ||
|
||
|
||
| Method | Description | | ||
| :---- | ------ | | ||
| isTestnetNetworkName = (networkName: string): networkName is TestnetNetworkName | Returns true if it's a valid Testnet name | | ||
| isZetaTestnet = (networkName: string): networkName is ZetaTestnetNetworkName | Returns true if it's a valid ZetaTestnet name | | ||
| isMainnetNetworkName = (networkName: string): networkName is MainnetNetworkName | Returns true if it's a valid Mainnet name | | ||
| isNetworkName = (networkName: string): networkName is NetworkName | Returns true if it's a valid network name | | ||
| isZetaNetworkName = (networkName: string): networkName is ZetaNetworkName | Returns true if it's a valid Zeta network name | | ||
| type ZetaAddress | Valid values for ZetaAddress | | ||
| getAddress = ({ address: ZetaAddress; networkName: string; zetaNetwork: string; }): string | Returns the address of a valid ZetaAddress | | ||
|
||
``` |
This file was deleted.
Oops, something went wrong.
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,14 +1,30 @@ | ||
{ | ||
"name": "@zetachain/addresses", | ||
"version": "0.0.4", | ||
"version": "0.0.8", | ||
"license": "MIT", | ||
"author": "zetachain", | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"main": "src/index.ts", | ||
"main": "./dist/zetachain-addresses.umd.js", | ||
"module": "./dist/zetachain-addresses.mjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./dist/zetachain-addresses.mjs", | ||
"require": "./dist/zetachain-addresses.umd.js" | ||
} | ||
}, | ||
"scripts": { | ||
"tsc:watch": "npx tsc --watch" | ||
"tsc:watch": "npx tsc --watch", | ||
"prepublishOnly": "vite build" | ||
}, | ||
"devDependencies": { | ||
"vite": "^3.1.0", | ||
"vite-plugin-dts": "^1.4.1" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"typeRoots": ["@types", "./node_modules/@types"], | ||
"target": "es6", | ||
"noImplicitAny": true, | ||
"moduleResolution": "node", | ||
"sourceMap": false, | ||
"outDir": "dist", | ||
"esModuleInterop": true, | ||
"baseUrl": "./", | ||
"declaration": true, | ||
"module": "commonjs", | ||
"resolveJsonModule": true, | ||
} | ||
} |
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,20 @@ | ||
// vite.config.js | ||
import { resolve } from "path"; | ||
import { defineConfig } from "vite"; | ||
import dts from "vite-plugin-dts"; | ||
|
||
export default defineConfig({ | ||
build: { | ||
lib: { | ||
entry: resolve(__dirname, "./src/index.ts"), | ||
// the proper extensions will be added | ||
fileName: "zetachain-addresses", | ||
name: "ZetachainAddresses" | ||
} | ||
}, | ||
plugins: [ | ||
dts({ | ||
insertTypesEntry: true | ||
}) | ||
] | ||
}); |
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
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,23 @@ | ||
import { getAddress as getAddressLib, NetworkName, ZetaAddress, ZetaNetworkName } from "@zetachain/addresses"; | ||
import { network } from "hardhat"; | ||
|
||
const MissingZetaNetworkError = new Error( | ||
"ZETA_NETWORK is not defined, please set the environment variable (e.g.: ZETA_NETWORK=athens <command>)" | ||
); | ||
|
||
export const getAddress = ( | ||
address: ZetaAddress, | ||
{ | ||
customNetworkName, | ||
customZetaNetwork | ||
}: { customNetworkName?: NetworkName; customZetaNetwork?: ZetaNetworkName } = {} | ||
): string => { | ||
const { name: _networkName } = network; | ||
const networkName = customNetworkName || _networkName; | ||
|
||
const { ZETA_NETWORK: _ZETA_NETWORK } = process.env; | ||
const zetaNetwork = customZetaNetwork || _ZETA_NETWORK; | ||
|
||
if (!zetaNetwork) throw MissingZetaNetworkError; | ||
return getAddressLib({ address, networkName, zetaNetwork }); | ||
}; |
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
Oops, something went wrong.