Skip to content
Draft
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
112 changes: 112 additions & 0 deletions modules/statics/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ export interface VetTokenConstructorOptions extends AccountConstructorOptions {
contractAddress: string;
gasTankToken?: string;
}

/**
* Midnight Network token (DUST) constructor options
* DUST is the fee token on the Midnight Network
*/
export interface NightTokenConstructorOptions extends AccountConstructorOptions {
// Token identifier (e.g., 'dust' for the fee token)
tokenId: string;
}

export interface CosmosTokenConstructorOptions extends AccountConstructorOptions {
denom: string;
}
Expand Down Expand Up @@ -706,6 +716,20 @@ export class VetToken extends AccountCoinToken {
}
}

/**
* Midnight Network supports the DUST token for transaction fees.
* DUST is a native token on the Midnight Network used to pay for transaction fees.
*/
export class NightToken extends AccountCoinToken {
public tokenId: string;
constructor(options: NightTokenConstructorOptions) {
super({
...options,
});
this.tokenId = options.tokenId;
}
}

/**
* Cosmos network supports tokens
* Cosmos tokens work similar to native coins, but the token is determined by
Expand Down Expand Up @@ -3778,6 +3802,94 @@ export function tvetToken(
);
}

/**
* Factory function for Night token (DUST) instances.
*
* @param id uuid v4
* @param name unique identifier of the token
* @param fullName Complete human-readable name of the token
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
* @param tokenId Token identifier (e.g., 'dust')
* @param asset Asset which this coin represents
* @param features Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
* @param prefix Optional token prefix. Defaults to empty string
* @param suffix Optional token suffix. Defaults to token name.
* @param network Optional token network. Defaults to the mainnet Night network.
* @param primaryKeyCurve The elliptic curve for this chain/token
*/
export function nightToken(
id: string,
name: string,
fullName: string,
decimalPlaces: number,
tokenId: string,
asset: UnderlyingAsset,
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
prefix = '',
suffix: string = name.toUpperCase(),
network: AccountNetwork = Networks.main.night,
primaryKeyCurve: KeyCurve = KeyCurve.Ed25519
) {
return Object.freeze(
new NightToken({
id,
name,
fullName,
network,
tokenId,
prefix,
suffix,
features,
decimalPlaces,
asset,
isToken: true,
primaryKeyCurve,
baseUnit: BaseUnit.NIGHT,
})
);
}

/**
* Factory function for testnet Night token (DUST) instances.
*
* @param id uuid v4
* @param name unique identifier of the token
* @param fullName Complete human-readable name of the token
* @param decimalPlaces Number of decimal places this token supports (divisibility exponent)
* @param tokenId Token identifier (e.g., 'tdust')
* @param asset Asset which this coin represents
* @param features Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
* @param prefix Optional token prefix. Defaults to empty string
* @param suffix Optional token suffix. Defaults to token name.
* @param network Optional token network. Defaults to the testnet Night network.
*/
export function tnightToken(
id: string,
name: string,
fullName: string,
decimalPlaces: number,
tokenId: string,
asset: UnderlyingAsset,
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
prefix = '',
suffix: string = name.toUpperCase(),
network: AccountNetwork = Networks.test.night
) {
return nightToken(
id,
name,
fullName,
decimalPlaces,
tokenId,
asset,
features,
prefix,
suffix,
network,
KeyCurve.Ed25519
);
}

