From 2481fe326be30bc40b0746ec99a67f6cdbb1109f Mon Sep 17 00:00:00 2001 From: Sameh Abouel-saad Date: Sun, 4 Feb 2024 15:48:16 +0200 Subject: [PATCH] fix soultion provider ID, deployment data and hash --- src/mappings/contracts.ts | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/mappings/contracts.ts b/src/mappings/contracts.ts index 592d17e..dd91c75 100644 --- a/src/mappings/contracts.ts +++ b/src/mappings/contracts.ts @@ -65,6 +65,14 @@ export async function contractCreated( contractEvent = contractCreatedEvent.asV105 newNameContract.solutionProviderID = Number(contractEvent.solutionProviderId) || 0 } + if (contractCreatedEvent.isV147) { + contractEvent = contractCreatedEvent.asV147 + newNameContract.solutionProviderID = Number(contractEvent.solutionProviderId) || 0 + } + if (contractCreatedEvent.isV148) { + contractEvent = contractCreatedEvent.asV148 + newNameContract.solutionProviderID = Number(contractEvent.solutionProviderId) || 0 + } await ctx.store.save(newNameContract) } else if (contractEvent.contractType.__kind === "NodeContract") { @@ -90,7 +98,14 @@ export async function contractCreated( contractEvent = contractCreatedEvent.asV105 newNodeContract.solutionProviderID = Number(contractEvent.solutionProviderId) || 0 } - + if (contractCreatedEvent.isV147) { + contractEvent = contractCreatedEvent.asV147 + newNodeContract.solutionProviderID = Number(contractEvent.solutionProviderId) || 0 + } + if (contractCreatedEvent.isV148) { + contractEvent = contractCreatedEvent.asV148 + newNodeContract.solutionProviderID = Number(contractEvent.solutionProviderId) || 0 + } // Gather IPS and update them let touchedIps: PublicIp[] = await ctx.store.find(PublicIp, { where: { @@ -131,6 +146,14 @@ export async function contractCreated( contractEvent = contractCreatedEvent.asV105 newRentContract.solutionProviderID = Number(contractEvent.solutionProviderId) || 0 } + if (contractCreatedEvent.isV147) { + contractEvent = contractCreatedEvent.asV147 + newRentContract.solutionProviderID = Number(contractEvent.solutionProviderId) || 0 + } + if (contractCreatedEvent.isV148) { + contractEvent = contractCreatedEvent.asV148 + newRentContract.solutionProviderID = Number(contractEvent.solutionProviderId) || 0 + } await ctx.store.save(newRentContract) // Update node to dedicated if it is rented @@ -194,9 +217,8 @@ async function updateNodeContract(ctx: Ctx, ctr: any, contract: NodeContract, st contract.nodeID = parsedNodeContract.nodeId contract.numberOfPublicIPs = parsedNodeContract.publicIps - - contract.deploymentData = validateString(ctx, contract.deploymentData.toString()) - contract.deploymentHash = validateString(ctx, contract.deploymentHash.toString()) + contract.deploymentData = validateString(ctx, parsedNodeContract.deploymentData.toString()) + contract.deploymentHash = validateString(ctx, parsedNodeContract.deploymentHash.toString()) let state = ContractState.OutOfFunds switch (ctr.state.__kind) {