Skip to content

Commit adb503f

Browse files
Pierre Geecanonbrother
andauthored
feat(jellyfish-network): add changi (#2143)
<!-- Thanks for sending a pull request! --> #### What this PR does / why we need it: - Add changi network - Update node to latest to fix regression issues #### Which issue(s) does this PR fixes?: <!-- (Optional) Automatically closes linked issue when PR is merged. Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> Fixes # #### Additional comments?: --------- Co-authored-by: canonbrother <[email protected]>
1 parent 9daa1c1 commit adb503f

File tree

9 files changed

+61
-9
lines changed

9 files changed

+61
-9
lines changed

apps/legacy-api/src/pipes/NetworkValidationPipe.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
PipeTransform
66
} from '@nestjs/common'
77

8-
export type SupportedNetwork = 'mainnet' | 'testnet' | 'devnet' | 'regtest'
8+
export type SupportedNetwork = 'mainnet' | 'testnet' | 'devnet' | 'regtest' | 'changi'
99

1010
@Injectable()
1111
export class NetworkValidationPipe implements PipeTransform {
@@ -14,7 +14,8 @@ export class NetworkValidationPipe implements PipeTransform {
1414
'mainnet',
1515
'testnet',
1616
'devnet',
17-
'regtest'
17+
'regtest',
18+
'changi'
1819
])
1920

