@@ -20,7 +20,6 @@ import assert from "assert";
2020import type { Contracts } from "@fluencelabs/deal-ts-clients" ;
2121import { color } from "@oclif/color" ;
2222import parse from "parse-duration" ;
23- import { yamlDiffPatch } from "yaml-diff-patch" ;
2423
2524import { commandObj } from "../commandObj.js" ;
2625import { initProviderConfig } from "../configs/project/provider/provider.js" ;
@@ -471,7 +470,7 @@ export async function createCommitments(flags: PeerAndOfferNameFlags) {
471470 ) ;
472471
473472 commandObj . logToStderr (
474- stringifyDetailedCommitmentsInfo (
473+ await stringifyDetailedCommitmentsInfo (
475474 await getDetailedCommitmentsInfoGroupedByStatus ( {
476475 [ PEER_NAMES_FLAG_NAME ] : computePeers
477476 . map ( ( { name } ) => {
@@ -1049,21 +1048,31 @@ export async function getDetailedCommitmentsInfoGroupedByStatus(
10491048 ) ;
10501049}
10511050
1052- export function stringifyDetailedCommitmentsInfo (
1051+ export async function stringifyDetailedCommitmentsInfo (
10531052 detailedCommitmentsInfoGroupedByStatus : Awaited <
10541053 ReturnType < typeof getDetailedCommitmentsInfoGroupedByStatus >
10551054 > ,
10561055) {
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" ) ;
10671076}
10681077
10691078function getStatusHeading ( cc : CommitmentGroupedByStatus [ number ] ) {
@@ -1197,47 +1206,43 @@ async function getDetailedCommitmentInfo({
11971206 } satisfies Record < string , string > ;
11981207}
11991208
1200- function getDetailedCommitmentInfoString (
1209+ async function getDetailedCommitmentInfoString (
12011210 detailedCommitmentInfo : Awaited < ReturnType < typeof getDetailedCommitmentInfo > > ,
12021211) {
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+ } ) ;
12411246}
12421247
12431248type Rewards = { ccRewards : bigint ; dealStakerRewards : bigint } ;
0 commit comments