Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Lavinia Talpas authored and Lavinia Talpas committed Oct 31, 2024
1 parent 9f76b95 commit 45549aa
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Crestal JavaScript SDK

JavaScript SDK for Crestal's services, supporting Berachain Testnet (80084) and Polygon Amoy (80002).
JavaScript SDK for Crestal's services.

## Installation

Expand Down Expand Up @@ -70,12 +70,12 @@ Then run it with: `npx ts-node --esm YOUR_SCRIPT.ts` or `node YOUR_SCRIPT.js`.

### Chain Validation

For a full list of supported networks and their chain Ids, please check
[here](https://docs.crestal.xyz/networks/supported-networks).

```typescript
import { isChainSupported, supportedChainIds } from 'crestal-js-sdk/utils';

// Check supported chains
console.log('Supported chains:', supportedChainIds); // [80084, 80002]

// Validate a specific chain
const isValid = isChainSupported(80084); // true
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crestal-js-sdk",
"version": "1.2.0",
"version": "1.2.1",
"description": "JavaScript SDK for Crestal Network services.",
"main": "dist/cjs/typescript-sdk/index.js",
"module": "dist/esm/typescript-sdk/index.js",
Expand Down
2 changes: 1 addition & 1 deletion utils/examples/submitProposalExample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function main() {
rank: 1,
type: "public",
da: {
chain_id: 80084,
chain_id: chainId,
da_name: "Avail",
network_type: "Testnet",
gas_token: "ETH",
Expand Down
4 changes: 0 additions & 4 deletions utils/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,3 @@ export const login = async (privateKey: string, userAddress: string, chainId: nu
logErrorDetails(err);
}
};
// Usage example
const privateKey = '469f21a9bf88257a595177404d4765a142e4304a8bffa89d93a8fbf15ca1d3a0';
const userAddress = '0x1e22A1C3AB5DfbA41d61d546f39b08A43410caC8';
login(privateKey, userAddress, 80084);
4 changes: 4 additions & 0 deletions utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ export type DAName =
| "Ethereum";

export type NetworkType = "Mainnet" | "Testnet";

export const supportedChainIdsArray = [80002, 80084, 97] as const;

export type SupportedChainIds = typeof supportedChainIdsArray[number];
11 changes: 6 additions & 5 deletions utils/validateChain.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export const supportedChainIds = [80084, 80002]; // berachainTestnet: 80084, polygonAmoy: 80002
import { supportedChainIdsArray } from './types';

/**
* Utility function to check if a chain ID is supported.
*
* @param chainId - The chain ID to check.
* @returns A boolean indicating if the chain is supported.
*
* @param {number} chainId - The chain ID to check.
* @returns {boolean} A boolean indicating if the chain is supported.
*/
export const isChainSupported = (chainId) => supportedChainIds.includes(chainId);
export const isChainSupported = (chainId) => supportedChainIdsArray.includes(chainId);
5 changes: 3 additions & 2 deletions utils/validateChain.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export const supportedChainIds = [80084, 80002]; // berachainTestnet: 80084, polygonAmoy: 80002
import { SupportedChainIds, supportedChainIdsArray } from './types';

/**
* Utility function to check if a chain ID is supported.
*
* @param chainId - The chain ID to check.
* @returns A boolean indicating if the chain is supported.
*/
export const isChainSupported = (chainId: number): boolean => supportedChainIds.includes(chainId);
export const isChainSupported = (chainId: number): chainId is SupportedChainIds =>
supportedChainIdsArray.includes(chainId as SupportedChainIds);

0 comments on commit 45549aa

Please sign in to comment.