2021
transform (value: any, metadata: ArgumentMetadata): any {

apps/whale-api/src/app.configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function ENV_VALIDATION_SCHEMA (): any {
3131
return Joi.object({
3232
NODE_ENV: Joi.string().optional(),
3333
WHALE_VERSION: Joi.string().optional(),
34-
WHALE_NETWORK: Joi.string().valid('mainnet', 'testnet', 'regtest', 'devnet').default('regtest'),
34+
WHALE_NETWORK: Joi.string().valid('mainnet', 'testnet', 'regtest', 'devnet', 'changi').default('regtest'),
3535
WHALE_DEFID_URL: Joi.string().optional(),
3636
WHALE_DATABASE_PROVIDER: Joi.string().optional(),
3737
WHALE_DATABASE_LEVEL_LOCATION: Joi.string().optional()

apps/whale-api/src/module.api/masternode.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ const MasternodeConsensusParams = {
2929
newActivationDelay: 1008,
3030
resignDelay: 60,
3131
newResignDelay: 2 * 1008
32+
},
33+
changi: {
34+
activationDelay: 10,
35+
newActivationDelay: 1008,
36+
resignDelay: 60,
37+
newResignDelay: 2 * 1008
3238
}
3339
}
3440

packages/jellyfish-network/__tests__/BitcoinJsLib.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,15 @@ it('should match RegTest network', () => {
3535
expect(network.scriptHash).toStrictEqual(0xc4)
3636
expect(network.messagePrefix).toStrictEqual('\x15Defi Signed Message:\n')
3737
})
38+
39+
it('should match Changi network', () => {
40+
const network = getNetworkBitcoinJsLib('changi')
41+
42+
expect(network.bech32).toStrictEqual('tf')
43+
expect(network.bip32.public).toStrictEqual(0x043587cf)
44+
expect(network.bip32.private).toStrictEqual(0x04358394)
45+
expect(network.wif).toStrictEqual(0xef)
46+
expect(network.pubKeyHash).toStrictEqual(0xf)
47+
expect(network.scriptHash).toStrictEqual(0x80)
48+
expect(network.messagePrefix).toStrictEqual('\x15Defi Signed Message:\n')
49+
})

packages/jellyfish-network/__tests__/Network.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Network, MainNet, RegTest, TestNet, DevNet, getNetwork } from '../src'
1+
import { Network, MainNet, RegTest, TestNet, DevNet, Changi, getNetwork } from '../src'
22

33
it('should be exported', () => {
44
const network: Network = MainNet
@@ -26,6 +26,11 @@ describe('getNetwork', () => {
2626
expect(getNetwork('regtest').name).toStrictEqual('regtest')
2727
expect(getNetwork('regtest').bech32.hrp).toStrictEqual('bcrt')
2828
})
29+
30+
it('should get changi', () => {
31+
expect(getNetwork('changi').name).toStrictEqual('changi')
32+
expect(getNetwork('changi').bech32.hrp).toStrictEqual('tf')
33+
})
2934
})
3035

3136
it('should match MainNet network', () => {
@@ -71,3 +76,14 @@ it('should match RegTest network', () => {
7176
expect(RegTest.scriptHashPrefix).toStrictEqual(0xc4)
7277
expect(RegTest.messagePrefix).toStrictEqual('\x15Defi Signed Message:\n')
7378
})
79+
80+
it('should match Changi network', () => {
81+
expect(Changi.name).toStrictEqual('changi')
82+
expect(Changi.bech32.hrp).toStrictEqual('tf')
83+
expect(Changi.bip32.publicPrefix).toStrictEqual(0x043587cf)
84+
expect(Changi.bip32.privatePrefix).toStrictEqual(0x04358394)
85+
expect(Changi.wifPrefix).toStrictEqual(0xef)
86+
expect(Changi.pubKeyHashPrefix).toStrictEqual(0xf)
87+
expect(Changi.scriptHashPrefix).toStrictEqual(0x80)
88+
expect(Changi.messagePrefix).toStrictEqual('\x15Defi Signed Message:\n')
89+
})

packages/jellyfish-network/src/Network.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type NetworkName = Network['name']
88
* They can be found in DeFiCh/ain project in file chainparams.cpp, under base58Prefixes
99
*/
1010
export interface Network {
11-
name: 'mainnet' | 'testnet' | 'regtest' | 'devnet'
11+
name: 'mainnet' | 'testnet' | 'regtest' | 'devnet' | 'changi'
1212
bech32: {
1313
/** bech32 human readable part */
1414
hrp: 'df' | 'tf' | 'bcrt'
@@ -48,6 +48,8 @@ export function getNetwork (network: NetworkName): Network {
4848
return DevNet
4949
case 'regtest':
5050
return RegTest
51+
case 'changi':
52+
return Changi
5153
default:
5254
throw new Error(`${network as string} network not found`)
5355
}
@@ -104,8 +106,8 @@ export const DevNet: Network = {
104106
...TestNet,
105107
name: 'devnet',
106108
ports: {
107-
rpc: 20554,
108-
p2p: 20555
109+
rpc: 21554,
110+
p2p: 21555
109111
}
110112
}
111113

@@ -130,3 +132,15 @@ export const RegTest: Network = {
130132
p2p: 19555
131133
}
132134
}
135+
136+
/**
137+
* Changi specific DeFi configuration.
138+
*/
139+
export const Changi: Network = {
140+
...TestNet,
141+
name: 'changi',
142+
ports: {
143+
rpc: 20554,
144+
p2p: 20555
145+
}
146+
}

packages/ocean-api-client/src/OceanApiClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface OceanApiClientOptions {
2424
/**
2525
* Network that ocean client is configured to
2626
*/
27-
network?: 'mainnet' | 'testnet' | 'devnet' | 'regtest' | string
27+
network?: 'mainnet' | 'testnet' | 'devnet' | 'regtest' | 'changi' | string
2828
}
2929

3030
/**

packages/testcontainers/src/containers/DeFiDContainer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { NativeChainRpc } from '../index'
66
/**
77
* Types of network as per https://github.com/DeFiCh/ain/blob/bc231241/src/chainparams.cpp#L825-L836
88
*/
9-
type Network = 'mainnet' | 'testnet' | 'devnet' | 'regtest'
9+
type Network = 'mainnet' | 'testnet' | 'devnet' | 'regtest' | 'changi'
1010

1111
/**
1212
* Mandatory options to start defid with

packages/testcontainers/src/containers/NativeChainContainer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ export class NativeChainContainer extends GenericContainer {
9090
'-rpcbind=0.0.0.0',
9191
'-rpcworkqueue=512'
9292
],
93+
changi: [
94+
'-changi=1'
95+
],
9396
testnet: [
9497
'-testnet=1'
9598
],

0 commit comments

Comments
 (0)