Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"whatwg-url": "^14.0.0"
},
"dependencies": {
"@fluencelabs/deal-ts-clients": "0.23.2-feat-marketplace-v2-resources-a3ae33d-7546-1.0",
"@fluencelabs/deal-ts-clients": "0.23.2-feat-marketplace-v2-resources-d1eaf27-7661-1.0",
"@kubernetes/client-node": "github:fluencelabs/kubernetes-client-javascript#e72ee00a52fec4eb4a8327632895d888ee504f4d",
"@libp2p/crypto": "4.0.1",
"@libp2p/peer-id-factory": "4.0.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package/src/commands/provider/cc-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class CCInfo extends BaseCommand<typeof CCInfo> {
return CCs;
}),
)
: stringifyDetailedCommitmentsInfo(ccInfo),
: await stringifyDetailedCommitmentsInfo(ccInfo),
);
}
}
5 changes: 2 additions & 3 deletions packages/cli/package/src/commands/provider/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { yamlDiffPatch } from "yaml-diff-patch";

import { BaseCommand } from "../../baseCommand.js";
import { jsonStringify } from "../../common.js";
import { getProviderInfo } from "../../lib/chain/providerInfo.js";
Expand Down Expand Up @@ -68,7 +66,8 @@ export default class Info extends BaseCommand<typeof Info> {
return;
}

commandObj.log(yamlDiffPatch("", {}, infoToPrint));
const { stringify } = await import("yaml");
commandObj.log(stringify(infoToPrint));
}
}

Expand Down
8 changes: 5 additions & 3 deletions packages/cli/package/src/lib/ajvInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ export async function validationErrorToString(errors: AjvErrors) {
return "";
}

const { yamlDiffPatch } = await import("yaml-diff-patch");
const { stringify } = await import("yaml");

