@@ -20,7 +20,6 @@ import assert from "assert";
20
20
import type { Contracts } from "@fluencelabs/deal-ts-clients" ;
21
21
import { color } from "@oclif/color" ;
22
22
import parse from "parse-duration" ;
23
- import { yamlDiffPatch } from "yaml-diff-patch" ;
24
23
25
24
import { commandObj } from "../commandObj.js" ;
26
25
import { initProviderConfig } from "../configs/project/provider/provider.js" ;
@@ -471,7 +470,7 @@ export async function createCommitments(flags: PeerAndOfferNameFlags) {
471
470
) ;
472
471
473
472
commandObj . logToStderr (
474
- stringifyDetailedCommitmentsInfo (
473
+ await stringifyDetailedCommitmentsInfo (
475
474
await getDetailedCommitmentsInfoGroupedByStatus ( {
476
475
[ PEER_NAMES_FLAG_NAME ] : computePeers
477
476
. map ( ( { name } ) => {
@@ -1049,21 +1048,31 @@ export async function getDetailedCommitmentsInfoGroupedByStatus(
1049
1048
) ;
1050
1049
}
1051
1050
1052
- export function stringifyDetailedCommitmentsInfo (
1051
+ export async function stringifyDetailedCommitmentsInfo (
1053
1052
detailedCommitmentsInfoGroupedByStatus : Awaited <
1054
1053
ReturnType < typeof getDetailedCommitmentsInfoGroupedByStatus >
1055
1054
> ,
1056
1055
) {
1057
- return detailedCommitmentsInfoGroupedByStatus
1058
- . map ( ( { statusInfo, CCs } ) => {
1059
- return `${ getStatusHeading ( statusInfo ) } ${ CCs . map ( ( cc ) => {
1060
- const peerNameString =
1061
- "peerName" in cc ? color . yellow ( `Peer: ${ cc . peerName } \n` ) : "" ;
1062
-
1063
- return `${ peerNameString } ${ getDetailedCommitmentInfoString ( cc ) } ` ;
1064
- } ) . join ( "\n\n" ) } `;
1065
- } )
1066
- . join ( "\n\n" ) ;
1056
+ return (
1057
+ await Promise . all (
1058
+ detailedCommitmentsInfoGroupedByStatus . map (
1059
+ async ( { statusInfo, CCs } ) => {
1060
+ return `${ getStatusHeading ( statusInfo ) } ${ (
1061
+ await Promise . all (
1062
+ CCs . map ( async ( cc ) => {
1063
+ const peerNameString =
1064
+ "peerName" in cc
1065
+ ? color . yellow ( `Peer: ${ cc . peerName } \n` )
1066
+ : "" ;
1067
+
1068
+ return `${ peerNameString } ${ await getDetailedCommitmentInfoString ( cc ) } ` ;
1069
+ } ) ,
1070
+ )
1071
+ ) . join ( "\n\n" ) } `;
1072
+ } ,
1073
+ ) ,
1074
+ )
1075
+ ) . join ( "\n\n" ) ;
1067
1076
}
1068
1077
1069
1078
function getStatusHeading ( cc : CommitmentGroupedByStatus [ number ] ) {
@@ -1197,47 +1206,43 @@ async function getDetailedCommitmentInfo({
1197
1206
} satisfies Record < string , string > ;
1198
1207
}
1199
1208
1200
- function getDetailedCommitmentInfoString (
1209
+ async function getDetailedCommitmentInfoString (
1201
1210
detailedCommitmentInfo : Awaited < ReturnType < typeof getDetailedCommitmentInfo > > ,
1202
1211
) {
1203
- return yamlDiffPatch (
1204
- "" ,
1205
- { } ,
1206
- {
1207
- PeerId : detailedCommitmentInfo . peerId ,
1208
- "Capacity commitment ID" : detailedCommitmentInfo . commitmentId ,
1209
- Status : detailedCommitmentInfo . status ,
1210
- Staker : detailedCommitmentInfo . staker ,
1211
- "Staker reward" : detailedCommitmentInfo . stakerReward ,
1212
- "Duration (epochs)" : detailedCommitmentInfo . durationEpochs ,
1213
- "Start / End / Current epoch" : [
1214
- detailedCommitmentInfo . startEpoch ,
1215
- detailedCommitmentInfo . endEpoch ,
1216
- detailedCommitmentInfo . currentEpoch ,
1217
- ] . join ( " / " ) ,
1218
- "Start date" : detailedCommitmentInfo . startDate ,
1219
- "Expiration date" : detailedCommitmentInfo . expirationDate ,
1220
- "Total CU" : detailedCommitmentInfo . totalCU ,
1221
- "Missed proofs / Threshold" : [
1222
- detailedCommitmentInfo . missedProofs ,
1223
- detailedCommitmentInfo . threshold ,
1224
- ] . join ( " / " ) ,
1225
- "Collateral per unit" : detailedCommitmentInfo . collateralPerUnit ,
1226
- "Exited unit count" : detailedCommitmentInfo . exitedUnitCount ,
1227
- "Total CC rewards over time" :
1228
- detailedCommitmentInfo . totalCCRewardsOverTime ,
1229
- "In vesting / Available / Total claimed (Provider)" : [
1230
- detailedCommitmentInfo . providerRewardsInVesting ,
1231
- detailedCommitmentInfo . providerRewardsAvailable ,
1232
- detailedCommitmentInfo . providerRewardsTotalClaimed ,
1233
- ] . join ( " / " ) ,
1234
- "In vesting / Available / Total claimed (Staker)" : [
1235
- detailedCommitmentInfo . stakerRewardsInVesting ,
1236
- detailedCommitmentInfo . stakerRewardsAvailable ,
1237
- detailedCommitmentInfo . stakerRewardsTotalClaimed ,
1238
- ] . join ( " / " ) ,
1239
- } ,
1240
- ) ;
1212
+ const { stringify } = await import ( "yaml" ) ;
1213
+ return stringify ( {
1214
+ PeerId : detailedCommitmentInfo . peerId ,
1215
+ "Capacity commitment ID" : detailedCommitmentInfo . commitmentId ,
1216
+ Status : detailedCommitmentInfo . status ,
1217
+ Staker : detailedCommitmentInfo . staker ,
1218
+ "Staker reward" : detailedCommitmentInfo . stakerReward ,
1219
+ "Duration (epochs)" : detailedCommitmentInfo . durationEpochs ,
1220
+ "Start / End / Current epoch" : [
1221
+ detailedCommitmentInfo . startEpoch ,
1222
+ detailedCommitmentInfo . endEpoch ,
1223
+ detailedCommitmentInfo . currentEpoch ,
1224
+ ] . join ( " / " ) ,
1225
+ "Start date" : detailedCommitmentInfo . startDate ,
1226
+ "Expiration date" : detailedCommitmentInfo . expirationDate ,
1227
+ "Total CU" : detailedCommitmentInfo . totalCU ,
1228
+ "Missed proofs / Threshold" : [
1229
+ detailedCommitmentInfo . missedProofs ,
1230
+ detailedCommitmentInfo . threshold ,
1231
+ ] . join ( " / " ) ,
1232
+ "Collateral per unit" : detailedCommitmentInfo . collateralPerUnit ,
1233
+ "Exited unit count" : detailedCommitmentInfo . exitedUnitCount ,
1234
+ "Total CC rewards over time" : detailedCommitmentInfo . totalCCRewardsOverTime ,
1235
+ "In vesting / Available / Total claimed (Provider)" : [
1236
+ detailedCommitmentInfo . providerRewardsInVesting ,
1237
+ detailedCommitmentInfo . providerRewardsAvailable ,
1238
+ detailedCommitmentInfo . providerRewardsTotalClaimed ,
1239
+ ] . join ( " / " ) ,
1240
+ "In vesting / Available / Total claimed (Staker)" : [
1241
+ detailedCommitmentInfo . stakerRewardsInVesting ,
1242
+ detailedCommitmentInfo . stakerRewardsAvailable ,
1243
+ detailedCommitmentInfo . stakerRewardsTotalClaimed ,
1244
+ ] . join ( " / " ) ,
1245
+ } ) ;
1241
1246
}
1242
1247
1243
1248
type Rewards = { ccRewards : bigint ; dealStakerRewards : bigint } ;
0 commit comments