-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename package to jellyfish-network (#84)
* rename package to jellyfish-network * updated package-lock.json
- Loading branch information
Showing
11 changed files
with
180 additions
and
137 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
[![npm](https://img.shields.io/npm/v/@defichain/jellyfish-network)](https://www.npmjs.com/package/@defichain/jellyfish-network/v/latest) | ||
[![npm@next](https://img.shields.io/npm/v/@defichain/jellyfish-network/next)](https://www.npmjs.com/package/@defichain/jellyfish-network/v/next) | ||
|
||
# @defichain/jellyfish-network | ||
|
||
DeFi blockchain various network configuration for main, net and regtest. |
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,51 @@ | ||
import { Network, MainNet, RegTest, TestNet, getNetwork } from '../src' | ||
|
||
it('should be exported', () => { | ||
const network: Network = MainNet | ||
expect(network.bech32.hrp).toBe('df') | ||
expect(network.wifPrefix).toBe(0x80) | ||
}) | ||
|
||
describe('getNetwork', () => { | ||
it('should get mainnet', () => { | ||
expect(getNetwork('mainnet').bech32.hrp).toBe('df') | ||
}) | ||
|
||
it('should get testnet', () => { | ||
expect(getNetwork('testnet').bech32.hrp).toBe('tf') | ||
}) | ||
|
||
it('should get regtest', () => { | ||
expect(getNetwork('regtest').bech32.hrp).toBe('bcrt') | ||
}) | ||
}) | ||
|
||
it('should match MainNet network', () => { | ||
expect(MainNet.bech32.hrp).toBe('df') | ||
expect(MainNet.bip32.publicPrefix).toBe(0x0488b21e) | ||
expect(MainNet.bip32.privatePrefix).toBe(0x0488ade4) | ||
expect(MainNet.wifPrefix).toBe(0x80) | ||
expect(MainNet.pubKeyHashPrefix).toBe(0x12) | ||
expect(MainNet.scriptHashPrefix).toBe(0x5a) | ||
expect(MainNet.messagePrefix).toBe('\x15Defi Signed Message:\n') | ||
}) | ||
|
||
it('should match TestNet network', () => { | ||
expect(TestNet.bech32.hrp).toBe('tf') | ||
expect(TestNet.bip32.publicPrefix).toBe(0x043587cf) | ||
expect(TestNet.bip32.privatePrefix).toBe(0x04358394) | ||
expect(TestNet.wifPrefix).toBe(0xef) | ||
expect(TestNet.pubKeyHashPrefix).toBe(0xf) | ||
expect(TestNet.scriptHashPrefix).toBe(0x80) | ||
expect(TestNet.messagePrefix).toBe('\x15Defi Signed Message:\n') | ||
}) | ||
|
||
it('should match RegTest network', () => { | ||
expect(RegTest.bech32.hrp).toBe('bcrt') | ||
expect(RegTest.bip32.publicPrefix).toBe(0x043587cf) | ||
expect(RegTest.bip32.privatePrefix).toBe(0x04358394) | ||
expect(RegTest.wifPrefix).toBe(0xef) | ||
expect(RegTest.pubKeyHashPrefix).toBe(0x6f) | ||
expect(RegTest.scriptHashPrefix).toBe(0xc4) | ||
expect(RegTest.messagePrefix).toBe('\x15Defi Signed Message:\n') | ||
}) |
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
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,92 @@ | ||
/** | ||
* Network specific DeFi Wallet configuration. | ||
* They can be found in DeFiCh/ain project in file chainparams.cpp, under base58Prefixes | ||
*/ | ||
export interface Network { | ||
bech32: { | ||
/** bech32 human readable part */ | ||
hrp: string | ||
} | ||
bip32: { | ||
/** base58Prefixes.EXT_PUBLIC_KEY */ | ||
publicPrefix: number | ||
/** base58Prefixes.EXT_SECRET_KEY */ | ||
privatePrefix: number | ||
} | ||
/** base58Prefixes.SECRET_KEY */ | ||
wifPrefix: number | ||
/** base58Prefixes.PUBKEY_ADDRESS */ | ||
pubKeyHashPrefix: number | ||
/** base58Prefixes.SCRIPT_ADDRESS */ | ||
scriptHashPrefix: number | ||
/** For message signing. */ | ||
messagePrefix: string | ||
} | ||
|
||
/** | ||
* @param network name | ||
* @return Network specific DeFi Wallet configuration | ||
*/ | ||
export function getNetwork (network: 'mainnet' | 'testnet' | 'regtest'): Network { | ||
switch (network) { | ||
case 'mainnet': | ||
return MainNet | ||
case 'testnet': | ||
return TestNet | ||
case 'regtest': | ||
return RegTest | ||
default: | ||
throw new Error(`${network as string} network not found`) | ||
} | ||
} | ||
|
||
/** | ||
* MainNet specific DeFi Wallet configuration. | ||
*/ | ||
export const MainNet: Network = { | ||
bech32: { | ||
hrp: 'df' | ||
}, | ||
bip32: { | ||
publicPrefix: 0x0488b21e, | ||
privatePrefix: 0x0488ade4 | ||
}, | ||
wifPrefix: 0x80, | ||
pubKeyHashPrefix: 0x12, | ||
scriptHashPrefix: 0x5a, | ||
messagePrefix: '\x15Defi Signed Message:\n' | ||
} | ||
|
||
/** | ||
* TestNet specific DeFi Wallet configuration. | ||
*/ | ||
export const TestNet: Network = { | ||
bech32: { | ||
hrp: 'tf' | ||
}, | ||
bip32: { | ||
publicPrefix: 0x043587cf, | ||
privatePrefix: 0x04358394 | ||
}, | ||
wifPrefix: 0xef, | ||
pubKeyHashPrefix: 0xf, | ||
scriptHashPrefix: 0x80, | ||
messagePrefix: '\x15Defi Signed Message:\n' | ||
} | ||
|
||
/** | ||
* RegTest specific DeFi Wallet configuration. | ||
*/ | ||
export const RegTest: Network = { | ||
bech32: { | ||
hrp: 'bcrt' | ||
}, | ||
bip32: { | ||
publicPrefix: 0x043587cf, | ||
privatePrefix: 0x04358394 | ||
}, | ||
wifPrefix: 0xef, | ||
pubKeyHashPrefix: 0x6f, | ||
scriptHashPrefix: 0xc4, | ||
messagePrefix: '\x15Defi Signed Message:\n' | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.