return (
"Errors:\n\n" +
errors
.map(({ instancePath, params, message }, i) => {
const paramsMessage = yamlDiffPatch("", {}, params);
const paramsMessage =
Object.keys(params).length === 0 ? "" : `\n${stringify(params)}`;

const prevError = errors[i - 1];

const isDuplicateError =
Expand All @@ -64,7 +66,7 @@ export async function validationErrorToString(errors: AjvErrors) {
return "";
}

return `${instancePath === "" ? "" : `${color.yellow(instancePath)} `}${message ?? ""}${paramsMessage === "" ? "" : `\n${paramsMessage}`}`;
return `${instancePath === "" ? "" : `${color.yellow(instancePath)} `}${message ?? ""}${paramsMessage}`;
})
.filter((s) => {
return s !== "";
Expand Down
109 changes: 57 additions & 52 deletions packages/cli/package/src/lib/chain/commitment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import assert from "assert";
import type { Contracts } from "@fluencelabs/deal-ts-clients";
import { color } from "@oclif/color";
import parse from "parse-duration";
import { yamlDiffPatch } from "yaml-diff-patch";

import { commandObj } from "../commandObj.js";
import { initProviderConfig } from "../configs/project/provider/provider.js";
Expand Down Expand Up @@ -471,7 +470,7 @@ export async function createCommitments(flags: PeerAndOfferNameFlags) {
);

commandObj.logToStderr(
stringifyDetailedCommitmentsInfo(
await stringifyDetailedCommitmentsInfo(
await getDetailedCommitmentsInfoGroupedByStatus({
[PEER_NAMES_FLAG_NAME]: computePeers
.map(({ name }) => {
Expand Down Expand Up @@ -1049,21 +1048,31 @@ export async function getDetailedCommitmentsInfoGroupedByStatus(
);
}

export function stringifyDetailedCommitmentsInfo(
export async function stringifyDetailedCommitmentsInfo(
detailedCommitmentsInfoGroupedByStatus: Awaited<
ReturnType<typeof getDetailedCommitmentsInfoGroupedByStatus>
>,
) {
return detailedCommitmentsInfoGroupedByStatus
.map(({ statusInfo, CCs }) => {
return `${getStatusHeading(statusInfo)}${CCs.map((cc) => {
const peerNameString =
"peerName" in cc ? color.yellow(`Peer: ${cc.peerName}\n`) : "";

return `${peerNameString}${getDetailedCommitmentInfoString(cc)}`;
}).join("\n\n")}`;
})
.join("\n\n");
return (
await Promise.all(
detailedCommitmentsInfoGroupedByStatus.map(
async ({ statusInfo, CCs }) => {
return `${getStatusHeading(statusInfo)}${(
await Promise.all(
CCs.map(async (cc) => {
const peerNameString =
"peerName" in cc
? color.yellow(`Peer: ${cc.peerName}\n`)
: "";

return `${peerNameString}${await getDetailedCommitmentInfoString(cc)}`;
}),
)
).join("\n\n")}`;
},
),
)
).join("\n\n");
}

function getStatusHeading(cc: CommitmentGroupedByStatus[number]) {
Expand Down Expand Up @@ -1197,47 +1206,43 @@ async function getDetailedCommitmentInfo({
} satisfies Record<string, string>;
}

function getDetailedCommitmentInfoString(
async function getDetailedCommitmentInfoString(
detailedCommitmentInfo: Awaited<ReturnType<typeof getDetailedCommitmentInfo>>,
) {
return yamlDiffPatch(
"",
{},
{
PeerId: detailedCommitmentInfo.peerId,
"Capacity commitment ID": detailedCommitmentInfo.commitmentId,
Status: detailedCommitmentInfo.status,
Staker: detailedCommitmentInfo.staker,
"Staker reward": detailedCommitmentInfo.stakerReward,
"Duration (epochs)": detailedCommitmentInfo.durationEpochs,
"Start / End / Current epoch": [
detailedCommitmentInfo.startEpoch,
detailedCommitmentInfo.endEpoch,
detailedCommitmentInfo.currentEpoch,
].join(" / "),
"Start date": detailedCommitmentInfo.startDate,
"Expiration date": detailedCommitmentInfo.expirationDate,
"Total CU": detailedCommitmentInfo.totalCU,
"Missed proofs / Threshold": [
detailedCommitmentInfo.missedProofs,
detailedCommitmentInfo.threshold,
].join(" / "),
"Collateral per unit": detailedCommitmentInfo.collateralPerUnit,
"Exited unit count": detailedCommitmentInfo.exitedUnitCount,
"Total CC rewards over time":
detailedCommitmentInfo.totalCCRewardsOverTime,
"In vesting / Available / Total claimed (Provider)": [
detailedCommitmentInfo.providerRewardsInVesting,
detailedCommitmentInfo.providerRewardsAvailable,
detailedCommitmentInfo.providerRewardsTotalClaimed,
].join(" / "),
"In vesting / Available / Total claimed (Staker)": [
detailedCommitmentInfo.stakerRewardsInVesting,
detailedCommitmentInfo.stakerRewardsAvailable,
detailedCommitmentInfo.stakerRewardsTotalClaimed,
].join(" / "),
},
);
const { stringify } = await import("yaml");
return stringify({
PeerId: detailedCommitmentInfo.peerId,
"Capacity commitment ID": detailedCommitmentInfo.commitmentId,
Status: detailedCommitmentInfo.status,
Staker: detailedCommitmentInfo.staker,
"Staker reward": detailedCommitmentInfo.stakerReward,
"Duration (epochs)": detailedCommitmentInfo.durationEpochs,
"Start / End / Current epoch": [
detailedCommitmentInfo.startEpoch,
detailedCommitmentInfo.endEpoch,
detailedCommitmentInfo.currentEpoch,
].join(" / "),
"Start date": detailedCommitmentInfo.startDate,
"Expiration date": detailedCommitmentInfo.expirationDate,
"Total CU": detailedCommitmentInfo.totalCU,
"Missed proofs / Threshold": [
detailedCommitmentInfo.missedProofs,
detailedCommitmentInfo.threshold,
].join(" / "),
"Collateral per unit": detailedCommitmentInfo.collateralPerUnit,
"Exited unit count": detailedCommitmentInfo.exitedUnitCount,
"Total CC rewards over time": detailedCommitmentInfo.totalCCRewardsOverTime,
"In vesting / Available / Total claimed (Provider)": [
detailedCommitmentInfo.providerRewardsInVesting,
detailedCommitmentInfo.providerRewardsAvailable,
detailedCommitmentInfo.providerRewardsTotalClaimed,
].join(" / "),
"In vesting / Available / Total claimed (Staker)": [
detailedCommitmentInfo.stakerRewardsInVesting,
detailedCommitmentInfo.stakerRewardsAvailable,
detailedCommitmentInfo.stakerRewardsTotalClaimed,
].join(" / "),
});
}

type Rewards = { ccRewards: bigint; dealStakerRewards: bigint };
Expand Down
Loading
Loading