@@ -85,33 +85,47 @@ export class AithraManager {
85
85
}
86
86
87
87
async getTotalCost ( numberOfSongs : number , numberOfMints : number ) : Promise < Result < number , Error > > {
88
- const generateSongPrice = 0.035 ;
88
+ // const generateSongPrice = 0.035;
89
89
90
- const priceResult = await this . mintsCreditManager . getAithraPriceInUsd ( ) ;
91
- if ( priceResult . isErr ( ) ) {
92
- return Result . err ( priceResult . getErr ( ) ) ;
93
- }
94
- const aithraUsdPrice = priceResult . unwrap ( ) || 0.001 ;
90
+ // const priceResult = await this.mintsCreditManager.getAithraPriceInUsd();
91
+ // if (priceResult.isErr()) {
92
+ // return Result.err(priceResult.getErr());
93
+ // }
94
+ // const aithraUsdPrice = priceResult.unwrap() || 0.001;
95
95
96
- const generateSongPriceAithra = generateSongPrice / aithraUsdPrice ;
96
+ // const generateSongPriceAithra = generateSongPrice / aithraUsdPrice;
97
97
98
- const fileCostResult = await this . filesCreditManager . getCost ( ) ;
99
- if ( fileCostResult . isErr ( ) ) {
100
- return Result . err ( fileCostResult . getErr ( ) ) ;
101
- }
98
+ // const fileCostResult = await this.filesCreditManager.getCost();
99
+ // if (fileCostResult.isErr()) {
100
+ // return Result.err(fileCostResult.getErr());
101
+ // }
102
102
103
- const mintCostResult = await this . mintsCreditManager . getCost ( ) ;
104
- if ( mintCostResult . isErr ( ) ) {
105
- return Result . err ( mintCostResult . getErr ( ) ) ;
106
- }
103
+ // const mintCostResult = await this.mintsCreditManager.getCost();
104
+ // if (mintCostResult.isErr()) {
105
+ // return Result.err(mintCostResult.getErr());
106
+ // }
107
+
108
+ // const totalCost = (numberOfSongs * fileCostResult.unwrap() + 2 * fileCostResult.unwrap()) +
109
+ // (numberOfMints * mintCostResult.unwrap()) +
110
+ // (numberOfSongs * generateSongPriceAithra);
107
111
108
- const totalCost = ( numberOfSongs * fileCostResult . unwrap ( ) + 2 * fileCostResult . unwrap ( ) ) +
109
- ( numberOfMints * mintCostResult . unwrap ( ) ) +
110
- ( numberOfSongs * generateSongPriceAithra ) ;
112
+ const GENERATE_MUSIC_MEME_PRICE_IN_USD = 0.3 ;
113
+ try {
114
+ const response = await fetch ( "https://api.coingecko.com/api/v3/simple/price?ids=solana&vs_currencies=usd" ) ;
115
+ const data = await response . json ( ) ;
116
+ const currentSolPrice = data . solana . usd ;
111
117
112
- return Result . ok ( totalCost ) ;
118
+ const solAmount = GENERATE_MUSIC_MEME_PRICE_IN_USD / currentSolPrice ;
119
+
120
+ return Result . ok ( Number ( solAmount . toFixed ( 4 ) ) )
121
+
122
+ } catch ( error ) {
123
+ console . error ( "Failed to fetch SOL price:" , error ) ;
124
+ Result . err ( new Error ( error ) ) ;
125
+ }
113
126
}
114
127
128
+
115
129
async buildUploadMintMusicNFTs ( params : BuildUploadMintMusicNFTsParams ) : Promise < Result < BuildMusicNFTResult , Error > > {
116
130
// 1. Build playlist config
117
131
const playlistResult = await buildPlaylistConfig (
0 commit comments