/**
* Factory function for Vet NFT collections.
*
Expand Down
21 changes: 21 additions & 0 deletions modules/statics/src/allCoinsAndTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
} from './account';
import { ada } from './ada';
import { avaxp } from './avaxp';
import { night } from './night';
import { BaseUnit, CoinFeature, KeyCurve, UnderlyingAsset } from './base';
import { canton } from './canton';
import { erc20Coins } from './coins/erc20Coins';
Expand All @@ -68,6 +69,7 @@ import { lightningCoins } from './lightning';
import { sip10Tokens } from './coins/sip10Tokens';
import { nep141Tokens } from './coins/nep141Tokens';
import { vetTokens } from './coins/vetTokens';
import { nightTokens } from './coins/nightTokens';
import { cosmosTokens } from './coins/cosmosTokens';
import { jettonTokens } from './coins/jettonTokens';
import { polyxTokens } from './coins/polyxTokens';
Expand Down Expand Up @@ -105,6 +107,7 @@ import {
INJECTIVE_FEATURES,
IOTA_FEATURES,
NEAR_FEATURES,
NIGHT_FEATURES,
OAS_FEATURES,
OPETH_FEATURES,
POLYGON_FEATURES,
Expand Down Expand Up @@ -155,6 +158,7 @@ export const allCoinsAndTokens = [
...sip10Tokens,
...nep141Tokens,
...vetTokens,
...nightTokens,
...cosmosTokens,
...botTokens,
...adaTokens,
Expand Down Expand Up @@ -199,6 +203,23 @@ export const allCoinsAndTokens = [
UnderlyingAsset.ADA,
ADA_FEATURES
),
// Midnight Network - Privacy-first blockchain using zero-knowledge proofs
night(
'b1c2d3e4-5f6a-7b8c-9d0e-1f2a3b4c5d6e',
'night',
'Midnight',
Networks.main.night,
UnderlyingAsset.NIGHT,
NIGHT_FEATURES
),
night(
'c2d3e4f5-6a7b-8c9d-0e1f-2a3b4c5d6e7f',
'tnight',
'Testnet Midnight',
Networks.test.night,
UnderlyingAsset.NIGHT,
NIGHT_FEATURES
),
account(
'ec41e62a-cc57-4aa0-9b9e-217da1226817',
'algo',
Expand Down
5 changes: 5 additions & 0 deletions modules/statics/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export enum CoinFamily {
CTC = 'ctc',
HYPEEVM = 'hypeevm',
NEAR = 'near',
NIGHT = 'night', // Midnight Network
OAS = 'oas',
OFC = 'ofc',
OG = 'og',
Expand Down Expand Up @@ -613,6 +614,9 @@ export enum UnderlyingAsset {
MORPH = 'morph',
MORPHETH = 'morpheth',
NEAR = 'near',
NIGHT = 'night', // Midnight Network
'night:dust' = 'night:dust', // Midnight Dust token (fee token)
'tnight:tdust' = 'tnight:tdust', // Testnet Midnight Dust token
OAS = 'oas',
OG = 'og',
OKBXLAYER = 'okbxlayer',
Expand Down Expand Up @@ -3609,6 +3613,7 @@ export enum BaseUnit {
SUI = 'MIST',
TON = 'nanoton',
NEAR = 'yocto',
NIGHT = 'dust', // Midnight Network smallest unit
OFC = 'ofcCoin',
OSMO = 'uosmo',
FIAT = 'fiatCoin',
Expand Down
27 changes: 27 additions & 0 deletions modules/statics/src/coinFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,33 @@ export const VET_FEATURES = [
];
export const VET_TOKEN_FEATURES = VET_FEATURES.filter((feature) => feature !== CoinFeature.SUPPORTS_TOKENS);

/**
* Midnight Network (NIGHT) features
* Night is a UTXO-based privacy chain using Ed25519 and ZK proofs
* Minimal features enabled for skeleton implementation
*/
export const NIGHT_FEATURES = [
CoinFeature.UNSPENT_MODEL,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
CoinFeature.TRANSACTION_DATA,
CoinFeature.REQUIRES_BIG_NUMBER,
CoinFeature.SUPPORTS_TOKENS, // Supports DUST token
];

/**
* Midnight Network token (DUST) features
* DUST is the fee token on the Midnight Network
* Tokens use account model, not unspent model
*/
export const NIGHT_TOKEN_FEATURES = [
CoinFeature.ACCOUNT_MODEL,
CoinFeature.TSS,
CoinFeature.TSS_COLD,
CoinFeature.TRANSACTION_DATA,
CoinFeature.REQUIRES_BIG_NUMBER,
];

export const EVM_NON_EIP1559_FEATURES = [...EVM_FEATURES.filter((feature) => feature !== CoinFeature.EIP1559)];

