-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added all registry submodules, added typescript types, added unit tests, setup nx package for @sei-js/registry * Updated assetlist and package.json * @sei-js/registry - Added a new package for exporting the official sei chain registry as constants as well as the community driven asset list - Added typedoc comments with examples to each variable, interface, and type - Added unit tests with 100% test coverage - Cleaned up tsconfigs across all packages * Updated gitmodules with new community asset list * Added submodule for community asset list * Removed Babel in favor of TSC * Added typedoc comments * Removed duplicate js files from failed tsc, fixed testing issue * Made variable names UPPERCASE As the variables are now uppercase the typescript types can be the same name and not end with "Type" * Added changeset * Updated typdoc comments for new variable names
- Loading branch information
1 parent
42cd65f
commit 53cc721
Showing
38 changed files
with
722 additions
and
52 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,5 @@ | ||
--- | ||
"@sei-js/registry": major | ||
--- | ||
|
||
Intitial release of @sei-js/registry which contains exports from the official Sei chain registry as well as the community token list |
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,6 @@ | ||
[submodule "packages/registry/community-assetlist"] | ||
path = packages/registry/community-assetlist | ||
url = https://github.com/Sei-Public-Goods/sei-assetlist.git | ||
[submodule "packages/registry/chain-registry"] | ||
path = packages/registry/chain-registry | ||
url = https://github.com/sei-protocol/chain-registry.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
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
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
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,2 @@ | ||
node_modules | ||
dist |
File renamed without changes.
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,13 @@ | ||
src | ||
node_modules | ||
docs | ||
coverage/ | ||
|
||
.gitkeep | ||
jest.config.ts | ||
tsconfig.json | ||
|
||
yarn-error.log | ||
|
||
.eslintignore | ||
eslintrc.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# @sei-js/registry | ||
This package contains TypeScript typed exports for the Sei registry repository as well as the community asset-list repository. | ||
|
||
## Installation | ||
```bash | ||
yarn add @sei-js/registry | ||
``` | ||
|
||
## Usage | ||
```typescript | ||
import { TOKEN_LIST, NETWORKS, IBC_INFO, GAS_INFO } from '@sei-js/registry' | ||
|
||
const uAtom = TOKEN_LIST.find(asset => asset.denom === 'uatom') | ||
``` |
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,2 @@ | ||
### Init submodules | ||
`git submodule update --init --recursive` |
Submodule chain-registry
added at
71938f
Submodule community-assetlist
added at
831406
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,3 @@ | ||
{ | ||
"extends": ["../../eslint.base.json", "eslint:recommended", "plugin:@typescript-eslint/recommended"] | ||
} |
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,8 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'], | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
modulePathIgnorePatterns: ['<rootDir>/dist/'] | ||
}; |
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,50 @@ | ||
{ | ||
"name": "@sei-js/registry", | ||
"version": "0.1.0", | ||
"description": "TypeScript library for Sei chain constants and assets", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"types": "./dist/types/index.d.ts", | ||
"sideEffects": false, | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"prebuild": "rimraf dist", | ||
"build": "yarn build:cjs && yarn build:esm && yarn build:prettier && yarn build:types", | ||
"build:cjs": "tsc --outDir dist/cjs --module commonjs", | ||
"build:esm": "tsc --outDir dist/esm --module esnext", | ||
"build:types": "tsc --project ./tsconfig.declaration.json", | ||
"build:prettier": "prettier --write 'dist/**/*.js'", | ||
"docs": "typedoc --out docs", | ||
"test": "jest", | ||
"lint": "eslint --ext .ts" | ||
}, | ||
"homepage": "https://github.com/sei-protocol/sei-js#readme", | ||
"keywords": [ | ||
"sei", | ||
"javascript", | ||
"typescript" | ||
], | ||
"repository": "[email protected]:sei-protocol/sei-js.git", | ||
"license": "MIT", | ||
"private": false, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": {}, | ||
"peerDependencies": {}, | ||
"devDependencies": { | ||
"@types/jest": "^29.5.5", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.2.5", | ||
"ts-jest": "^29.1.1" | ||
}, | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/cjs/index.js", | ||
"types": "./dist/types/index.d.ts" | ||
} | ||
} | ||
} |
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,19 @@ | ||
import { CHAIN_INFO } from '../index'; | ||
|
||
describe('ChainInfo Tests', () => { | ||
it('has the required properties with correct types', () => { | ||
expect(typeof CHAIN_INFO.chain_name).toBe('string'); | ||
expect(['mainnet', 'testnet', 'devnet']).toContain(CHAIN_INFO.network_type); | ||
expect(typeof CHAIN_INFO.chain_id).toBe('string'); | ||
expect(typeof CHAIN_INFO.daemon_name).toBe('string'); | ||
expect(typeof CHAIN_INFO.bech32_prefix).toBe('string'); | ||
expect(Array.isArray(CHAIN_INFO.key_algos)).toBeTruthy(); | ||
expect(typeof CHAIN_INFO.slip44).toBe('number'); | ||
expect(typeof CHAIN_INFO.fee_token).toBe('string'); | ||
expect(Array.isArray(CHAIN_INFO.supported_wallets)).toBeTruthy(); | ||
}); | ||
|
||
it("includes 'secp256k1' in key_algos", () => { | ||
expect(CHAIN_INFO.key_algos).toContain('secp256k1'); | ||
}); | ||
}); |
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,37 @@ | ||
import ChainInfoJSON from '../../chain-registry/chain_info.json'; | ||
|
||
/** | ||
* Represents the essential information about an official Sei network. | ||
*/ | ||
export interface ChainInfo { | ||
/** The name of the chain. (Sei) */ | ||
chain_name: string; | ||
/** The type of network, indicating whether it's a mainnet, testnet, or devnet. */ | ||
network_type: 'mainnet' | 'testnet' | 'devnet'; | ||
/** The unique identifier for the Sei network. 'pacific-1' | 'atlantic-2' | 'arctic-1' */ | ||
chain_id: string; | ||
/** The name of the daemon process that runs the node software for the blockchain. (seid) */ | ||
daemon_name: string; | ||
/** The prefix used for Bech32 encoded addresses on the network. (sei) */ | ||
bech32_prefix: string; | ||
/** An array of cryptographic algorithms supported by the network for key generation. */ | ||
key_algos: string[]; | ||
/** The SLIP-44 coin type number assigned to the network for HD wallet purposes. */ | ||
slip44: number; | ||
/** The denomination of the fee token used for transaction fees on the network. */ | ||
fee_token: string; | ||
/** A list of wallet software that supports this blockchain network. */ | ||
supported_wallets: string[]; | ||
} | ||
|
||
/** | ||
* A constant that holds the chain information, imported from the official Sei [chain-registry](https://github.com/sei-protocol/chain-registry). | ||
* | ||
* @example | ||
* ```tsx | ||
* import { CHAIN_INFO } from '@sei-js/registry'; | ||
* | ||
* console.log(CHAIN_INFO.bech32_prefix); // 'sei' | ||
* ``` | ||
*/ | ||
export const CHAIN_INFO: ChainInfo = ChainInfoJSON as ChainInfo; |
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,35 @@ | ||
import { ModuleAdjustments, GAS_INFO, ChainGasInfo } from '../index'; | ||
import { Network } from '../../index'; | ||
|
||
describe('GasInfo Tests', () => { | ||
// Check if GasInfo contains all expected networks | ||
it('contains all required networks', () => { | ||
const expectedNetworks: Network[] = ['pacific-1', 'atlantic-2', 'arctic-1']; | ||
expectedNetworks.forEach((network) => { | ||
expect(GAS_INFO).toHaveProperty(network); | ||
}); | ||
}); | ||
|
||
// Validate the structure of GasInfo for each network | ||
it('validates structure for each network', () => { | ||
Object.values(GAS_INFO).forEach((info: ChainGasInfo) => { | ||
expect(typeof info.denom).toBe('string'); | ||
expect(typeof info.min_gas_price).toBe('number'); | ||
expect(info).toHaveProperty('module_adjustments'); | ||
expect(info.module_adjustments).toHaveProperty('dex'); | ||
|
||
const { dex }: { dex: ModuleAdjustments['dex'] } = info.module_adjustments; | ||
expect(typeof dex.sudo_gas_price).toBe('number'); | ||
expect(typeof dex.order_placement).toBe('number'); | ||
expect(typeof dex.order_cancellation).toBe('number'); | ||
}); | ||
}); | ||
|
||
// Example: Check specific values for a network (e.g., 'pacific-1') | ||
it('checks specific values for pacific-1', () => { | ||
const pacific1 = GAS_INFO['pacific-1']; | ||
expect(pacific1.denom).toBe('usei'); | ||
expect(pacific1.min_gas_price).toBeGreaterThanOrEqual(0.01); | ||
expect(pacific1.module_adjustments.dex.sudo_gas_price).toBeLessThanOrEqual(0.02); | ||
}); | ||
}); |
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,53 @@ | ||
import GasInfoJSON from '../../chain-registry/gas.json'; | ||
import { Network } from '../index'; | ||
|
||
/** | ||
* Defines the gas price adjustments for specific modules within the Sei blockchain, | ||
* allowing for differentiated gas pricing based on transaction type. | ||
*/ | ||
export interface ModuleAdjustments { | ||
/** Adjustments specifically for decentralized exchange (DEX) transactions. */ | ||
dex: { | ||
/** The sudo (superuser) gas price for critical operations. */ | ||
sudo_gas_price: number; | ||
/** The gas price for placing orders on the DEX. */ | ||
order_placement: number; | ||
/** The gas price for canceling orders on the DEX. */ | ||
order_cancellation: number; | ||
}; | ||
} | ||
|
||
/** | ||
* Represents the gas information for a specific Sei network, | ||
* including the default minimum gas price and module-specific adjustments. | ||
*/ | ||
export interface ChainGasInfo { | ||
/** The denomination of the gas fee. */ | ||
denom: string; | ||
/** The minimum gas price required for transactions on the network. */ | ||
min_gas_price: number; | ||
/** Gas price adjustments for specific modules. */ | ||
module_adjustments: ModuleAdjustments; | ||
} | ||
|
||
/** | ||
* A mapping of network identifiers (chain id's) to their respective gas information. | ||
*/ | ||
type GasInfo = { | ||
/** Each network identifier is associated with its gas information. */ | ||
[network in Network]: ChainGasInfo; | ||
}; | ||
|
||
/** | ||
* A constant holding the gas information for each official Sei network, imported from the official Sei [chain-registry](https://github.com/sei-protocol/chain-registry). | ||
* This includes details such as the gas denomination, minimum gas price, and module-specific adjustments. | ||
* | ||
* @example | ||
* ```tsx | ||
* import { GAS_INFO } from '@sei-js/registry'; | ||
* | ||
* const pacific1Info = GAS_INFO['pacific-1']; | ||
* console.log(pacific1Info.denom); // 'usei' | ||
* ``` | ||
*/ | ||
export const GAS_INFO: GasInfo = GasInfoJSON as GasInfo; |
Oops, something went wrong.