Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update chain enums #716

Merged
merged 3 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/gorgeous-plants-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@moralisweb3/evm-utils': patch
'@moralisweb3/sol-utils': patch
---

Deprecate old testnets and add enums for SolNetwork
7 changes: 7 additions & 0 deletions packages/evmUtils/src/dataTypes/EvmChain/EvmChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class EvmChain implements MoralisData, EvmChainable {
* Returns ROPSTEN chain
*
* @example EvmChain.ROPSTEN
* @deprecated see https://ethereum.org/en/developers/docs/networks/
*/
public static get ROPSTEN() {
return EvmChain.create(3);
Expand All @@ -46,6 +47,7 @@ export class EvmChain implements MoralisData, EvmChainable {
* Returns RINKEBY chain
*
* @example EvmChain.RINKEBY
* @deprecated see https://ethereum.org/en/developers/docs/networks/
*/
public static get RINKEBY() {
return EvmChain.create(4);
Expand All @@ -64,11 +66,16 @@ export class EvmChain implements MoralisData, EvmChainable {
* Returns KOVAN chain
*
* @example EvmChain.KOVAN
* @deprecated see https://ethereum.org/en/developers/docs/networks/
*/
public static get KOVAN() {
return EvmChain.create(42);
}

public static get SEPOLIA() {
return EvmChain.create(11155111);
}

/**
* Returns POLYGON chain
*
Expand Down
18 changes: 18 additions & 0 deletions packages/solUtils/src/dataTypes/SolNetwork/SolNetwork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ describe('SolNetwork', () => {
expect(network.format()).toEqual('mainnet');
});

it('creates an instance based on MAINNET enum', () => {
const network = SolNetwork.MAINNET;

expect(network.network).toEqual('mainnet');
expect(network.toJSON()).toEqual('mainnet');
expect(network.toString()).toEqual('mainnet');
expect(network.format()).toEqual('mainnet');
});

it('creates an instance based on DEVNET enum', () => {
const network = SolNetwork.DEVNET;

expect(network.network).toEqual('devnet');
expect(network.toJSON()).toEqual('devnet');
expect(network.toString()).toEqual('devnet');
expect(network.format()).toEqual('devnet');
});

it('throws an error when a network is not supported', () => {
expect(() => SolNetwork.create('UNKNOWN')).toThrowError('Solana network is not supported');
});
Expand Down
18 changes: 18 additions & 0 deletions packages/solUtils/src/dataTypes/SolNetwork/SolNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ export type SolNetworkish = SolNetwork | SolNetworkNameish;
* @category DataType
*/
export class SolNetwork implements MoralisData {
/**
* Returns MAINNET network
*
* @example SolNetwork.MAINNET
*/
public static get MAINNET() {
return SolNetwork.create('mainnet');
}

/**
* Returns DEVNET network
*
* @example SolNetwork.MAINNET
*/
public static get DEVNET() {
return SolNetwork.create('devnet');
}

/**
* Create a new instance of SolNetwork from any valid network input.
*
Expand Down