@@ -19,11 +19,15 @@ import { ApiDecoration } from '@polkadot/api/types';
1919import type { BlockHash } from '@polkadot/types/interfaces' ;
2020import { u8aToHex } from '@polkadot/util' ;
2121import { BadRequest , InternalServerError } from 'http-errors' ;
22+ import { MetadataBlobParams } from 'src/types/requests' ;
2223import { ITransactionMetadataBlob } from 'src/types/responses' ;
2324
24- import { MetadataBlobParams } from '../../controllers/transaction/TransactionMetadataBlobController' ;
2525import { AbstractService } from '../AbstractService' ;
2626
27+ const DEFAULT_DECIMALS = 10 ;
28+ const DEFAULT_SS58_PREFIX = 42 ;
29+ const DEFAULT_TOKEN_SYMBOL = 'DOT' ;
30+
2731// Dynamic import helper that TypeScript won't transform to require()
2832// This is necessary because @polkadot -api/merkleize-metadata is an ESM-only package
2933// eslint-disable-next-line @typescript-eslint/no-implied-eval
@@ -89,27 +93,27 @@ export class TransactionMetadataBlobService extends AbstractService {
8993 const tokenSymbolRaw = properties . tokenSymbol . isSome ? properties . tokenSymbol . value : null ;
9094 const ss58Format = properties . ss58Format . isSome ? properties . ss58Format . value : null ;
9195
92- let decimals = 10 ;
96+ let decimals = DEFAULT_DECIMALS ;
9397 if ( tokenDecimalsRaw ) {
9498 const decimalsJson = tokenDecimalsRaw . toJSON ( ) ;
9599 if ( Array . isArray ( decimalsJson ) ) {
96- decimals = ( decimalsJson [ 0 ] as number ) ?? 10 ;
100+ decimals = ( decimalsJson [ 0 ] as number ) ?? DEFAULT_DECIMALS ;
97101 } else if ( typeof decimalsJson === 'number' ) {
98102 decimals = decimalsJson ;
99103 }
100104 }
101105
102- let tokenSymbol = 'DOT' ;
106+ let tokenSymbol = DEFAULT_TOKEN_SYMBOL ;
103107 if ( tokenSymbolRaw ) {
104108 const symbolJson = tokenSymbolRaw . toJSON ( ) ;
105109 if ( Array . isArray ( symbolJson ) ) {
106- tokenSymbol = ( symbolJson [ 0 ] as string ) ?? 'DOT' ;
110+ tokenSymbol = ( symbolJson [ 0 ] as string ) ?? DEFAULT_TOKEN_SYMBOL ;
107111 } else if ( typeof symbolJson === 'string' ) {
108112 tokenSymbol = symbolJson ;
109113 }
110114 }
111115
112- const base58Prefix = ss58Format ?. toNumber ( ) ?? 42 ;
116+ const base58Prefix = ss58Format ?. toNumber ( ) ?? DEFAULT_SS58_PREFIX ;
113117
114118 // Use dynamic import for ESM module compatibility
115119 const merkleizeMetadata = await this . getMerkleizeMetadata ( ) ;
0 commit comments