Skip to content

Commit

Permalink
fix soultion provider ID, deployment data and hash
Browse files Browse the repository at this point in the history
  • Loading branch information
sameh-farouk committed Feb 4, 2024
1 parent d7ce510 commit 2481fe3
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/mappings/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<NameContract>(newNameContract)
}
else if (contractEvent.contractType.__kind === "NodeContract") {
Expand All @@ -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: {
Expand Down Expand Up @@ -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<RentContract>(newRentContract)

// Update node to dedicated if it is rented
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2481fe3

Please sign in to comment.