Skip to content

Commit 7cc4f8e

Browse files
feat(midnight): added night coin skeleton
Ticket: COIN-7475
1 parent 82e8bf9 commit 7cc4f8e

9 files changed

Lines changed: 350 additions & 0 deletions

File tree

modules/statics/src/account.ts

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ export interface VetTokenConstructorOptions extends AccountConstructorOptions {
169169
contractAddress: string;
170170
gasTankToken?: string;
171171
}
172+
173+
/**
174+
* Midnight Network token (DUST) constructor options
175+
* DUST is the fee token on the Midnight Network
176+
*/
177+
export interface NightTokenConstructorOptions extends AccountConstructorOptions {
178+
// Token identifier (e.g., 'dust' for the fee token)
179+
tokenId: string;
180+
}
181+
172182
export interface CosmosTokenConstructorOptions extends AccountConstructorOptions {
173183
denom: string;
174184
}
@@ -706,6 +716,20 @@ export class VetToken extends AccountCoinToken {
706716
}
707717
}
708718

719+
/**
720+
* Midnight Network supports the DUST token for transaction fees.
721+
* DUST is a native token on the Midnight Network used to pay for transaction fees.
722+
*/
723+
export class NightToken extends AccountCoinToken {
724+
public tokenId: string;
725+
constructor(options: NightTokenConstructorOptions) {
726+
super({
727+
...options,
728+
});
729+
this.tokenId = options.tokenId;
730+
}
731+
}
732+
709733
/**
710734
* Cosmos network supports tokens
711735
* Cosmos tokens work similar to native coins, but the token is determined by
@@ -3778,6 +3802,94 @@ export function tvetToken(
37783802
);
37793803
}
37803804

3805+
/**
3806+
* Factory function for Night token (DUST) instances.
3807+
*
3808+
* @param id uuid v4
3809+
* @param name unique identifier of the token
3810+
* @param fullName Complete human-readable name of the token
3811+
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
3812+
* @param tokenId Token identifier (e.g., 'dust')
3813+
* @param asset Asset which this coin represents
3814+
* @param features Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
3815+
* @param prefix Optional token prefix. Defaults to empty string
3816+
* @param suffix Optional token suffix. Defaults to token name.
3817+
* @param network Optional token network. Defaults to the mainnet Night network.
3818+
* @param primaryKeyCurve The elliptic curve for this chain/token
3819+
*/
3820+
export function nightToken(
3821+
id: string,
3822+
name: string,
3823+
fullName: string,
3824+
decimalPlaces: number,
3825+
tokenId: string,
3826+
asset: UnderlyingAsset,
3827+
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
3828+
prefix = '',
3829+
suffix: string = name.toUpperCase(),
3830+
network: AccountNetwork = Networks.main.night,
3831+
primaryKeyCurve: KeyCurve = KeyCurve.Ed25519
3832+
) {
3833+
return Object.freeze(
3834+
new NightToken({
3835+
id,
3836+
name,
3837+
fullName,
3838+
network,
3839+
tokenId,
3840+
prefix,
3841+
suffix,
3842+
features,
3843+
decimalPlaces,
3844+
asset,
3845+
isToken: true,
3846+
primaryKeyCurve,
3847+
baseUnit: BaseUnit.NIGHT,
3848+
})
3849+
);
3850+
}
3851+
3852+
/**
3853+
* Factory function for testnet Night token (DUST) instances.
3854+
*
3855+
* @param id uuid v4
3856+
* @param name unique identifier of the token
3857+
* @param fullName Complete human-readable name of the token
3858+
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
3859+
* @param tokenId Token identifier (e.g., 'tdust')
3860+
* @param asset Asset which this coin represents
3861+
* @param features Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
3862+
* @param prefix Optional token prefix. Defaults to empty string
3863+
* @param suffix Optional token suffix. Defaults to token name.
3864+
* @param network Optional token network. Defaults to the testnet Night network.
3865+
*/
3866+
export function tnightToken(
3867+
id: string,
3868+
name: string,
3869+
fullName: string,
3870+
decimalPlaces: number,
3871+
tokenId: string,
3872+
asset: UnderlyingAsset,
3873+
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
3874+
prefix = '',
3875+
suffix: string = name.toUpperCase(),
3876+
network: AccountNetwork = Networks.test.night
3877+
) {
3878+
return nightToken(
3879+
id,
3880+
name,
3881+
fullName,
3882+
decimalPlaces,
3883+
tokenId,
3884+
asset,
3885+
features,
3886+
prefix,
3887+
suffix,
3888+
network,
3889+
KeyCurve.Ed25519
3890+
);
3891+
}
3892+
37813893
/**
37823894
* Factory function for Vet NFT collections.
37833895
*

modules/statics/src/allCoinsAndTokens.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import {
5555
} from './account';
5656
import { ada } from './ada';
5757
import { avaxp } from './avaxp';
58+
import { night } from './night';
5859
import { BaseUnit, CoinFeature, KeyCurve, UnderlyingAsset } from './base';
5960
import { canton } from './canton';
6061
import { erc20Coins } from './coins/erc20Coins';
@@ -68,6 +69,7 @@ import { lightningCoins } from './lightning';
6869
import { sip10Tokens } from './coins/sip10Tokens';
6970
import { nep141Tokens } from './coins/nep141Tokens';
7071
import { vetTokens } from './coins/vetTokens';
72+
import { nightTokens } from './coins/nightTokens';
7173
import { cosmosTokens } from './coins/cosmosTokens';
7274
import { jettonTokens } from './coins/jettonTokens';
7375
import { polyxTokens } from './coins/polyxTokens';
@@ -105,6 +107,7 @@ import {
105107
INJECTIVE_FEATURES,
106108
IOTA_FEATURES,
107109
NEAR_FEATURES,
110+
NIGHT_FEATURES,
108111
OAS_FEATURES,
109112
OPETH_FEATURES,
110113
POLYGON_FEATURES,
@@ -155,6 +158,7 @@ export const allCoinsAndTokens = [
155158
...sip10Tokens,
156159
...nep141Tokens,
157160
...vetTokens,
161+
...nightTokens,
158162
...cosmosTokens,
159163
...botTokens,
160164
...adaTokens,
@@ -199,6 +203,23 @@ export const allCoinsAndTokens = [
199203
UnderlyingAsset.ADA,
200204
ADA_FEATURES
201205
),
206+
// Midnight Network - Privacy-first blockchain using zero-knowledge proofs
207+
night(
208+
'b1c2d3e4-5f6a-7b8c-9d0e-1f2a3b4c5d6e',
209+
'night',
210+
'Midnight',
211+
Networks.main.night,
212+
UnderlyingAsset.NIGHT,
213+
NIGHT_FEATURES
214+
),
215+
night(
216+
'c2d3e4f5-6a7b-8c9d-0e1f-2a3b4c5d6e7f',
217+
'tnight',
218+
'Testnet Midnight',
219+
Networks.test.night,
220+
UnderlyingAsset.NIGHT,
221+
NIGHT_FEATURES
222+
),
202223
account(
203224
'ec41e62a-cc57-4aa0-9b9e-217da1226817',
204225
'algo',

modules/statics/src/base.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export enum CoinFamily {
8787
CTC = 'ctc',
8888
HYPEEVM = 'hypeevm',
8989
NEAR = 'near',
90+
NIGHT = 'night', // Midnight Network
9091
OAS = 'oas',
9192
OFC = 'ofc',
9293
OG = 'og',
@@ -613,6 +614,9 @@ export enum UnderlyingAsset {
613614
MORPH = 'morph',
614615
MORPHETH = 'morpheth',
615616
NEAR = 'near',
617+
NIGHT = 'night', // Midnight Network
618+
'night:dust' = 'night:dust', // Midnight Dust token (fee token)
619+
'tnight:tdust' = 'tnight:tdust', // Testnet Midnight Dust token
616620
OAS = 'oas',
617621
OG = 'og',
618622
OKBXLAYER = 'okbxlayer',
@@ -3609,6 +3613,7 @@ export enum BaseUnit {
36093613
SUI = 'MIST',
36103614
TON = 'nanoton',
36113615
NEAR = 'yocto',
3616+
NIGHT = 'dust', // Midnight Network smallest unit
36123617
OFC = 'ofcCoin',
36133618
OSMO = 'uosmo',
36143619
FIAT = 'fiatCoin',

modules/statics/src/coinFeatures.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,26 @@ export const VET_FEATURES = [
715715
];
716716
export const VET_TOKEN_FEATURES = VET_FEATURES.filter((feature) => feature !== CoinFeature.SUPPORTS_TOKENS);
717717

718+
/**
719+
* Midnight Network (NIGHT) features
720+
* Night is a UTXO-based privacy chain using Ed25519 and ZK proofs
721+
* Minimal features enabled for skeleton implementation
722+
*/
723+
export const NIGHT_FEATURES = [
724+
CoinFeature.UNSPENT_MODEL,
725+
CoinFeature.TSS,
726+
CoinFeature.TSS_COLD,
727+
CoinFeature.TRANSACTION_DATA,
728+
CoinFeature.REQUIRES_BIG_NUMBER,
729+
CoinFeature.SUPPORTS_TOKENS, // Supports DUST token
730+
];
731+
732+
/**
733+
* Midnight Network token (DUST) features
734+
* DUST is the fee token on the Midnight Network
735+
*/
736+
export const NIGHT_TOKEN_FEATURES = NIGHT_FEATURES.filter((feature) => feature !== CoinFeature.SUPPORTS_TOKENS);
737+
718738
export const EVM_NON_EIP1559_FEATURES = [...EVM_FEATURES.filter((feature) => feature !== CoinFeature.EIP1559)];
719739

