File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,7 +69,24 @@ export class Cardano {
6969
7070 if ( ! Cardano . _instances [ network ] ) {
7171 const instance = new Cardano ( network ) ;
72- await instance . init ( ) ;
72+
73+ if (
74+ instance . projectId &&
75+ instance . projectId . toLowerCase ( ) . startsWith ( network . toLowerCase ( ) )
76+ ) {
77+ try {
78+ await instance . init ( ) ;
79+ } catch ( err : any ) {
80+ logger . warn (
81+ `[Cardano] initial init() skipped for network="${ network } ": ${ err . message } ` ,
82+ ) ;
83+ }
84+ } else {
85+ logger . info (
86+ `[Cardano] skipped init() for network="${ network } " because projectId is still placeholder` ,
87+ ) ;
88+ }
89+
7390 Cardano . _instances [ network ] = instance ;
7491 }
7592
Original file line number Diff line number Diff line change @@ -146,12 +146,12 @@ export const balancesRoute: FastifyPluginAsync = async (fastify) => {
146146 // Get first wallet address for example
147147 const cardano = await Cardano . getInstance ( 'preprod' ) ;
148148
149- // Default Ethereum address for examples if no wallet is available
149+ // Default Cardano address for examples if no wallet is available
150150 let firstWalletAddress = '' ;
151151
152152 try {
153- // Try to get user's first Ethereum wallet if available
154- // getFirstWalletAddress specifically looks in the /ethereum directory
153+ // Try to get user's first Cardano wallet if available
154+ // getFirstWalletAddress specifically looks in the /cardano directory
155155 const userWallet = await cardano . getFirstWalletAddress ( ) ;
156156 if ( userWallet ) {
157157 // Make sure it's a valid Cardano address
@@ -166,7 +166,7 @@ export const balancesRoute: FastifyPluginAsync = async (fastify) => {
166166 }
167167 }
168168 } catch ( error ) {
169- logger . warn ( 'No Ethereum wallets found for examples in schema' ) ;
169+ logger . warn ( 'No Cardano wallets found for examples in schema' ) ;
170170 }
171171
172172 BalanceRequestSchema . properties . address . examples = [ firstWalletAddress ] ;
Original file line number Diff line number Diff line change 99 ConfigUpdateResponseSchema ,
1010} from '../schemas' ;
1111import { updateConfig } from '../utils' ;
12+ import { Cardano } from '../../chains/cardano/cardano' ;
1213
1314export const updateConfigRoute : FastifyPluginAsync = async ( fastify ) => {
1415 fastify . post < { Body : ConfigUpdateRequest ; Reply : ConfigUpdateResponse } > (
@@ -84,6 +85,14 @@ export const updateConfigRoute: FastifyPluginAsync = async (fastify) => {
8485
8586 // Build descriptive message
8687 const description = `'${ namespace } .${ path } '` ;
88+ // If they updated the projectId for one of the Cardano networks:
89+ if ( configPath . startsWith ( 'cardano.' ) && configPath . endsWith ( '.projectId' ) ) {
90+ const network = configPath . split ( '.' ) [ 2 ] ; // e.g. 'preprod || mainnet || preview'
91+ console . log ( 'network' , network ) ;
92+ const cardano = await Cardano . getInstance ( network ) ;
93+ cardano . projectId = String ( processedValue ) ; // assign the new key as string
94+ await cardano . init ( ) ; // re‐init Lucid on the fly
95+ }
8796
8897 return {
8998 message : `Configuration updated successfully: ${ description } set to ${ JSON . stringify ( processedValue ) } ` ,
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ export const removeLiquidityRoute: FastifyPluginAsync = async (fastify) => {
6868 ) ;
6969 }
7070
71- // Get Uniswap and Ethereum instances
71+ // Get Minswap and Cardano instances
7272 const minswap = await Minswap . getInstance ( networkToUse ) ;
7373
7474 // Get wallet address - either from request or first available
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ export const removeLiquidityRoute: FastifyPluginAsync = async (fastify) => {
7676 ) ;
7777 }
7878
79- // Get Uniswap and Ethereum instances
79+ // Get Sundaeswap and Cardano instances
8080 const sundaeswap = await Sundaeswap . getInstance ( networkToUse ) ;
8181
8282 // Get wallet address - either from request or first available
Original file line number Diff line number Diff line change @@ -4,17 +4,17 @@ networks:
44 tokenListSource : " /home/gateway/conf/lists/cardano_mainnet_tokens.json"
55 nativeCurrencySymbol : ' ADA'
66 apiurl : ' https://cardano-mainnet.blockfrost.io/api/v0'
7- projectId : ' your_mainnet_api_key '
7+ projectId : ' your_api_key '
88 preprod :
99 tokenListType : " FILE"
1010 tokenListSource : " /home/gateway/conf/lists/cardano_preprod_tokens.json"
1111 nativeCurrencySymbol : ' ADA'
1212 apiurl : ' https://cardano-preprod.blockfrost.io/api/v0'
13- projectId : ' your_preprod_api_key '
13+ projectId : ' your_api_key '
1414 preview :
1515 tokenListType : " FILE"
1616 tokenListSource : " /home/gateway/conf/lists/cardano_preview_tokens.json"
1717 nativeCurrencySymbol : ' ADA'
1818 apiurl : ' https://cardano-preview.blockfrost.io/api/v0'
19- projectId : ' your_preview_api_key '
19+ projectId : ' your_api_key '
2020
You can’t perform that action at this time.
0 commit comments