Skip to content

Commit

Permalink
fix and use latest
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsartem committed Jan 16, 2025
1 parent 59edf79 commit b928a16
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 29 deletions.
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-add-dc-to-subgraph-afdd94a-7473-1.0",
"@fluencelabs/deal-ts-clients": "0.23.2-feat-marketplace-v2-resources-eb89b78-7511-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: 2 additions & 0 deletions packages/cli/package/src/lib/chain/offer/offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ function setCPUSupplyForCP(
readonly details: string;
readonly name: string;
readonly supply: number;
readonly metadata: string;
};
};
owner: string;
Expand Down Expand Up @@ -353,6 +354,7 @@ function setCPUSupply(
readonly details: string;
readonly name: string;
readonly supply: number;
readonly metadata: string;
},
unitIds: Uint8Array[],
): OnChainResource {
Expand Down
27 changes: 18 additions & 9 deletions packages/cli/package/src/lib/configs/project/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import configOptions1, { type Config as Config1 } from "./provider1.js";
import configOptions2, { type Config as Config2 } from "./provider2.js";
import configOptions3, { type Config as Config3 } from "./provider3.js";
import configOptions4, {
resourceNameToId,
resourceNameToResource,
type Config as Config4,
type ComputePeer,
getDefaultComputePeerConfig,
Expand Down Expand Up @@ -343,7 +343,7 @@ export async function ensureComputerPeerConfigs({

return {
...s,
id: await resourceNameToId("storage", s.name),
...(await resourceNameToResource("storage", s.name)),
details: mergeStorageResourceDetails(storage, s),
};
}),
Expand All @@ -352,30 +352,39 @@ export async function ensureComputerPeerConfigs({
const resourcesWithIds = {
cpu: {
...computePeer.resources.cpu,
id: await resourceNameToId("cpu", computePeer.resources.cpu.name),
...(await resourceNameToResource(
"cpu",
computePeer.resources.cpu.name,
)),
details: mergeCPUResourceDetails(cpu, computePeer.resources.cpu),
},
ram: {
...computePeer.resources.ram,
id: await resourceNameToId("ram", computePeer.resources.ram.name),
...(await resourceNameToResource(
"ram",
computePeer.resources.ram.name,
)),
details: mergeRAMResourceDetails(ram, computePeer.resources.ram),
},
storage: storages,
bandwidth: {
...computePeer.resources.bandwidth,
id: await resourceNameToId(
...(await resourceNameToResource(
"bandwidth",
computePeer.resources.bandwidth.name,
),
)),
},
ip: {
...computePeer.resources.ip,
id: await resourceNameToId("ip", computePeer.resources.ip.name),
...(await resourceNameToResource(
"ip",
computePeer.resources.ip.name,
)),
},
} as const satisfies Record<
ResourceType,
| { id: string; details?: unknown }
| Array<{ id: string; details: unknown }>
| { id: string; metadata: string; details?: unknown }
| Array<{ id: string; metadata: string; details: unknown }>
>;

return {
Expand Down
20 changes: 10 additions & 10 deletions packages/cli/package/src/lib/configs/project/provider/provider4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,18 +800,18 @@ export function ipResourceToHumanReadableString({ version }: IPMetadata) {
return `v${version}`;
}

export async function resourceNameToId(
export async function resourceNameToResource(
resourceType: ResourceType,
name: string,
) {
const { id } = (await getResourcesFromChain())[resourceType][name] ?? {};
const chainResource = (await getResourcesFromChain())[resourceType][name];

assert(
id !== undefined,
chainResource !== undefined,
`Unreachable. It's validated in ${PROVIDER_CONFIG_FULL_FILE_NAME} schema that resource names are correct`,
);

return id;
return chainResource;
}

const START_IP = 16843009; // 1.1.1.1
Expand Down Expand Up @@ -1756,11 +1756,11 @@ export async function getDataCentersFromChain(): Promise<
}

type ChainResources = {
cpu: Record<string, CPUMetadata & { id: string }>;
ram: Record<string, RAMMetadata & { id: string }>;
storage: Record<string, StorageMetadata & { id: string }>;
bandwidth: Record<string, BandwidthMetadata & { id: string }>;
ip: Record<string, IPMetadata & { id: string }>;
cpu: Record<string, { metadata: string; id: string }>;
ram: Record<string, { metadata: string; id: string }>;
storage: Record<string, { metadata: string; id: string }>;
bandwidth: Record<string, { metadata: string; id: string }>;
ip: Record<string, { metadata: string; id: string }>;
};

let resourcesPromise: undefined | Promise<ChainResources> = undefined;
Expand Down Expand Up @@ -1810,7 +1810,7 @@ async function getResourcesFromChainImpl(): Promise<ChainResources> {
// @ts-expect-error it's validated above that resource metadata corresponds to the resource type
}[resourceType](parsedMetadata);

chainResources[resourceType][name] = { ...parsedMetadata, id };
chainResources[resourceType][name] = { metadata, id };
} catch (err) {
commandObj.warn(
`Failed to parse metadata for resource with id: ${id}. Error: ${stringifyUnknown(err)} Please report this issue.`,
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/package/src/versions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"protocolVersion": 1,
"chain-rpc": "docker.fluence.dev/chain-rpc:feat-marketplace-v2-resources-40f9723-7509-1",
"chain-deploy-script": "docker.fluence.dev/chain-deploy-script:feat-marketplace-v2-resources-40f9723-7509-1",
"subgraph-deploy-script": "docker.fluence.dev/subgraph-deploy-script:feat-marketplace-v2-resources-40f9723-7509-1"
"protocolVersion": 2,
"chain-rpc": "docker.fluence.dev/chain-rpc:feat-marketplace-v2-resources-eb89b78-7511-1",
"chain-deploy-script": "docker.fluence.dev/chain-deploy-script:feat-marketplace-v2-resources-eb89b78-7511-1",
"subgraph-deploy-script": "docker.fluence.dev/subgraph-deploy-script:feat-marketplace-v2-resources-eb89b78-7511-1"
}
10 changes: 5 additions & 5 deletions packages/cli/package/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ __metadata:
dependencies:
"@actions/core": "npm:1.11.1"
"@aws-sdk/lib-storage": "npm:^3.501.0"
"@fluencelabs/deal-ts-clients": "npm:0.23.2-add-dc-to-subgraph-afdd94a-7473-1.0"
"@fluencelabs/deal-ts-clients": "npm:0.23.2-feat-marketplace-v2-resources-eb89b78-7511-1.0"
"@graphql-codegen/cli": "npm:^5.0.3"
"@graphql-codegen/typescript": "npm:^4.1.1"
"@graphql-codegen/typescript-graphql-request": "npm:^6.2.0"
Expand Down Expand Up @@ -2038,9 +2038,9 @@ __metadata:
languageName: unknown
linkType: soft

"@fluencelabs/deal-ts-clients@npm:0.23.2-add-dc-to-subgraph-afdd94a-7473-1.0":
version: 0.23.2-add-dc-to-subgraph-afdd94a-7473-1.0
resolution: "@fluencelabs/deal-ts-clients@npm:0.23.2-add-dc-to-subgraph-afdd94a-7473-1.0"
"@fluencelabs/deal-ts-clients@npm:0.23.2-feat-marketplace-v2-resources-eb89b78-7511-1.0":
version: 0.23.2-feat-marketplace-v2-resources-eb89b78-7511-1.0
resolution: "@fluencelabs/deal-ts-clients@npm:0.23.2-feat-marketplace-v2-resources-eb89b78-7511-1.0"
dependencies:
"@graphql-typed-document-node/core": "npm:^3.2.0"
debug: "npm:^4.3.4"
Expand All @@ -2052,7 +2052,7 @@ __metadata:
graphql-tag: "npm:^2.12.6"
ipfs-http-client: "npm:^60.0.1"
multiformats: "npm:^13.0.1"
checksum: 10c0/539d77261a226fb09fb02c671fb221a31de4947988997b0a355479cf1f84358ecdacc14e4bb6e56c5d8d8ba34715f592b738ee215d205cb7100fb13f70785353
checksum: 10c0/55b1d3f36725afeb33171e945895daa175b5de821c6e52406fe1b1f688fb486f369008d15102a795cb8156b9ae146205d3a4f4c9b7462da88a2c1cec16aa25da
languageName: node
linkType: hard

Expand Down

0 comments on commit b928a16

Please sign in to comment.