720740
export const XDC_FEATURES = [...EVM_NON_EIP1559_FEATURES, CoinFeature.ERC20_BULK_TRANSACTION];
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { nightToken, tnightToken } from '../account';
2+
import { UnderlyingAsset } from '../base';
3+
import { NIGHT_TOKEN_FEATURES } from '../coinFeatures';
4+
5+
/**
6+
* DUST tokens on the Midnight Network
7+
* DUST is the native fee token used to pay for transactions on Midnight
8+
*/
9+
export const nightTokens = [
10+
nightToken(
11+
'f8a9b2c1-3d4e-5f6a-7b8c-9d0e1f2a3b4c', // UUID for night:dust
12+
'night:dust',
13+
'Midnight Dust',
14+
8, // 8 decimal places like NIGHT
15+
'dust',
16+
UnderlyingAsset['night:dust'],
17+
NIGHT_TOKEN_FEATURES
18+
),
19+
tnightToken(
20+
'a1b2c3d4-5e6f-7a8b-9c0d-e1f2a3b4c5d6', // UUID for tnight:tdust
21+
'tnight:tdust',
22+
'Testnet Midnight Dust',
23+
8, // 8 decimal places like NIGHT
24+
'tdust',
25+
UnderlyingAsset['tnight:tdust'],
26+
NIGHT_TOKEN_FEATURES
27+
),
28+
];