export const XDC_FEATURES = [...EVM_NON_EIP1559_FEATURES, CoinFeature.ERC20_BULK_TRANSACTION];
Expand Down
28 changes: 28 additions & 0 deletions modules/statics/src/coins/nightTokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { nightToken, tnightToken } from '../account';
import { UnderlyingAsset } from '../base';
import { NIGHT_TOKEN_FEATURES } from '../coinFeatures';

/**
* DUST tokens on the Midnight Network
* DUST is the native fee token used to pay for transactions on Midnight
*/
export const nightTokens = [
nightToken(
'f8a9b2c1-3d4e-5f6a-7b8c-9d0e1f2a3b4c', // UUID for night:dust
'night:dust',
'Midnight Dust',
8, // 8 decimal places like NIGHT
'dust',
UnderlyingAsset['night:dust'],
NIGHT_TOKEN_FEATURES
),
tnightToken(
'a1b2c3d4-5e6f-7a8b-9c0d-e1f2a3b4c5d6', // UUID for tnight:tdust
'tnight:tdust',
'Testnet Midnight Dust',
8, // 8 decimal places like NIGHT
'tdust',
UnderlyingAsset['tnight:tdust'],
NIGHT_TOKEN_FEATURES
),
];
2 changes: 2 additions & 0 deletions modules/statics/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './tokenConfig';
export { OfcCoin } from './ofc';
export { UtxoCoin } from './utxo';
export { LightningCoin } from './lightning';
export { Night } from './night';
export {
AccountCoin,
GasTankAccountCoin,
Expand All @@ -30,6 +31,7 @@ export {
Nep141Token,
VetToken,
VetNFTCollection,
NightToken,
CosmosChainToken,
AdaToken,
JettonToken,
Expand Down
35 changes: 35 additions & 0 deletions modules/statics/src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ export interface AdaNetwork extends BaseNetwork {
coinsPerUtxoWord: number;
}

/**
* Midnight Network - Privacy-first blockchain using zero-knowledge proofs
*/
export interface NightNetwork extends BaseNetwork {
// GraphQL indexer endpoint for querying chain state
readonly indexerUrl: string;
// RPC WebSocket endpoint for node communication
readonly rpcUrl: string;
}

export interface AvalancheNetwork extends BaseNetwork {
readonly alias: string;
readonly blockchainID: string;
Expand Down Expand Up @@ -236,6 +246,29 @@ class AdaTestnet extends Testnet implements AdaNetwork {
stakeKeyDeposit = 2000000;
}

/**
* Midnight Network - Privacy-first blockchain using zero-knowledge proofs
* Mainnet configuration
*/
class Night extends Mainnet implements NightNetwork {
name = 'Midnight';
family = CoinFamily.NIGHT;
explorerUrl = 'https://explorer.midnight.network/';
indexerUrl = 'https://indexer.midnight.network/api/v3/graphql';
rpcUrl = 'wss://rpc.midnight.network';
}

/**
* Midnight Network Testnet (Preprod)
*/
class NightTestnet extends Testnet implements NightNetwork {
name = 'MidnightTestnet';
family = CoinFamily.NIGHT;
explorerUrl = 'https://explorer.preprod.midnight.network/';
indexerUrl = 'https://indexer.preprod.midnight.network/api/v3/graphql';
rpcUrl = 'wss://rpc.preprod.midnight.network';
}

class Apt extends Mainnet implements AccountNetwork {
name = 'Apt';
family = CoinFamily.APT;
Expand Down Expand Up @@ -2460,6 +2493,7 @@ export const Networks = {
sonic: Object.freeze(new Sonic()),
sui: Object.freeze(new Sui()),
near: Object.freeze(new Near()),
night: Object.freeze(new Night()),
stx: Object.freeze(new Stx()),
somi: Object.freeze(new Somi()),
soneium: Object.freeze(new Soneium()),
Expand Down Expand Up @@ -2573,6 +2607,7 @@ export const Networks = {
sol: Object.freeze(new SolTestnet()),
sui: Object.freeze(new SuiTestnet()),
near: Object.freeze(new NearTestnet()),
night: Object.freeze(new NightTestnet()),
stx: Object.freeze(new StxTestnet()),
stt: Object.freeze(new SomniaTestnet()),
soneium: Object.freeze(new SoneiumTestnet()),
Expand Down
Loading
Loading