Skip to content

Commit

Permalink
fix(jellyfish-network): add missing devnet case (#1991)
Browse files Browse the repository at this point in the history
#### What this PR does / why we need it:

Fixes missing devnet case

#### Additional comments?:

Added support for `devnet` in `legacy-api` and `ocean-api-client`
packages
  • Loading branch information
Jouzo authored Jan 20, 2023
1 parent 8fb4248 commit e07aad2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/legacy-api/src/pipes/NetworkValidationPipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {
PipeTransform
} from '@nestjs/common'

export type SupportedNetwork = 'mainnet' | 'testnet' | 'regtest'
export type SupportedNetwork = 'mainnet' | 'testnet' | 'devnet' | 'regtest'

@Injectable()
export class NetworkValidationPipe implements PipeTransform {
private static readonly VALID_NETWORKS: Set<undefined | SupportedNetwork> = new Set([
undefined, // defaults to 'mainnet'
'mainnet',
'testnet',
'devnet',
'regtest'
])

Expand Down
5 changes: 5 additions & 0 deletions packages/jellyfish-network/__tests__/Network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ describe('getNetwork', () => {
expect(getNetwork('testnet').bech32.hrp).toStrictEqual('tf')
})

it('should get devnet', () => {
expect(getNetwork('devnet').name).toStrictEqual('devnet')
expect(getNetwork('devnet').bech32.hrp).toStrictEqual('tf')
})

it('should get regtest', () => {
expect(getNetwork('regtest').name).toStrictEqual('regtest')
expect(getNetwork('regtest').bech32.hrp).toStrictEqual('bcrt')
Expand Down
2 changes: 2 additions & 0 deletions packages/jellyfish-network/src/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export function getNetwork (network: NetworkName): Network {
return MainNet
case 'testnet':
return TestNet
case 'devnet':
return DevNet
case 'regtest':
return RegTest
default:
Expand Down
2 changes: 1 addition & 1 deletion packages/ocean-api-client/src/OceanApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface OceanApiClientOptions {
/**
* Network that ocean client is configured to
*/
network?: 'mainnet' | 'testnet' | 'regtest' | string
network?: 'mainnet' | 'testnet' | 'devnet' | 'regtest' | string
}

/**
Expand Down

0 comments on commit e07aad2

Please sign in to comment.