modules/statics/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export * from './tokenConfig';
66
export { OfcCoin } from './ofc';
77
export { UtxoCoin } from './utxo';
88
export { LightningCoin } from './lightning';
9+
export { Night } from './night';
910
export {
1011
AccountCoin,
1112
GasTankAccountCoin,
@@ -30,6 +31,7 @@ export {
3031
Nep141Token,
3132
VetToken,
3233
VetNFTCollection,
34+
NightToken,
3335
CosmosChainToken,
3436
AdaToken,
3537
JettonToken,

modules/statics/src/networks.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ export interface AdaNetwork extends BaseNetwork {
9393
coinsPerUtxoWord: number;
9494
}
9595

96+
/**
97+
* Midnight Network - Privacy-first blockchain using zero-knowledge proofs
98+
*/
99+
export interface NightNetwork extends BaseNetwork {
100+
// GraphQL indexer endpoint for querying chain state
101+
readonly indexerUrl: string;
102+
// RPC WebSocket endpoint for node communication
103+
readonly rpcUrl: string;
104+
}
105+
96106
export interface AvalancheNetwork extends BaseNetwork {
97107
readonly alias: string;
98108
readonly blockchainID: string;
@@ -236,6 +246,29 @@ class AdaTestnet extends Testnet implements AdaNetwork {
236246
stakeKeyDeposit = 2000000;
237247
}
238248

249+
/**
250+
* Midnight Network - Privacy-first blockchain using zero-knowledge proofs
251+
* Mainnet configuration
252+
*/
253+
class Night extends Mainnet implements NightNetwork {
254+
name = 'Midnight';
255+
family = CoinFamily.NIGHT;
256+
explorerUrl = 'https://explorer.midnight.network/';
257+
indexerUrl = 'https://indexer.midnight.network/api/v3/graphql';
258+
rpcUrl = 'wss://rpc.midnight.network';
259+
}
260+
261+
/**
262+
* Midnight Network Testnet (Preprod)
263+
*/
264+
class NightTestnet extends Testnet implements NightNetwork {
265+
name = 'MidnightTestnet';
266+
family = CoinFamily.NIGHT;
267+
explorerUrl = 'https://explorer.preprod.midnight.network/';
268+
indexerUrl = 'https://indexer.preprod.midnight.network/api/v3/graphql';
269+
rpcUrl = 'wss://rpc.preprod.midnight.network';
270+
}
271+
239272
class Apt extends Mainnet implements AccountNetwork {
240273
name = 'Apt';
241274
family = CoinFamily.APT;
@@ -2460,6 +2493,7 @@ export const Networks = {
24602493
sonic: Object.freeze(new Sonic()),
24612494
sui: Object.freeze(new Sui()),
24622495
near: Object.freeze(new Near()),
2496+
night: Object.freeze(new Night()),
24632497
stx: Object.freeze(new Stx()),
24642498
somi: Object.freeze(new Somi()),
24652499
soneium: Object.freeze(new Soneium()),
@@ -2573,6 +2607,7 @@ export const Networks = {
25732607
sol: Object.freeze(new SolTestnet()),
25742608
sui: Object.freeze(new SuiTestnet()),
25752609
near: Object.freeze(new NearTestnet()),
2610+
night: Object.freeze(new NightTestnet()),
25762611
stx: Object.freeze(new StxTestnet()),
25772612
stt: Object.freeze(new SomniaTestnet()),
25782613
soneium: Object.freeze(new SoneiumTestnet()),

0 commit comments

Comments
 (0)